Slow AES-GCM decryption for initial runs
I am developing an app on the Android simulator in debug mode. The user sets a configuration and the app begins solving a problem. The app needs to do the following for 16 iterations: Read a file from local storage with size 154 KB to 177 KB; Decrypt the file encoded with AES-GCM-128; Check the SHA256; Inflate the GZIP file; Reformat the data in memory for consumption by the app.
All of the operations take on the order of 20-150 ms except the first run(s) of decryption. For the first three files, decryption with the Cryptography package takes 32.35, 0.408, 0.111 seconds. Thereafter, decryption takes 0.094 to 0.156 seconds.
The Cryptography Flutter package is worse. For the first six files, decryption takes 32.971, 37.251, 38.330, 38.853, 0.669, 0.128 seconds. Thereafter, decryption takes around 0.13 seconds.
Questions: Why is the Cryptography package so slow for decryption in the initial runs? Would this behavior occur on real devices when built for highest performance?
I decided to boot Cryptography Flutter from my app because of its appallingly bad performance. I am replacing it with native-crypto-flutter. While native-crypto lacks the polish of a mature package, it can encrypt or decrypt a 170 KB file in 11 ms compared to Cryptography Flutter at 94 ms in the best case or 39 seconds in the worse case.
any fix or infos on this issue yet ?
Fixed in cryptography_flutter 2.1.0.