Skip to content
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

App login function freezes/hangs when React-Native environment is reloaded (press R twice) on Android #3668

Closed
petergaal opened this issue Mar 29, 2021 · 5 comments · Fixed by #3794

Comments

@petergaal
Copy link

petergaal commented Mar 29, 2021

Goals

Fix freezing login function on App class in React-Native Android application after reloading.

Expected Results

Login function should not freeze.

Actual Results

Login function freezes/hangs forever after logging in into application when the application is reloaded.

Steps to Reproduce

We have a React-Native application running as Android application (in emulator, but similar thing happens on real device). When I reload the application in React-Native environment (pressing R key twice) and I try to log in then the application will freeze forever on login function in App class.

What I already tried:

  • realmApp.allUsers[key].loggedIn - false (only one user visible in allUsers)
  • realmApp.allUsers[key].logOut() - didn't help
  • realmApp.currentUser = returns null
  • deleting realm files with adb shell commands - didn't help
  • killing the application from memory - after starting the application it works again (just by closing where the application is running in the background and starting it from there doesn't help)
  • reinstalling the application (react-native run-android) - works again

Code Sample

const getRealmApp = () => {
  const appConfig = {
    id: Config.REALM_DIR,
    timeout: 30000,
  };
  return new Realm.App(appConfig);
};

export const realmApp = getRealmApp();



export const signIn = async jwt => {
  const creds = Realm.Credentials.jwt(jwt);
  await realmApp?.logIn(creds);  // <- the application will hang on this line
};

Version of Realm and Tooling

  • Realm npm package: 10.2.0
  • Realm JS SDK Version: ?
  • react-native: 0.63.3
  • Android: 10
  • node: v14.9.0
  • Which debugger for React Native: 0.10.7 (not connected)
@kneth
Copy link
Member

kneth commented Mar 29, 2021

Thank you for reporting. We have had a similar issue before (#3236), but the fix back then didn't solve all edge cases.

Does it only happen when using Android 10 or do you also observe it with other versions of Android?

@petergaal
Copy link
Author

We didn't test it on different version of Android, only version 10. But we can try to test it if it would be useful. Please, let me know.

@kneth
Copy link
Member

kneth commented Mar 30, 2021

If it is possible, we will appreciate it.

@petergaal
Copy link
Author

Hi. So I made a quick test and on other versions the result is the same. I tested Android versions with API Level 24-28 (Android 7.0 to Android 9.0). I get into a situation sometimes when the application was crashing on API Level 24 and 26 but after repeating the test I always get into a situation of hanging forever.

@luantrasel
Copy link

Any update on this? I'm having the same problem on version 10.4.0

RedBeard0531 added a commit that referenced this issue Jun 8, 2021
This makes it also call `realm::app::App::clear_cached_apps()`, which
fixes #3668. This also makes it more maintainable by having a single place to
put all cache clearing logic for all RN platforms.
RedBeard0531 added a commit that referenced this issue Jun 8, 2021
This makes it also call `realm::app::App::clear_cached_apps()`, which
fixes #3668. This also makes it more maintainable by having a single place to
put all cache clearing logic for all RN platforms.
RedBeard0531 added a commit that referenced this issue Jun 8, 2021
This makes it also call `realm::app::App::clear_cached_apps()`, which
fixes #3668. This also makes it more maintainable by having a single place to
put all cache clearing logic for all RN platforms.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants