react-native-splash-screen icon indicating copy to clipboard operation
react-native-splash-screen copied to clipboard

Crash on Splash Screen iOS 12.3.1

Open code4cake opened this issue 6 years ago • 16 comments

Run react-native info in your project and share the content.

Environment:
  OS: macOS 10.14.5
  Node: 10.15.3
  Yarn: 1.16.0
  npm: 6.4.1
  Watchman: 4.9.0
  Xcode: Xcode 10.2.1 Build version 10E1001
  Android Studio: 3.4 AI-183.5429.30.34.5452501

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: ^0.55.4 => 0.55.4

What react-native-splash-screen version are you using?

"react-native-splash-screen": "^3.0.9",

What platform does your issue occur on? (Android/iOS/Both)

iOS

Describe your issue as precisely as possible :

  1. Steps to reproduce the issue or to explain in which case you get the issue

The issue usually happens when I submit the app for release to TestFlight. At the moment it's being rejected, cause they only receive a blank screen. I'm unable to reproduce the bug locally.

  1. Interesting logs

Join a screenshot or video of the problem on the simulator or device?

apple-rejection-blank-splash-screen-bug

Show us the code you are using?

code4cake avatar Jun 13 '19 12:06 code4cake

I'm having the same bug. Everything works fine in debug / release mode on simulator / real device but it fails when the builds comes from Testflight.

What you could do is look at your device crash logs (CMD + SHIFT + 2 in Xcode with your device plugged in). From my logs it seems that l31 of the RNSplashScreen.m is responsible for the crash:

image

This very same line was already discussed because of BAD ACCESS issue a year ago: https://www.bountysource.com/issues/49406480-splashscreen-show-crashes-with-exc_bad_access

image

Apparently the app gets killed by the OS because it takes too much time to load. Maybe the loop does not stop early enough (in my case I call RNSplashScreen.hide() very late in my react-native code). Check this SO issue for more info: https://stackoverflow.com/questions/50186258/app-crash-exception-type-exc-crash-sigkill-termination-reason-namespace-spri.

I'll try to dig a bit !

colaskirschoff avatar Jun 26 '19 22:06 colaskirschoff

I just read this thread that talks about a related issue: https://forums.developer.apple.com/thread/88529. In their case it was the OS that was not handling correctly the end of a background task, but still it helps understand a bit more what's happening for us :)

colaskirschoff avatar Jun 26 '19 22:06 colaskirschoff

I experience the same issue. Any update on this?

SebiVPS avatar Jul 02 '19 15:07 SebiVPS

I was the one that had posted the issue. I have not dig more into it, cause it sort of disapear on my end and I could not tested anymore.

code4cake avatar Jul 02 '19 15:07 code4cake

I can confirm this bug and it seems to only happen on testflight builds for us. It is a showstopper unfortunately.

mcorner avatar Jul 08 '19 17:07 mcorner

Any luck here from anyone? Started to hit this as well

chevonc avatar Aug 02 '19 17:08 chevonc

Same here, any luck?

image

corelmax avatar Aug 04 '19 18:08 corelmax

FYI, I will try to use [RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView]; instead of [RNSplashScreen show]. You just have to create a View (.xib) via Xcode.

It seems like it's fixing the problem since it won't go into the Run Loop that was causing the crash.

EDIT: I confirm that you can workaround this issue by using the showSplash:inRootView: method instead of show (cc @corelmax @chevonc @mcorner @sebiVPS @colaskirschoff )

ou2s avatar Aug 27 '19 16:08 ou2s

@ou2s

Just to confirm. You are saying you fixed the issue by using

[RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView];

Instead of

[RNSplashScreen show]

Or did you use something else IE showSplash:inRootView:

CaptainJeff avatar Oct 04 '19 16:10 CaptainJeff

Facing the same issue here

EDIT: I just figured out that the issue wasn't related to react-native-splash-screen directly.

Fausto95 avatar Oct 09 '19 13:10 Fausto95

I can confirm using

@ou2s

Just to confirm. You are saying you fixed the issue by using

[RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView];

Instead of

[RNSplashScreen show]

Or did you use something else IE showSplash:inRootView:

I can confirm using : [RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView]; instead of [RNSplashScreen show]

fixed crash for me.

vikrantshroti avatar Oct 16 '19 10:10 vikrantshroti

@ou2s

Just to confirm. You are saying you fixed the issue by using

[RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView];

Instead of

[RNSplashScreen show]

Or did you use something else IE showSplash:inRootView:

Yes I confirm.

FYI, showSplash:inRootView: is not something else. It's the method name in Objective-C used in this code: [RNSplashScreen showSplash:@"LaunchScreen" inRootView: rootView]. Another example is: show is the method name in [RNSplashScreen show].

ou2s avatar Oct 24 '19 11:10 ou2s

Looks like [RNSplashScreen show] has some strange while (waiting) => while (true) in its code. The other method [RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView]; has a bit different code. I think it fixes issue for me as well.

dkoprowski avatar Feb 17 '20 13:02 dkoprowski

Same here, Any solution ?

ghasemikasra39 avatar Jun 03 '20 08:06 ghasemikasra39

I was having the same issues with expo-updates and the trick of changing to inRootView worked.

Note that expo already creates a root view for you, so you just need to add RNSplashScreen in to it. So instead of before the return YES you need to add it at the end of initializeReactNativeApp

  return YES;
}

- (RCTBridge *)initializeReactNativeApp
{
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  [RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView];

  return bridge;
}

celandro avatar Jun 14 '20 20:06 celandro

The reason this was happening for me was all due to ordering

Won't work:

Here the [RNSplashScreen show] blocks the bridge from ever starting, and thus prevents "hide" from being called on the JS side which unlocks the thread

  [RNSplashScreen show];
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"MyApp"
                                            initialProperties:nil];

Worked for me:

Now that the JS can run, "hide" is shortly called which dismisses the splash screen

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"MyApp"
                                            initialProperties:nil];
  [RNSplashScreen show];

wildseansy avatar Feb 21 '22 22:02 wildseansy