-
-
Notifications
You must be signed in to change notification settings - Fork 524
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
getGenericPassword on Android sometimes fails and crashes app #525
Comments
in my android it does not do anything code stopes on "await Keychain.getGenericPassword" and thats it |
@jm90m @kriit24 Did you manage to find a fix for this? Getting a similar experience as well but can't seem to figure out what exactly is causing it or how to reproduce. Only hacky workaround that I could find is if I run async code before calling Example: setLoading(true);
await delay(500);
const credentials = await Keychain.getGenericPassword();
setLoading(false); For more context:
Lmk if there's any other information I can give to debug this. |
I've dug deeper into this issue and have been able to consistently reproduce it. TLDR: It seems to occur when biometrics is triggered in the middle of unfinished UI navigation or rendering; Reproduction steps:In an Android device try these:
Why?Looking through the android device logs, I've seen this occur only in cases where biometrics is triggered in the middle of navigation/rendering or when a UI operation is in-progress but not complete, and then the biometrics prompt is presented just in time. When the prompt is presented, the underlying logic blocks the main activity thread while waiting to capture user’s biometrics and this freezes the main thread in the middle of ongoing UI operation which leads to it being unresponsive even after user’s biometrics input is done. And once it is frozen, regardless of the result – success or failure – the app always crashes. Additionally, it is also susceptible to race conditions which makes it harder to reproduce. Android LogsRegular flow logs (no crash)
Logs during the crash
You can see in that there are 2 main differences in the above logs:
|
Same problem occurs in our app on Android. No particular version - seems to occur on any device. We reproduce it like so: import Keychain from 'react-native-keychain';
async function getBiometryPassword() {
console.log(1);
/*
// Optionally, we can block the thread for a couple of seconds,
// just to not have to be quick with minimizing the app.
const start = Date.now();
while (Date.now() < start + 2000) {}
console.log(2);
*/
const value = await Keychain.getGenericPassword({
service: 'our-bio-password-key',
accessible: Keychain.ACCESSIBLE.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY,
securityLevel: Keychain.SECURITY_LEVEL.SECURE_HARDWARE,
accessControl: Keychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET,
authenticationType: Keychain.AUTHENTICATION_TYPE.BIOMETRICS
}).catch(error => {
console.log(3);
throw error;
});
console.log(4);
return value;
} If you start the app, call Also, we don't get app state change event fired ( import { AppState } from 'react-native';
AppState.addEventListener('change', handleAppStateChange); |
I'm having the same issue. As soon as I call getGenericPassword the app freezes and a few seconds later "App not responding" pop-up shows up! This is a serious issue guys! |
@BraveEvidence Thanks, I'll take a look at it for sure but the thing is I had to prepare a release for pen-testing so wouldn't have time to deal with this stuff :/ thanks to @hazim-j the solution he found worked for me! |
@tsdmrfth what was the fix ? |
This is happening for me as well - dev and prod - unsure of what the conditions are, but it typically seems to hang most if called relatively quickly after an app background -> foreground . Killing the app and restarting always fixes the issue. |
getGenericPassword on android sometimes fails. I can't figure out why, it just crashes the app.
The text was updated successfully, but these errors were encountered: