cordova-plugin-ionic-webview: App stops rendering after being in the background on iOS 12.2 Beta

On iOS 12.2 Beta, after our app has been in the background for a minute or 2, we see the following errors in the log.

default	15:33:39.797710 -0800	TIC TCP Conn Destroyed [3:0x2831b5980]
error	15:33:39.797762 -0800	TIC Read Status [3:0x0]: 1:57
error	15:33:39.797813 -0800	TIC Read Status [3:0x0]: 1:57
error	15:33:39.797867 -0800	nw_protocol_boringssl_get_output_frames(1301) <private>[0x102033770] get output frames failed, state 8196
error	15:33:39.797922 -0800	nw_protocol_boringssl_get_output_frames(1301) <private>[0x102033770] get output frames failed, state 8196
error	15:33:39.798184 -0800	TIC Read Status [2:0x0]: 1:57
error	15:33:39.798236 -0800 TIC Read Status [2:0x0]: 1:57
***** error	15:33:40.247471 -0800	Background task expired while holding WebKit ProcessAssertion (isMainThread? 1). *****

When the app is brought back to the foreground, the screen will either go white or just stop rendering and will not respond to taps. Note though that the javascript thread continues to run as we still see console.log statements.

We have tried the plugin versions 2.3.2 and 3.1.1 and the problem still occurs with both versions on iOS 12.2 Beta.

Our app does run in the background (geolocation) and we have <preference name="WKSuspendInBackground" value="false" /> in config.xml. If we remove the “WKSuspendInBackground” property from config.xml the issue goes away BUT our background processing (geolocation) does too which is kind of a non-starter for us.

We have tested our code on iOS 11.4 and 12.1 as well. We never see the issue on iOS 11.4. We periodically see the issue on iOS 12.1.

We’ve seen similar issues (Ticket #251) reported and some have suggested upgrading to 3.1.1 fixed the issue for them on iOS 12.1 but it still happens for us (periodically, as stated above).

cli packages: (/Users/sxsmith/.nvm/versions/node/v8.2.0/lib/node_modules)
    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:
    cordova (Cordova CLI) : 8.0.0

local packages:
    @ionic/app-scripts : 3.2.0
    Cordova Platforms  : android 7.0.0 ios 4.5.5
    Ionic Framework    : ionic-angular 3.9.2

System:
    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2
    Node              : v8.2.0
    npm               : 6.4.1
    OS                : macOS
    Xcode             : Xcode 10.1 Build version 10B61

Environment Variables:
    ANDROID_HOME : /Users/sxsmith/Library/Android/sdk

Misc:
    backend : pro
branch-cordova-sdk 3.0.0 "branch-cordova-sdk"
com.adjust.sdk 4.14.0 "Adjust"
com.batch.cordova 2.0.2 "Batch"
cordova-clipboard 1.2.1 "Clipboard"
cordova-custom-config 5.0.2 "cordova-custom-config"
cordova-plugin-add-swift-support 1.7.2 "AddSwiftSupport"
cordova-plugin-advanced-http 1.11.1 "Advanced HTTP plugin"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-appavailability 0.4.2 "AppAvailability"
cordova-plugin-contacts 3.0.1 "Contacts"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-enable-multidex 0.1.3 "Enable Multidex"
cordova-plugin-facebook4 2.1.0 "Facebook Connect"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-file-transfer 1.7.2-dev "File Transfer"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-googleplus 6.0.0 "Google SignIn"
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.1.2 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.3.2 "cordova-plugin-ionic-webview"
cordova-plugin-jumbomode 1.0 "Cordova Jumbo Mode"
cordova-plugin-mixpanel 4.3.0 "Mixpanel"
cordova-plugin-native-services 0.0.1 "NativeServices"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-stripe 1.5.3 "cordova-plugin-stripe"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.4.1 "SocialSharing"
cordova-universal-links-plugin 1.2.1 "Universal Links Plugin"
es6-promise-plugin 4.2.2 "Promise"
onymos-plugin-media 1.0.8.3 "OnymosMediaComponent"

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 49 (15 by maintainers)

Commits related to this issue

Most upvoted comments

This is the stackcrawl article that got us headed in the right direction: https://stackoverflow.com/questions/54474910/ionic-app-crashes-on-ios-12-2-because-of-alwaysrunsatforegroundpriority

I’m the creator of the above mentioned post, and as it says, on my end my app does just terminate on startup due to this. XCode gives me this message:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<WKWebViewConfiguration 0x105916dc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key _alwaysRunsAtForegroundPriority.'

I have found out that removing the cordova-plugin-background-mode plugin makes the problem go away, but that’s no solution for me in the long run, as i need the functionality this plugin provides.

I also tried removing the line mentioned above, in CDVWKWebViewEngine.m (Which is on line 185 at my end), and XCode still gives me the same message. That makes no sense to me, and may not even be part of the problem. Anyway, I’d love to be pointed in the right direction on this one, as i can’t have all my customers that use iPhones have their apps crash once iOS 12.2 comes out publicly.

We released several fixes for this last week. Upgrade to 4.0 if you’re able to drop the webserver (and iOS 10), or use the latest 2.x if you need to support iOS 10 still. Both have a fix for this issue.

@mlynch My problem is as follows: If Apple doesn’t fix it and the “yes in theory” turns out to be a “no”, my app stops working come iOS 12.2.

So I’m sitting here needing to decide if I should completely abandon Ionic/Cordova and rewrite my entire application in Swift before 12.2 drops, or migrate to Ionic4/Capacitor and hope for the best.