react-native-keychain icon indicating copy to clipboard operation
react-native-keychain copied to clipboard

[Fix][Android] Avoid blocking threads to prevent deadlocks

Open frw opened this issue 3 years ago • 6 comments

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

frw avatar Nov 13 '22 10:11 frw

For reanimated related issues, please refer to this PR and thread https://github.com/software-mansion/react-native-reanimated/pull/3440

androideveloper avatar Nov 22 '22 11:11 androideveloper

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!

frw avatar Nov 24 '22 08:11 frw

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?

ca057 avatar Feb 06 '23 11:02 ca057

@oblador Any chance you could take a look at this, seems like it's still affecting a few folks

frw avatar Feb 15 '23 09:02 frw

Any progress / blockers on this PR? Can we prioritize this?

kabirbaidhya avatar Feb 23 '23 10:02 kabirbaidhya

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?

androideveloper avatar Feb 07 '24 16:02 androideveloper

Fixed in 9.0.0

DorianMazur avatar Oct 03 '24 10:10 DorianMazur