realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

Android app crash after calling codepush.restart()

Open ra1nj opened this issue 9 months ago • 4 comments

How frequently does the bug occur?

Always

Description

Same as https://github.com/realm/realm-js/issues/6903;

Stacktrace & log output

FATAL EXCEPTION: mqt_native_modules
                                                                                                    Process: 
                                                                                                    java.lang.UnsatisfiedLinkError: No implementation found for void io.realm.react.RealmReactModule.invalidateCaches() (tried Java_io_realm_react_RealmReactModule_invalidateCaches and Java_io_realm_react_RealmReactModule_invalidateCaches__)
                                                                                                    	at io.realm.react.RealmReactModule.invalidateCaches(Native Method)
                                                                                                    	at io.realm.react.RealmReactModule.invalidate(RealmReactModule.java:58)
                                                                                                    	at com.facebook.react.bridge.ModuleHolder.destroy(ModuleHolder.java:109)
                                                                                                    	at com.facebook.react.bridge.NativeModuleRegistry.notifyJSInstanceDestroy(NativeModuleRegistry.java:86)
                                                                                                    	at com.facebook.react.bridge.CatalystInstanceImpl.lambda$destroy$2(CatalystInstanceImpl.java:366)
                                                                                                    	at com.facebook.react.bridge.CatalystInstanceImpl.$r8$lambda$Oa3wfVCkSpv9UbaDKR-owki1vUU(Unknown Source:0)
                                                                                                    	at com.facebook.react.bridge.CatalystInstanceImpl$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:900)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:103)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
                                                                                                    	at android.os.Looper.loop(Looper.java:219)
                                                                                                    	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:929)

Can you reproduce the bug?

Always

Reproduction Steps

  1. Integrate realm-js v20.1.0
  2. Integrate react-native-code-push
  3. Calling CodePush.restartApp();

Version

20.1.0

What services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Android,

Build environment

No response

Cocoapods version

No response

ra1nj avatar Mar 26 '25 02:03 ra1nj

Anyone can help on this issue ?

ra1nj avatar Apr 07 '25 01:04 ra1nj

+1

hamzasaleem3 avatar Apr 08 '25 12:04 hamzasaleem3

I found the root cause of this issue is that we don't initialize the realm library on the start of the app , we initialize it when certain module is loaded. it will crash if the realm is not initialized yet , else won't. So i add a workaround like this

    @Override
    public void invalidate() {
        try {
            invalidateCaches();
        }catch (UnsatisfiedLinkError e){
            Log.e("Realm",e.toString());
        }
    }

Basically just added a try catch to prevent the app crash, and it won't damage the function since if the realm is not initialized , there is no need to clear caches.

ra1nj avatar Apr 09 '25 02:04 ra1nj

+1 experiencing this on Android only as well - the number of crashes seems to be correlated with the number of failed installs after downloads

Using Revopush as a provider ( fork of AppCenter Codepush )

Alex7734 avatar May 06 '25 06:05 Alex7734