-
Notifications
You must be signed in to change notification settings - Fork 609
Description
How frequently does the bug occur?
Once
Description
I'm having an issue with an upgraded React Native app using Realm. On Android, the app crashes on first launch, but works properly later. I have tried isolating the issue but it appears to happen on first interaction with Realm no matter what.
The issue starts with "Cannot access realm that has been closed" then crashes after "Access to invalidated Results objects".
The issue does NOT appear in debug mode, only in release.
I hope someone has had a similar issue and can point me in the right direction.
Of suspect is that setDefaultRealmFileDirectory seems to run twice. If anyone can figure out why that is happening, maybe that is the issue? That does not seem to be called at all on subsequent launches.
Stacktrace & log output
2025-11-11 20:59:25.478 15596-15596 SoLoader com.myapp.myapp W SoLoader already initialized
2025-11-11 20:59:25.478 15596-15596 SoLoader com.myapp.myapp W SoLoader already initialized
2025-11-11 20:59:25.481 15596-15725 Realm com.myapp.myapp V setDefaultRealmFileDirectory
2025-11-11 20:59:25.481 15596-15725 Realm com.myapp.myapp D Absolute path: /data/data/com.myapp.myapp/files
2025-11-11 20:59:25.481 15596-15596 InstallReferrerState com.myapp.myapp D OK
2025-11-11 20:59:25.486 15596-15725 Realm com.myapp.myapp V setDefaultRealmFileDirectory
2025-11-11 20:59:25.486 15596-15725 Realm com.myapp.myapp D Absolute path: /data/data/com.myapp.myapp/files
2025-11-11 20:59:25.486 15596-15596 InstallReferrerState com.myapp.myapp D OK
2025-11-11 20:59:25.560 15596-15642 ReactNativeJS com.myapp.myapp E [Error: Cannot access realm that has been closed.]
2025-11-11 20:59:25.560 15596-15726 ReactNativeJS com.myapp.myapp W `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
2025-11-11 20:59:25.561 15596-15726 ReactNativeJS com.myapp.myapp W `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.
2025-11-11 20:59:25.561 15596-15643 unknown:ReactNative com.myapp.myapp E Error: Cannot access realm that has been closed., stack:
beginTransaction@1:820933
write@1:982221
anonymous@1:773598
anonymous@1:777928
anonymous@1:777723
2025-11-11 20:59:25.832 15596-15726 ReactNativeJS com.myapp.myapp E [Error: Exception in HostFunction: Could not enqueue microtask because they are disabled in this runtime]
2025-11-11 20:59:25.832 15596-15727 unknown:ReactNative com.myapp.myapp E Error: Exception in HostFunction: Could not enqueue microtask because they are disabled in this runtime, js engine: hermes, stack:
setImmediate@1:231602
anonymous@1:261076
dispatchEvent@1:243857
setReadyState@1:239017
__didCompleteResponse@1:236590
anonymous@1:238654
emit@1:96661
anonymous@1:94068
emit@1:94375
__callFunction@1:86058
anonymous@1:84363
__guard@1:85319
callFunctionReturnFlushedQueue@1:84321
2025-11-11 20:59:25.865 15596-15726 ReactNativeJS com.myapp.myapp E [Error: Exception in HostFunction: Could not enqueue microtask because they are disabled in this runtime]
2025-11-11 20:59:25.866 15596-15727 unknown:ReactNative com.myapp.myapp E Error: Exception in HostFunction: Could not enqueue microtask because they are disabled in this runtime, js engine: hermes, stack:
setImmediate@1:231602
anonymous@1:261076
dispatchEvent@1:243857
setReadyState@1:239017
__didCompleteResponse@1:236590
anonymous@1:238654
emit@1:96661
anonymous@1:94068
emit@1:94375
__callFunction@1:86058
anonymous@1:84363
__guard@1:85319
callFunctionReturnFlushedQueue@1:84321
2025-11-11 20:59:25.866 15596-15726 ReactNativeJS com.myapp.myapp E [Error: Exception in HostFunction: Could not enqueue microtask because they are disabled in this runtime]
2025-11-11 20:59:25.866 15596-15727 unknown:ReactNative com.myapp.myapp E Error: Exception in HostFunction: Could not enqueue microtask because they are disabled in this runtime, js engine: hermes, stack:
setImmediate@1:231602
anonymous@1:261076
dispatchEvent@1:243857
setReadyState@1:239017
__didCompleteResponse@1:236590
anonymous@1:238654
emit@1:96661
anonymous@1:94068
emit@1:94375
__callFunction@1:86058
anonymous@1:84363
__guard@1:85319
callFunctionReturnFlushedQueue@1:84321
2025-11-11 20:59:26.047 15596-15726 ReactNativeJS com.myapp.myapp E [Error: Exception in HostFunction: Could not enqueue microtask because they are disabled in this runtime]
2025-11-11 20:59:26.048 15596-15727 unknown:ReactNative com.myapp.myapp E Error: Exception in HostFunction: Could not enqueue microtask because they are disabled in this runtime, js engine: hermes, stack:
setImmediate@1:231602
anonymous@1:261076
dispatchEvent@1:243857
setReadyState@1:239017
__didCompleteResponse@1:236590
anonymous@1:238654
emit@1:96661
anonymous@1:94068
emit@1:94375
__callFunction@1:86058
anonymous@1:84363
__guard@1:85319
callFunctionReturnFlushedQueue@1:84321
2025-11-11 20:59:26.619 15596-15600 hockey.cyclones com.myapp.myapp W Suspending all threads took: 6.124ms
2025-11-11 20:59:26.633 15596-15600 hockey.cyclones com.myapp.myapp I NativeAlloc concurrent mark compact GC freed 21MB AllocSpace bytes, 141(4640KB) LOS objects, 49% free, 14MB/28MB, paused 6.690ms,366us total 35.061ms
2025-11-11 20:59:26.634 15596-15602 hockey.cyclones com.myapp.myapp W ApkAssets: Deleting an ApkAssets object '<empty> and /data/app/~~WDwppNDoZp4HOSANZ5s4TA==/com.google.android.webview-lSidrLoc2mPDEe5o_LMHFg==/base.apk' with 2 weak references
2025-11-11 20:59:29.929 15596-15860 ProfileInstaller com.myapp.myapp D Installing profile for com.myapp.myapp
2025-11-11 20:59:32.404 15596-15635 EGL_emulation com.myapp.myapp D app_time_stats: avg=832.67ms min=1.11ms max=7180.23ms count=9
2025-11-11 20:59:32.414 15596-15642 ReactNativeJS com.myapp.myapp E Error: Access to invalidated Results objects
This error is located at:
in OnboardingScreen
in WrappedComponent
in RCTView
in Unknown
in AppContainer
2025-11-11 20:59:32.415 15596-15643 unknown:ReactNative com.myapp.myapp E Error: Access to invalidated Results objects
This error is located at:
in OnboardingScreen
in WrappedComponent
in RCTView
in Unknown
in AppContainer, stack:
size@1:819660
get@1:963770
get@1:946197
anonymous@1:2222387
callCallback@1:132940
commitCallbacks@1:133026
commitClassCallbacks@1:164834
commitLayoutEffectOnFiber@1:165849
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165627
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165334
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165905
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165951
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165905
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165951
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165435
commitRootImpl@1:177250
commitRoot@1:176804
commitRootWhenReady@1:173321
performConcurrentWorkOnRoot@1:172751
2025-11-11 20:59:32.428 15596-15642 ReactNativeJS com.myapp.myapp E Error: Access to invalidated Results objects
This error is located at:
in OnboardingScreen
in WrappedComponent
in RCTView
in Unknown
in AppContainer
2025-11-11 20:59:32.460 15596-15643 unknown:BridgelessReact com.myapp.myapp W ReactHost{0}.handleHostException(message = "Error: Access to invalidated Results objects
This error is located at:
in OnboardingScreen
in WrappedComponent
in RCTView
in Unknown
in AppContainer, stack:
size@1:819660
get@1:963770
get@1:946197
anonymous@1:2222387
callCallback@1:132940
commitCallbacks@1:133026
commitClassCallbacks@1:164834
commitLayoutEffectOnFiber@1:165849
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165627
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165334
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165905
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165951
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165905
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165951
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165435
commitRootImpl@1:177250
commitRoot@1:176804
commitRootWhenReady@1:173321
performConcurrentWorkOnRoot@1:172751
")
2025-11-11 20:59:32.460 15596-15643 AndroidRuntime com.myapp.myapp E FATAL EXCEPTION: mqt_v_native
Process: com.myapp.myapp, PID: 15596
com.facebook.react.common.JavascriptException: Error: Access to invalidated Results objects
This error is located at:
in OnboardingScreen
in WrappedComponent
in RCTView
in Unknown
in AppContainer, stack:
size@1:819660
get@1:963770
get@1:946197
anonymous@1:2222387
callCallback@1:132940
commitCallbacks@1:133026
commitClassCallbacks@1:164834
commitLayoutEffectOnFiber@1:165849
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165627
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165334
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165905
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165951
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165905
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165951
recursivelyTraverseLayoutEffects@1:168668
commitLayoutEffectOnFiber@1:165435
commitRootImpl@1:177250
commitRoot@1:176804
commitRootWhenReady@1:173321
performConcurrentWorkOnRoot@1:172751
at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.kt:52)
at com.facebook.jni.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:959)
at android.os.Handler.dispatchMessage(Handler.java:100)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.lambda$startNewBackgroundThread$2(MessageQueueThreadImpl.java:217)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
at java.lang.Thread.run(Thread.java:1119)
2025-11-11 20:59:32.464 15596-15596 unknown:BridgelessReact com.myapp.myapp W ReactHost{0}.onHostPause(activity)
2025-11-11 20:59:32.464 15596-15596 unknown:BridgelessReact com.myapp.myapp W ReactContext.onHostPause()
2025-11-11 20:59:32.465 15596-15643 Process com.myapp.myapp I Sending signal. PID: 15596 SIG: 9Can you reproduce the bug?
Always
Reproduction Steps
No response
Version
20.2.0
What services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
Android 35
Build environment
React Native 0.77.3
Cocoapods version
No response