My app stops white blank screen when app back to foreground from background
See original GitHub issueBug 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.
- Start app with XCode Simulator(ex: iPhone12 mini).
- By using Simulator, get app switch to background.
- Kill 2 processes(com.apple.Webkit.networking, com.apple.Webkit.WebContent) of app by using Activity Monitor. Clicking “Forced termination“.
- Back the app to foreground.
- 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:
- Created a year ago
- Comments:15
Top GitHub Comments
Here’s additional changes below.
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.
@bratelefant see my comment in https://github.com/meteor/meteor/issues/11811#issuecomment-1113957240, maybe this fixes it?