firstfloorsoftware / flutter_sodium

Flutter bindings for libsodium
BSD 3-Clause "New" or "Revised" License
102 stars 47 forks source link

Executes intensive tasks on main thread #5

Closed jeprojects closed 6 years ago

jeprojects commented 6 years ago

Is it executing the libsodium-jni calls in android on the main thread?

I/Choreographer( 5283): Skipped 67 frames! The application may be doing too much work on its main thread.

This happens when doing crypto calls like Argon2.

kozw commented 6 years ago

That's a correct observation. Will need to identity the long running APIs (such as password hashing) and move them to a background task

jeprojects commented 6 years ago

Shouldn't all crypto related tasks be moved to a background task rather than the one the UI is using ?

I can see a case where decrypting and encrypting a large amount of messages using ChaChaPoly cause cause UI issues.

kozw commented 6 years ago

Not sure if all crypto tasks needs to run in a background task. Creating and executing background tasks are not free. Most crypto task are lightweight, having them execute in the background only costs valuable CPU cycles. Maybe providing an option to run a crypto task in the foreground/background is the answer. Will need to measure on both Android and iOS.

jeprojects commented 6 years ago

That sounds perfect.

kozw commented 6 years ago

FYI: just pushed a commit to the develop branch adding support for running crypto operations on a background in Android. By default all crypto APIs execute on the UI thread, except for crypto_pwhash. Works beautifully.

iOS is work in progress.