zoontek / react-native-bootsplash

🚀 Show a splash screen during app startup. Hide it when you are ready.
MIT License
3.74k stars 258 forks source link

NullPointerException Error: RNBootSplashDialog.show(java.lang.Runnable) #637

Closed kf94 closed 1 month ago

kf94 commented 1 month ago

Before submitting a new issue

Bug summary

I am experiencing crashes on Android 14 and earlier versions across various devices with v6.1.3.

Error:

Attempt to invoke virtual method 'void com.zoontek.rnbootsplash.RNBootSplashDialog.show(java.lang.Runnable)' on a null object reference

Stack trace:

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.zoontek.rnbootsplash.RNBootSplashDialog.show(java.lang.Runnable)' on a null object reference at com.zoontek.rnbootsplash.RNBootSplashModuleImpl$3.run(RNBootSplashModuleImpl.java:130) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at android.app.ActivityThread.main(ActivityThread.java:9063) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:588) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

This seems similar to https://github.com/zoontek/react-native-bootsplash/issues/601

Library version

6.1.3

Environment info

"react-native": "0.73.8"

Steps to reproduce

I am not able to reproduce this, but I can see it is affecting our users via Sentry crash reports

Reproducible sample code

-
zoontek commented 1 month ago

@kf94 Are you using fade: true? Do you have users that report an actual issue or does this only happen when the user kills the app at launch?

kf94 commented 1 month ago

Yes, I'm using fade: true. I haven't received any reports from users, only seeing it in Sentry. The crash doesn't seem to occur consistently or after a specific session length.

zoontek commented 1 month ago

Try switching to useHideAnimation with a simple animation on the opacity and see if something change.

kf94 commented 1 month ago

I appreciate the suggestion, but it will take some time before I can validate its effectiveness. Could you provide more details on why this approach should mitigate the issue?

zoontek commented 1 month ago

@kf94 Because fading relies on a hack on Android, where it creates a new instance of Dialog (as we cannot set window animations after its creation).

kf94 commented 1 month ago

ok, thanks.

zoontek commented 1 month ago

I migrated the Android codebase to Kotlin, and don't perform nullability casts, we should be good now.