question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Statusbar turns white when the webview is loaded on iOS 12

See original GitHub issue

Bug description: PR #544 introduces a bug where the statusbar turns to UIStatusBarStyleLightContent (white text) when mounting a webview with a Youtube-video inside

To Reproduce:

  • Turn the statusbar to default (dark text) using the react-native Statusbar-component
  • Mount a webview with an embedded Youtube-video

Expected behavior: Mounting a webview should not affect the statusbar

Environment:

  • OS: iOS
  • OS version: 12.2
  • react-native version: 0.60.4
  • react-native-webview version: 6.3.1

What I can tell so far:

  • The following line (RNCWKWebView.m, line: 84) registers an event-handler that should only be called when entering/leaving fullscreen-mode:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toggleFullScreenVideoStatusBars) name:@"_MRMediaRemotePlayerSupportedCommandsDidChangeNotification" object:nil];
  • Using NSlog-statements I can see that this event-handler is also called when the webview has finished loading
  • This event-handler assumes the webview has just entered fullscreen and turns the statusbar to UIStatusBarStyleLightContent

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:13
  • Comments:42 (18 by maintainers)

github_iconTop GitHub Comments

28reactions
rmccuecommented, Jan 5, 2020

Hitting this same issue, and had to workaround it with:

componentDidMount() {
	// Workaround for https://github.com/react-native-community/react-native-webview/issues/735#issuecomment-548059083
	Keyboard.addListener( 'keyboardWillShow', this.onKeyboardShow );
	StatusBar.setBarStyle( 'dark-content' );
}

componentWillUnmount() {
	Keyboard.removeListener( 'keyboardWillShow', this.onKeyboardShow );
	StatusBar.setBarStyle( 'dark-content' );
}

onKeyboardShow = () => {
	StatusBar.setBarStyle( 'dark-content' );
}

Would be great if we could get it fixed in react-native-webview.

25reactions
tyleragnewcommented, Feb 3, 2020

I am seeing this issue as well, but when a keyboardUI is triggered. I was able to fix this by making the following changes to my RNCWebView.m file:

-(void)showFullScreenVideoStatusBars
{
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    _isFullScreenVideoOpen = YES;
    RCTUnsafeExecuteOnMainQueueSync(^{
      [RCTSharedApplication() setStatusBarHidden:NO animated:YES];
      [RCTSharedApplication() setStatusBarStyle:RCTSharedApplication().statusBarStyle animated:YES];
    });
#pragma clang diagnostic pop
}

-(void)hideFullScreenVideoStatusBars
{
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    _isFullScreenVideoOpen = NO;
    RCTUnsafeExecuteOnMainQueueSync(^{
      [RCTSharedApplication() setStatusBarHidden:NO animated:YES];
      [RCTSharedApplication() setStatusBarStyle:RCTSharedApplication().statusBarStyle animated:YES];
    });
#pragma clang diagnostic pop
}

I agree with the others, it would be nice to know why the keyboardUi triggers this event in the first place.

Read more comments on GitHub >

github_iconTop Results From Across the Web

status bar disappeared after full screen video in ...
1. This happens with the video player as well when returning from full-screen. · Same issue for me after coming from fullscreen. ·...
Read more >
WkWebView always comes up with white background?
Before loading an html resource into a WkWebView, it is always white regardless of whether in dark or light mode.
Read more >
react native android 12 status bar text turns white
Present a RN view controller via push. Notice how the status bar is still light-content (i.e. white text) because of the StatusBar code...
Read more >
Display content edge-to-edge in your app
Together, the status bar and the navigation bar are called the system bars. Your app achieves an edge-to-edge layout by drawing behind these...
Read more >
cordova-plugin-statusbar
On iOS, when you set StatusBar.overlaysWebView to false, you can set the background color of the statusbar by color name. StatusBar.backgroundColorByName("red");.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found