sindresorhus / Defaults

💾 Swifty and modern UserDefaults
https://swiftpackageindex.com/sindresorhus/Defaults/documentation/defaults
MIT License
1.93k stars 115 forks source link

High CPU when navigating away from view with the RequestReviewAction #146

Closed byaruhaf closed 11 months ago

byaruhaf commented 11 months ago

I have integrated this package into my application, and I've been working on implementing the "Request Review" feature. However, each time I navigate away from the screen containing the @Environment(\.requestReview) property to a screen using @Default(.localSavedStudents), the screen freezes, and I've noticed that the CPU usage exceeds 100%.

You can access a sample project using the link below, with code that you can run to recreate this issue.

https://github.com/byaruhaf/DefTest

is there some hidden interaction between Defaults & StoreKit?

Because if comment out either

`@Environment(\.requestReview) private var requestReview`

or @Default(.localSavedStudents) var localSavedStudents

The problem is resolved, using both however the problem returns.

High CPU

image

Increasing Memory

image
sindresorhus commented 11 months ago

I can reproduce the issue even without @Default. Try replacing @Default(.localSavedStudents) var localSavedStudents with @ObservedObject var test = Test().

final class Test: ObservableObject {}
byaruhaf commented 11 months ago

oops, sorry my bad didn't think to test that.