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.

My app stops white blank screen when app back to foreground from background

See original GitHub issue

Bug Report

Many of my app users has been reporting the issue that my app stops as white screen when it back to foreground from background.

Problem

What is expected to happen?

When back to foreground, app should display its webview contents properly.

What does actually happen?

When back to foreground, app displays white blank screen and no way to control by user(it looks freezing).

Information

I have been researching the issue a couple of months because I haven’t reproduced. Finally I could reproduce the issue by killing 2 webview processes with Acitivity Monitor of MacOS.

Here’s the procedure.

  1. Start app with XCode Simulator(ex: iPhone12 mini).
  2. By using Simulator, get app switch to background.
  3. Kill 2 processes(com.apple.Webkit.networking, com.apple.Webkit.WebContent) of app by using Activity Monitor. Clicking “Forced termination“.
  4. Back the app to foreground.
  5. The app shows white screen and no way to control.

When the app is back to foreground, app shows white screen but the killed 2 processes are reloaded in Activity Monitor view. But those 2 processes seem never communicate with app main process properly.

I guess, cordova-ios detects that webview processes are terminated and do webview.reload() but after that the reloaded processes are not communicating with app main process. Then my Javascript code is not loaded, not working, not rendering anything, so I can do nothing.

Here’s the log of Xcode.

2022-04-19 21:56:05.574242+0900 Miley PTA[1372:4054372] app entered background
2022-04-19 21:56:05.574344+0900 Miley PTA[1372:4054372] Set state background
2022-04-19 21:56:05.574434+0900 Miley PTA[1372:4054372] Disconnected from FCM
2022-04-19 21:56:05.590935+0900 Miley PTA[1372:4054372] [Snapshotting] Snapshotting a view (0x7fd97b078a00, UIKeyboardImpl) that has not been rendered at least once requires afterScreenUpdates:YES.
2022-04-19 21:56:05.893567+0900 Miley PTA[1372:4054372] pause!
2022-04-19 21:58:28.746089+0900 Miley PTA[1372:4054372] [Process] 0x111aca330 - NetworkProcessProxy::didClose (Network Process 0 crash)
2022-04-19 21:58:28.746328+0900 Miley PTA[1372:4054372] [Process] 0x111af1600 - [PID=1511] WebProcessProxy::didClose: (web process 0 crash)
2022-04-19 21:58:28.746420+0900 Miley PTA[1372:4054372] [Process] 0x111af1600 - [PID=1511] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=4
2022-04-19 21:58:28.747083+0900 Miley PTA[1372:4054372] [ProcessSuspension] 0x111abd420 - ProcessAssertion: Failed to acquire RBS Background assertion 'ConnectionTerminationWatchdog' for process because PID is invalid
2022-04-19 21:58:28.747464+0900 Miley PTA[1372:4063884] [ProcessSuspension] 0x111abd420 - ProcessAssertion: Failed to acquire RBS assertion 'ConnectionTerminationWatchdog' for process with PID=0, error: (null)
2022-04-19 21:58:28.747907+0900 Miley PTA[1372:4054372] [Process] 0x7fd97b033420 - [pageProxyID=11, webPageID=12, PID=1511] WebPageProxy::processDidTerminate: (pid 1511), reason 4
2022-04-19 21:58:28.750921+0900 Miley PTA[1372:4054372] [Loading] 0x7fd97b033420 - [pageProxyID=11, webPageID=12, PID=1511] WebPageProxy::dispatchProcessDidTerminate: reason=4
2022-04-19 21:58:28.763300+0900 Miley PTA[1372:4054372] CDVWebViewEngine shouldReloadWebView::
2022-04-19 21:58:28.763576+0900 Miley PTA[1372:4054372] CDVWebViewEngine shouldReloadWebView title:
2022-04-19 21:58:28.763874+0900 Miley PTA[1372:4054372] CDVWebViewEngine shouldReloadWebView location: app://localhost/index.html#/AppView
2022-04-19 21:58:28.764176+0900 Miley PTA[1372:4054372] CDVWebViewEngine shouldReloadWebView reload: 0
2022-04-19 21:58:29.053010+0900 Miley PTA[1372:4054372] app become active
2022-04-19 21:58:29.053151+0900 Miley PTA[1372:4054372] Set state foreground
2022-04-19 21:58:29.145401+0900 Miley PTA[1372:4054372] IAB.close() called but it was already closed.
2022-04-19 21:58:29.584398+0900 Miley PTA[1372:4054372] Cordova view ready
2022-04-19 21:58:29.589231+0900 Miley PTA[1372:4054372] BuildInfo init: 0.0000 sec(40616 nsec): Cache data return
2022-04-19 21:58:29.590158+0900 Miley PTA[1372:4054372] start Js Event Bridge
2022-04-19 21:58:29.603274+0900 Miley PTA[1372:4054372] FCM: has been created
2022-04-19 21:58:29.603535+0900 Miley PTA[1372:4054372] FCM: Ready!
2022-04-19 21:58:30.373260+0900 Miley PTA[1372:4065189] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics
2022-04-19 21:58:58.749429+0900 Miley PTA[1372:4054372] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
2022-04-19 22:27:59.054707+0900 Miley PTA[1372:4077801] [default] LaunchServices: disconnect event interruption received for service com.apple.lsd.mapdb
2022-04-19 22:28:54.071186+0900 Miley PTA[1372:4080043] [XPC] Handle connection with error: Connection interrupted

Environment, Platform, Device

Various of iPhone hardware and iOS versions has been reported from my app users.

Version information

  • Installed platforms:  android 10.1.1,  ios 6.2.0
  • cordova-plugin-android-dark-mode-support 1.0.0 “AndroidDarkModeSupport”
  • cordova-plugin-androidx-adapter 1.1.3 “cordova-plugin-androidx-adapter”
  • cordova-plugin-badge 0.8.8 “Badge”
  • cordova-plugin-buildinfo 4.0.0 “BuildInfo”
  • cordova-plugin-calendar 5.1.6 “Calendar”
  • cordova-plugin-customurlscheme 5.0.0 “Custom URL scheme”
  • cordova-plugin-fcm-with-dependecy-updated 7.8.0 “Cordova FCM Push Plugin”
  • cordova-plugin-file 6.0.2 “File”
  • cordova-plugin-inappbrowser 5.0.0 “InAppBrowser”
  • cordova-plugin-splashscreen 6.0.0 “Splashscreen”
  • cordova-plugin-statusbar 3.0.0 “StatusBar”
  • cordova-plugin-webviewcolor 2.2.0 “WebView background color plugin”
  • cordova-plugin-wkwebview-file-xhr 3.0.0 “Cordova WKWebView File XHR Plugin”
  • Vue 2.6.14
  • Firebase 9.6.1
  • MacOS 12.3.1
  • Xcode 13.3

Checklist

[x] I searched for existing GitHub issues [x] I updated all Cordova tooling to most recent version [x] I included all the necessary information above

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15

github_iconTop GitHub Comments

3reactions
gouterucommented, Apr 29, 2022

Here’s additional changes below.

- (BOOL)shouldReloadWebView:(NSURL*)location title:(NSString*)title
{
    BOOL title_is_nil = (title == nil);
    BOOL title_is_empty = ([title length] == 0); // added!
    BOOL title_is_bad = (title_is_nil || title_is_empty);  // added!
    BOOL location_is_blank = [[location absoluteString] isEqualToString:@"about:blank"];

    // BOOL reload = (title_is_nil || location_is_blank);
    BOOL reload = (title_is_bad || location_is_blank);  // added!

#ifdef DEBUG
    NSLog(@"%@", @"CDVWebViewEngine shouldReloadWebView::");
    NSLog(@"CDVWebViewEngine shouldReloadWebView title: %@", title);
    NSLog(@"CDVWebViewEngine shouldReloadWebView title length: %u", [title length]); //  // added!
    NSLog(@"CDVWebViewEngine shouldReloadWebView title is nil: %u", title_is_nil);
    NSLog(@"CDVWebViewEngine shouldReloadWebView location: %@", [location absoluteString]);
    NSLog(@"CDVWebViewEngine shouldReloadWebView location is blank: %u", location_is_blank);
    NSLog(@"CDVWebViewEngine shouldReloadWebView reload: %u", reload);
#endif

    return reload;
}
- (void) onAppWillEnterForeground:(NSNotification*)notification {
    if ([self shouldReloadWebView]) {
        NSLog(@"%@", @"CDVWebViewEngine reloading!");
        NSString *sURL = @"app://localhost/index.html";
        NSURL *url = [NSURL URLWithString:sURL];
        NSLog(@"onAppWillEnterForeground  url: %@", [url absoluteString]);
        [(WKWebView*)_engineWebView loadRequest:[NSURLRequest requestWithURL:url]];
        // [(WKWebView*)_engineWebView reload];
    }
}

I think shouldReloadWebView’s title check is insufficient. In my app’s case when WebContent process is terminated, title is not nil but empty string. So, empty string check should be added. With the changes above, my app works fine when WebContent process is terminated while app is in background. When app back in foreground, shouldReloadWebView detects properly and then load index.html.

With this change, when WebContent process is terminated while my app is in background, and then back in foreground, 2 functions “onAppWillEnterForeground” and “webViewWebContentProcessDidTerminate” do loadRequest. As long as my test, 2 times of loadRequest is not making any issue.

1reaction
JH7commented, Apr 30, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To fix white screen on app Start up? - Stack Overflow
File>Settings>Build,Execution, Deployment>Instant Run unCheck all options shown there. Note: White screen Issue due to Instant Run is only for Debug builds,this ...
Read more >
Remove the background of a photo with Paint 3D
The Paint 3D app in Windows helps you remove the background of an image. You can then save the edited image as a...
Read more >
All I see is a black screen—what do I do? - Gather Help
Click the hamburger menu in the top left corner. Click Background & Foreground, then Upload a Background. If you used the Walls and...
Read more >
Blank or unrecognizable window when opening the Autodesk ...
When starting up the Autodesk Desktop App, all that shows is a blank white screen, and the app never loads.
Read more >
I Have a White or Blank Screen on My Garmin Watch
If the watch goes back to the watch face this means you are viewing the shortcut screen and it is set to the...
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