facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.21k stars 24.33k forks source link

React Native 0.68 Onboarding Flash White Screen #33587

Closed lobydev closed 2 years ago

lobydev commented 2 years ago

Description

// Place this code after "[self.window makeKeyAndVisible]" and before "return YES;" UIStoryboard sb = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil]; UIViewController vc = [sb instantiateInitialViewController]; rootView.loadingView = vc.view;

this code is not working

Ekran Resmi 2022-04-07 18 20 30

Version

0.68.0

Output of npx react-native info

System: OS: macOS 12.3 CPU: (10) arm64 Apple M1 Max Memory: 795.16 MB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 17.8.0 - /opt/homebrew/bin/node Yarn: 1.22.17 - /opt/homebrew/bin/yarn npm: 8.5.5 - /opt/homebrew/bin/npm Watchman: 2022.03.14.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: Not Found SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8193401 Xcode: 13.3/13E113 - /usr/bin/xcodebuild Languages: Java: 11.0.14.1 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.68.0 => 0.68.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

the code is not working

// Place this code after "[self.window makeKeyAndVisible]" and before "return YES;" UIStoryboard sb = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil]; UIViewController vc = [sb instantiateInitialViewController]; rootView.loadingView = vc.view;

Snack, code example, screenshot, or link to a repository

No response

lobydev commented 2 years ago

is there no solution?

pragadeeshk commented 2 years ago

@lobydev change type of rootView to RCTRootView instead of UIView. You will need to type case RCTAppSetupDefaultRootView as well.

So changing line number 44 to

RCTRootView *rootView = (RCTRootView *)RCTAppSetupDefaultRootView(bridge, @"Furya", nil);

should solve the problem

AndreaGProg commented 2 years ago

YES

from UIView rootView = RCTAppSetupDefaultRootView(bridge, @"XXXX", nil); to RCTRootView rootView = (RCTRootView *)RCTAppSetupDefaultRootView(bridge, @"XXXX", nil);

work for me!

cortinico commented 2 years ago

Closing as this is resolved

ecexplorer commented 2 years ago

Even with the recommended change by @pragadeeshk I still see the screen flash white briefly between the launchscreen and the initial render. It's better than without the code, but wasn't seeing the white frames before.

andrestone commented 2 years ago

Hey, @ecexplorer. Have you managed to solve this?

andrestone commented 2 years ago

@cortinico It seems like this isn't solved.

The issue here is that the code that implements the mechanism to prevent the flash in RCTRootView's has no equivalent in RCTSurfaceHostingProxyRootView. So the issue persists when Fabric is enabled, even though the workaround proposed by @pragadeeshk fixes the issue if not, since the view instantiated is actually a RCTRootView in that case.

Maybe this should be reopened?

Edit: Currently I'm using this unideal workaround:

  UIStoryboard *sb = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil];
  UIViewController *vc = [sb instantiateInitialViewController];
  [rootView addSubview:vc.view];
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
    [[vc view] removeFromSuperview];
  });
cortinico commented 2 years ago

@cortinico It seems like this isn't solved.

Can I ask you to create a newer issue + provide a reproducer for this specific scenario? We're having a hard time tracking closed issues which receives follow-up comments so they get downprioritized. Please use the "New Architecture" issue as this looks like Fabric related.