Closed kylecesmat closed 2 years ago
Hi @kylecesmat 👋 Do you have any metric about these users (mainly to know if they use Android >= 12)?
As you can see here, init
is a simple static method calling installSplashScreen
. The only check performed is that the activity
is not null
(which will be just above in your logs if it happens), so I guess that's not it.
I'm thinking it could be a race condition: MainActivityDelegate.loadApp
might be called too late. Moving it to onCreate
will call it sooner (when MainActivity
is created).
The splashscreen-sample calls installSplashScreen
after super
call, which result in a crash (You need to use a Theme.AppCompat theme (or descendant) with this activity). The official guide put it before the super
call, so you can try init it like this (tried it, it works)
PS: I would be really glad if you can provides feedbacks about this change, as it's not a big deal for the library (a small README change) 😄
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ RNBootSplash.init(this);
+ super.onCreate(null);
+ }
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected Bundle getLaunchOptions() {
Bundle initialProperties = new Bundle();
initialProperties.putBoolean("appWasRestored", hasSavedInstanceState);
return initialProperties;
}
@Override
protected ReactRootView createRootView() {
ReactRootView reactRootView = new ReactRootView(getContext());
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
return reactRootView;
}
- @Override
- protected void loadApp(String appKey) {
- RNBootSplash.init(getPlainActivity());
- super.loadApp(appKey);
- }
};
}
Thank you so much for the helpful suggestions! Let me work on integrating & testing this change - And will absolutely let you know the results.
The crashes seem to all be from Android 12, with ~10% of the logs from Android 10.
@kylecesmat On Android 12, the native SplashScreen API starts on the Android system thread (as opposed as the compat implem for the versions before), so it seems normal: it's even quicker to boot. That fits with the previous theory 🙂
hey @zoontek the fix you suggested works great! We no longer see this crash in runtime logs.
That said, there is still a crash we are seeing that I believe is a Google issue. It's the second crash I posted above, but I outlined it a bit more in this crash report here: https://issuetracker.google.com/issues/242118185
Seems others have hit this issue as well: https://issuetracker.google.com/issues/233588959
Anyway, feel free to close this issue as the configuration issue is now fixed :) Thank you!
@kylecesmat Indeed, this seems not tied to the library itself. I'm closing this.
Since I saw you work at Coinbase, a gentle reminder to consider sponsoring. I think you are also using react-native-localize
and react-native-permissions
, which I also maintain 🙂!
@zoontek I'm doing my best internally to push for an OSS fund to support projects like this. Will absolutely keep you informed if we make progress - I understand that's not the best response 😓
Thank you again for your time & OSS contributions!
Bug summary
Hello, we are seeing <1% of our Android users experiencing this crash. I've read through the various threads & have validated configuration as recommended by the README & in the splashscreen-sample.
I am unable to create a reproduction, but have a theory that the
RNBootsplash.init
call may be exiting early, before thepostSplashScreenTheme
API can be called. Again, we cannot reproduce locally or see any platform/API version trends in our runtime error trace.As a possible solution, I wonder if there is a way to force
postSplashScreenTheme
to be called, in the event that theRNBootSplash.init
fails for some reason or exits early, so that the rest of the application can properly fall back toTheme.AppCompat.Light.NoActionBar
in the top-level root theme?Observing the following error in a small percentage of our logs:
Interestingly we also see this error as well:
And here are the relevant lines in our configuration:
Library version
4.2.4
Environment info
Steps to reproduce
Only clear way to reproduce is to comment-out
RNBootSplash.init(getPlainActivity());
. I believe this simulates the failure case our users see where the module does not resolve correctly andpostSplashScreenTheme
is never reached, meaning the AppCompat theme is never set.Reproducible sample code