react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

White flash on screen push.

Open maurovisintin opened this issue 10 years ago • 101 comments

Issue Description

In IOS when i push a new screen i see a white background on the rootview before the first react native render, since i have a dark styled app it's quite annoying.

Changing the color on rootview in AppDelegate.m to black, or setting a screenBackgroundColor doesn't seem to to anything

Steps to Reproduce / Code Snippets / Screenshots

This is the snippet from AppDeletage.m self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.backgroundColor = [UIColor blackColor];

This is the snipper from the screenComponent

class EventScreen extends Component { static navigatorStyle = { screenBackgroundColor: SituaColors.darkBg }; ....

Thanks

Environment

  • React Native Navigation version: 2.0.0-experimental.105
  • React Native version: 0.34.0
  • Platform: IOS
  • Device info: Both simulator and device, both debug and release

maurovisintin avatar Oct 05 '16 18:10 maurovisintin

Would be great to get some options for this. I also have a dark themed app and the white flashes between scenes are frustrating.

alexcurtis avatar Oct 11 '16 13:10 alexcurtis

same issue here

ryanscottaudio avatar Oct 13 '16 20:10 ryanscottaudio

I add this as temp solution for my project under setStyleOnAppearForViewController in RCCViewController

NSString *screenColor = self.navigatorStyle[@"screenColor"];
if (screenColor)
{
  UIColor *color = screenColor != (id)[NSNull null] ? [RCTConvert UIColor:screenColor] : nil;
  viewController.view.backgroundColor = color;
}

Maybe we create smth more nice, like screenStyles prop?

savelichalex avatar Oct 15 '16 19:10 savelichalex

@savelichalex thanks! works like a charm!

maurovisintin avatar Oct 16 '16 08:10 maurovisintin

Thanks @savelichalex it works well but does somebody a way to avoid this flashes ? maybe with preloading or idk ?

DavoCg avatar Oct 16 '16 22:10 DavoCg

Maybe @guyca help with it, but I don't think so. As I understand how it works, when push happened VC create new native view(1), then they send event to js that render react view, and then rendered new react view added to native view(2). Between this two phases we see default native view with default background color.

savelichalex avatar Oct 17 '16 07:10 savelichalex

Hey guys this issue will be addressed soon, I hope by the end of November. Sorry for the inconvenience.

@savelichalex you're correct, that's exactly what happens. On Android we avoid this issue by showing the pushed screen only after render is done and the native view is populated.

guyca avatar Oct 17 '16 11:10 guyca

Hello, do you have an idea when pre-rendering will be available on iOS so we don't see anymore this white screen when pushing view or showing modal? Or maybe you can point us what should be changed so we can try to work on it? Thanks!

pascalmermeold avatar Nov 18 '16 09:11 pascalmermeold

This is a big problem when switching tabs for the first time. Thinking about migrating to a javascript-based tab navigator.

brunolemos avatar Nov 21 '16 05:11 brunolemos

@brunolemos yeah, I've been using NavigationExperimental for now

ryanscottaudio avatar Nov 21 '16 05:11 ryanscottaudio

@brunolemos @ryanscottaudio @pascalmerme see #437

DanielZlotin avatar Nov 21 '16 09:11 DanielZlotin

I am experiencing the same issue when using switchToTab. Tab's screen content flashes when it is switched for the first time. It is even worse for me because I am using a custom (JS) tabbar and it flashes too.

grundmanise avatar Feb 24 '17 23:02 grundmanise

@shahen94 This doesn't fix the flash issue for me on iOS. Even if I add a 1 second delay it still seems that the view controller is not being rendered until the navigation transition actually starts. I still see a brief flash of white (background color) as the transition happens.

jbolter avatar Apr 20 '17 22:04 jbolter

@jbolter it fixed my issue. seems like your JS thread is doing much work, Try to use InteractionManager

shahen94 avatar Apr 21 '17 09:04 shahen94

I don't think adding a delay before making the controller visible is recommended. On Android we solved this issue easily be display the screen only after the react root view has been populated. Meaning, once the react root view has at least one child - we conclude it's rendered and show it. Perhaps the same logic can be implemented on iOS as well.

guyca avatar Apr 21 '17 11:04 guyca

@shahen94 I'm doing very little work on the JS thread so I don't think that is the issue. I can reproduce this in a very simple project if that helps debug.

@guyca Your proposed solution that works on Android sounds like a better solution than a delay. Do you have any tips on where I can look to start investigating this solution? I'm familiar with iOS development.

jbolter avatar Apr 25 '17 19:04 jbolter

Unfortunately I'm not familiar with the iOS codebase. Based on the solution suggested here, I can only suggest you start looking at RCCViewController and make your way from there.

guyca avatar Apr 25 '17 20:04 guyca

Guy I can find some time tomorrow to do that on iOS - point me to what you meant in Android, I don't remember us doing anything like that..

On Apr 25, 2017 11:17 PM, "Guy Carmeli" [email protected] wrote:

Unfortunately I'm not familiar with the iOS codebase. Based on the solution suggested here, I can only suggest you start looking at RCCViewController and make your way from there.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/wix/react-native-navigation/issues/358#issuecomment-297151959, or mute the thread https://github.com/notifications/unsubscribe-auth/AGWgj1T5oNK3YKO4hb3G71fdv0EyQ1iPks5rzlTAgaJpZM4KPG3x .

DanielZlotin avatar Apr 25 '17 21:04 DanielZlotin

Hey @DanielZlotin, In ContentView, Once the first child is added to the ReactRootView, we call the onDisplayListener in runOnPreDraw

guyca avatar Apr 26 '17 06:04 guyca

@DanielZlotin Just a reminder that I would love for you to take a look at this "flashing" issue when yu have time!

jbolter avatar May 09 '17 22:05 jbolter