Skip to content
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

Initial key generation hangs UI rendering #116

Closed
morrica opened this issue Apr 14, 2020 · 3 comments
Closed

Initial key generation hangs UI rendering #116

morrica opened this issue Apr 14, 2020 · 3 comments

Comments

@morrica
Copy link
Contributor

morrica commented Apr 14, 2020

The initial key generation on first run will hang UI rendering including initial Widget paints or animations. This is a big issue for a live app because a new user's first impression will be that the app is clunky and slow to load.

This appears to only affect running on real devices, perhaps because the emulator is able to use underlying PC hardware generate the key faster than is noticeable.

As is, this issue prevents the app from loading any UI for between 5 and 30 seconds on first launch on a Pixel 3 running latest Android 10 build QQ2A.200305.002.

Modifying FlutterSecureStoragePlugin.java to wait for an actual channel method call to initialize the StorageCipher will result in animations completely hanging for a similar period of time.

An example app that demonstrates the problem is included below. To reproduce the issue, run the given app on a real device and time the period before the LoadingScreen is rendered. Then time it a second time after the StorageCipher has been initialized. To retest the first run case you can clear the app's storage on the test device.

test_app.zip

mogol pushed a commit that referenced this issue May 3, 2020
#117)

* Fix for Android hanging UI on StorageCipher initialization.
Similar issue may or may not affect iOS.
Basic architecture example taken from flutter/flutter#22024 (comment)

* Fix for potential race condition on StorageCipher initialization.
@gargakshit
Copy link

I encountered the same issue yesterday, and it seems like either we have to use isolate or manually delay the key generation (workaround)

@morrica
Copy link
Contributor Author

morrica commented May 12, 2020

@gargakshit, this issue has been fixed in the merged commit above. The fix has not yet been pushed to pub.dev, but you can depend on github code directly in your pubspec.yaml if necessary.

@morrica morrica closed this as completed May 12, 2020
@gargakshit
Copy link

Cool, I'll use the git version. Thanks for the timely response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants