Cordova-plugin-ionic-webview: iOS 12.2 fatal crash

Created on 4 Mar 2019  路  14Comments  路  Source: ionic-team/cordova-plugin-ionic-webview

With iOS 12.2 all apps crashes with this plugin

019-03-04 12:30:09.349866+0100 MiApp[447:68531] Apache Cordova native platform version 4.5.5 is starting.
2019-03-04 12:30:09.350620+0100 MiApp[447:68531] Multi-tasking -> Device: YES, App: YES
2019-03-04 12:30:09.383522+0100 MiApp[447:68531] CDVWKWebViewEngine: trying to inject XHR polyfill
2019-03-04 12:30:09.404853+0100 MiApp[447:68531] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key _alwaysRunsAtForegroundPriority.'
*
First throw call stack:
(0x1f98f84c4 0x1f8ad79f8 0x1f9815bd4 0x1fa27ea40 0x1028175c8 0x1028a73d4 0x102a21bf4 0x102a2132c 0x102a217c0 0x102a1f074 0x102803134 0x225f96f30 0x225f97334 0x226574f64 0x22657550c 0x226585dec 0x102a2390c 0x102802e70 0x226537448 0x226538bac 0x22653e338 0x225e02640 0x225e0abe8 0x225e022c4 0x225e02bb4 0x225e00f00 0x225e00bc8 0x225e05708 0x225e064ec 0x225e055c0 0x225e0a2d0 0x22653c940 0x226139544 0x1fc275d94 0x1fc27f7a4 0x1fc27efac 0x1032c8c74 0x1032cc840 0x1fc2b010c 0x1fc2afda8 0x1fc2b0360 0x1f988a148 0x1f988a0c8 0x1f98899b0 0x1f98848e8 0x1f98841cc 0x1fba8679c 0x22653ff90 0x102802d70 0x1f934db70)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

Most helpful comment

Removing this --> [obj setValue:[NSNumber numberWithBool:YES]
forKey:[APPBackgroundMode wkProperty]]; works

All 14 comments

I have picked this up to. Do you have the background plugin installed?

Try the following in the Plugins>AppBackgroundMode.m file ----

(void) swizzleWKWebViewEngine
{
if (![self isRunningWebKit])
return;

Class wkWebViewEngineCls = NSClassFromString(@"CDVWKWebViewEngine");
SEL selector = NSSelectorFromString(@"createConfigurationFromSettings:");

SwizzleSelectorWithBlock_Begin(wkWebViewEngineCls, selector)
^(CDVPlugin *self, NSDictionary *settings) {
    id obj = ((id (*)(id, SEL, NSDictionary*))_imp)(self, _cmd, settings);

    if ([settings objectForKey:@"wksuspendinbackground"]) {
        NSLog(@"exist");
    } else {
        [obj setValue:[NSNumber numberWithBool:YES]
               forKey:[APPBackgroundMode wkProperty]];
    }

    [obj setValue:[NSNumber numberWithBool:NO]
           forKey:@"requiresUserActionForMediaPlayback"];

    return obj;
}
SwizzleSelectorWithBlock_End;

}

i'm going to try

cool I made the change in the platform>ios section

Same error. I uninstalled the background plugin and not working. The error is in this plugin cordova-plugin-ionic-webview

I think keep the background plugin installed and then apply the code. Which folder did you apply the code?

I apply directly to xcode.

Later I tried removing the background plugin and not working too

So the error is on the cordova-plugin-ionic-webview

mmm.. try updating the plugin to version 4.0.0

I'm using 4.0.0

This was fixed in both latest of 4.x and 2.x. If you are still seeing the crash you either aren鈥檛 on the new version, or have another plugin with the same bug because that code is no longer in the largest release.

I'm on version 4 -->
cordova plugin list -->
...
cordova-plugin-ionic-webview 4.0.0 "cordova-plugin-ionic-webview"
.....

Removing plugin cordova-plugin-ionic-webview works fine

Removing this --> [obj setValue:[NSNumber numberWithBool:YES]
forKey:[APPBackgroundMode wkProperty]]; works

yes 100% that line causes the app to crash. That's why I added a condition around it.

if ([settings objectForKey:@"wksuspendinbackground"]) { NSLog(@"exist"); } else { [obj setValue:[NSNumber numberWithBool:YES] forKey:[APPBackgroundMode wkProperty]]; }

Although I'm not sure what else might break by removing that line. Anyway good stuff!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KuschL picture KuschL  路  5Comments

lincolnthree picture lincolnthree  路  7Comments

paulstelzer picture paulstelzer  路  8Comments

pschinis picture pschinis  路  4Comments

slymeng picture slymeng  路  5Comments