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

React Native Android application crashing when using syncSession.addConnectionNotification #6579

Open
gfrancischini opened this issue Mar 26, 2024 · 9 comments · Fixed by #6612

Comments

@gfrancischini
Copy link

gfrancischini commented Mar 26, 2024

How frequently does the bug occur?

Always

Description

The react native application is crashing when there is an active syncSession.addConnectionNotification and the app gets reloaded

Stacktrace & log output

Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x30 in tid 8357 (mqt_js), pid 8292 (om.synctutorial)
2024-03-26 17:24:24.007  8292-8292  unknown:Re...nceManager com.synctutorial                     E  destroyRootView called
2024-03-26 17:24:24.009  8292-8292  unknown:Re...nceManager com.synctutorial                     E  destroyRootView called, unmountReactApplication

Cmdline: com.synctutorial
2024-03-26 17:24:25.208  8538-8538  DEBUG                   crash_dump64                         A  pid: 8292, tid: 8357, name: mqt_js  >>> com.synctutorial <<<
2024-03-26 17:24:25.208  8538-8538  DEBUG                   crash_dump64                         A        #00 pc 00000000003bfd00  /data/app/~~kwxPndNsCq5S-a142smnIA==/com.synctutorial-Jxnmi56nwT1pLTopnsEDBg==/lib/arm64/librealm.so (BuildId: edf6f0d435afef43e7dfceba74cfdd58b0289992)
2024-03-26 17:24:25.208  8538-8538  DEBUG                   crash_dump64                         A        #01 pc 00000000003c061c  /data/app/~~kwxPndNsCq5S-a142smnIA==/com.synctutorial-Jxnmi56nwT1pLTopnsEDBg==/lib/arm64/librealm.so (BuildId: edf6f0d435afef43e7dfceba74cfdd58b0289992)
2024-03-26 17:24:25.208  8538-8538  DEBUG                   crash_dump64                         A        #02 pc 000000000041c924  /data/app/~~kwxPndNsCq5S-a142smnIA==/com.synctutorial-Jxnmi56nwT1pLTopnsEDBg==/lib/arm64/librealm.so (BuildId: edf6f0d435afef43e7dfceba74cfdd58b0289992)
2024-03-26 17:24:25.208  8538-8538  DEBUG                   crash_dump64                         A        #03 pc 000000000041d634  /data/app/~~kwxPndNsCq5S-a142smnIA==/com.synctutorial-Jxnmi56nwT1pLTopnsEDBg==/lib/arm64/librealm.so (BuildId: edf6f0d435afef43e7dfceba74cfdd58b0289992)

Can you reproduce the bug?

Yes, always

Reproduction Steps

Using this branch: https://github.com/Spring-Global/realm-react-native-sample/tree/realm-crash-callback

  1. Run the application on android emulator
  2. Refresh the react native app with cmd+r

Version

realm@12.6.2

What services are you using?

Atlas Device Sync

Are you using encryption?

No

Platform OS and version(s)

Android - Emulator API 34

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

Copy link

sync-by-unito bot commented Mar 26, 2024

➤ PM Bot commented:

Jira ticket: RJS-2784

@kneth
Copy link
Member

kneth commented Apr 9, 2024

@gfrancischini Thank you for reporting.

The issue is similar to #6558, and we are investigating.

@kneth
Copy link
Member

kneth commented Apr 12, 2024

@gfrancischini I have a PR up which I think will fix the issue: #6612

@gfrancischini
Copy link
Author

Hi Kneth, thanks for the update. It seems that the change is only on JS side right?

// Clear the internal state to prevent crashes when reloading on React Native
binding.RealmCoordinator.clearAllCaches();
binding.App.clearCachedApps();

I will give a try

@vatsal-gadhiya-searce
Copy link

@kneth We have tried hot reload this time and the app is still crashing for us with latest version of realm 12.7.1.

Note: It does not crashes normally though for the first time.

@kneth
Copy link
Member

kneth commented Apr 26, 2024

@vatsal-gadhiya-searce Sorry to hear. I'll reopen the issue and we need to investigate further. If you can share a stack trace, we will appreciate it.

@kneth kneth reopened this Apr 26, 2024
@Premshankar-Searce
Copy link

@kneth here repo realmDemo reproducible

  • on restarting app also crashing after 2 - 3 times
  • Attaching a video for steps to reproduce
test.mp4

@kraenhansen
Copy link
Member

It seems to me we need to add a cleanup of connection state listeners, the same way we clean up other listeners passed to core, as part of the cleanup we do here:

// Clear the internal state to prevent crashes when reloading the app
binding.RealmCoordinator.clearAllCaches();
binding.App.clearCachedApps();

More specifically, we should expose a method on the SyncSession in Core (similiar to unregister_connection_change_callback) to remove all listeners from the underlying vector holding references to connection listener callbacks.

@altenorjr
Copy link

I'm finding this exact same issue on iOS since migrating to v12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants