-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application Settings blocks UI thread #4871
Comments
This seems like a reasonable request. The proposed options will introduce changes in behaviour though. I think it will be better to introduce a new set of Are you willing to open a PR with your implementation? You can check our contribution guidelines to get you started. |
@vakrilov Sure I don't mind submitting this as a PR. The behavior change you are talking about would only be on iOS, if the app hard-exits almost immediately after a If you don't like the minor behavior change, would you then suggest adding these methods?
|
I think it would be better to have
It is the more common convention (most notably in the the node APIs). About the behaviour change - if your code sets a variable and than (almost)immediately reads it you might be affected. That's why I think new |
Which platform does this happen on? As far as I know both iOS and Android has in-memory cache of NSUserDefaults and SharedPreferences respectively. So a read after change, would just access the in-memory cache. Some quotes on this:
|
@vakrilov could you elaborate on the behaviour change, taking the above quotes into account? |
Hey @ddfreiling - you are right, I wasn't aware about the in-memory cache. Having an explicit Thanks again for your involvement! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?
Tell us about the problem
Currently the
application-settings
module synchronize changes to disk every time a value is set. This could lead to main-thread blocking when setting large amounts of settings and/or large values. Especially at key moments, when 60fps is desired, like page transitions.Post iOS 7, one should not call
synchronize
after each change. (source)applicationDidEnterBackground
, see source for reason.On Android, one should not call
commit
after each change, but insteadapply
. (source)Proposed Change
synchronize
on iOS and useapply
on Android.flush
call which synchronize/commit changes to disk, so that the user still has the option.appSettings.flush()
onapplication.suspendEvent
.Side-note: Ideally I'd like to have something like RN's AsyncStorage
Plugin
@nota/nativescript-appsettings-async
To demo this I created a plugin with the changes proposed above. In the demo you can see the difference, which is quite big on Android. 4000ms /w commit vs. 100ms /w apply.
The text was updated successfully, but these errors were encountered: