[Fix][Android] Avoid blocking threads to prevent deadlocks
Similar to https://github.com/oblador/react-native-keychain/pull/547, I've run into issues with main thread deadlocking when using this library to show a BiometricPrompt and have seen an increased rate of ANRs on Crashlytics.
Upon further digging it was due to react-native-reanimated attempting to acquire a lock on the main thread, but since this library waits on the JS thread for the BiometricPrompt to show and finish on the main thread, a deadlock occurs.
This library avoids blocking the JS thread by using a listener to resolve a promise when decryption finishes. Since there are no additional dependencies, this should be compatible up to API level 21.
This PR should fix https://github.com/oblador/react-native-keychain/issues/525
For reanimated related issues, please refer to this PR and thread https://github.com/software-mansion/react-native-reanimated/pull/3440
Thanks @androideveloper for referring me to that thread! Glad to know something is also being done on the reanimated side to fix it. However, I think we should still consider fixing this thread-blocking behavior as well since it is not ideal to be blocking a thread while waiting for the biometrics prompt to finish. Would appreciate any comments or feedback on the PR!
I experienced the same issue and could resolve by using the version from this PR, all tests so far are successful. Is there anything I can support with to get this change / fix merged into upstream?
@oblador Any chance you could take a look at this, seems like it's still affecting a few folks
Any progress / blockers on this PR? Can we prioritize this?
Hi @frw! I'm going to have a look at your PRs in this repo. Did you already test these changes in a real app?
Fixed in 9.0.0