Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on Splash Screen iOS 12.3.1 #397

Open
code4cake opened this issue Jun 13, 2019 · 16 comments
Open

Crash on Splash Screen iOS 12.3.1 #397

code4cake opened this issue Jun 13, 2019 · 16 comments

Comments

@code4cake
Copy link

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?

@colaskirschoff
Copy link

colaskirschoff commented Jun 26, 2019

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
Copy link

colaskirschoff commented Jun 26, 2019

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 :)

@SebiVPS
Copy link

SebiVPS commented Jul 2, 2019

I experience the same issue. Any update on this?

@code4cake
Copy link
Author

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.

@mcorner
Copy link

mcorner commented Jul 8, 2019

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

@chevonc
Copy link

chevonc commented Aug 2, 2019

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

@corelmax
Copy link

corelmax commented Aug 4, 2019

Same here, any luck?

image

@ou2s
Copy link

ou2s commented Aug 27, 2019

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 )

@CaptainJeff
Copy link

@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:

@Fausto95
Copy link

Fausto95 commented Oct 9, 2019

Facing the same issue here

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

@vikrantshroti
Copy link

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.

@ou2s
Copy link

ou2s commented Oct 24, 2019

@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].

@dkoprowski
Copy link

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.

@ghasemikasra39
Copy link

Same here, Any solution ?

@celandro
Copy link

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;
}

@wildseansy
Copy link

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];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests