Cordova-plugin-googlemaps: addPolyline of release 1.4.5 crashes with iOS 11

Created on 24 Sep 2017  路  9Comments  路  Source: mapsplugin/cordova-plugin-googlemaps

I'm submitting a ...
[ ] question
[x] any problem or bug report
[ ] feature request

The plugin version:
[x] 1.4.5
[ ] 2.0-beta3 (github)
[ ] 2.0 (npm)

If you choose 'problem or bug report', please select OS: (check one with "x")
[ ] Android
[*] iOS

cordova information: (run $> cordova plugin list)

com.googlemaps.ios 2.4.0 "Google Maps SDK for iOS"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-googlemaps 1.4.5 "cordova-googlemaps-plugin"
cordova-plugin-whitelist 1.3.2 "Whitelist"

Current behavior:

The iOS 11 application crashes when addPolyline(...) is called, it also crashes with following snippet.

The crash report is following

2017-09-24 15:45:50.273741+0300 MyApp[62221:953743] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Polyline initWithWebViewEngine:]: unrecognized selector sent to instance 0x600000135f40'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010defc1cb __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010d830f41 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010df7c914 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x000000010de7f178 ___forwarding___ + 1432
    4   CoreFoundation                      0x000000010de7eb58 _CF_forwarding_prep_0 + 120
    5   MyApp                          0x00000001091128cc -[CDVViewController getCommandInstance:] + 348
    6   MyApp                          0x00000001090cd607 __19-[GoogleMaps exec:]_block_invoke + 1111
    7   libdispatch.dylib                   0x00000001107513f7 _dispatch_call_block_and_release + 12
    8   libdispatch.dylib                   0x000000011075243c _dispatch_client_callout + 8
    9   libdispatch.dylib                   0x0000000110757352 _dispatch_queue_override_invoke + 1458
    10  libdispatch.dylib                   0x000000011075e1f9 _dispatch_root_queue_drain + 772
    11  libdispatch.dylib                   0x000000011075de97 _dispatch_worker_thread3 + 132
    12  libsystem_pthread.dylib             0x0000000110c155a2 _pthread_wqthread + 1299
    13  libsystem_pthread.dylib             0x0000000110c1507d start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Expected behavior:

Same application works perfectly with iOS 10

Most helpful comment

Right... No needs to patch CordovaLib/Public/CDVViewController.m. You can rename a feature at the plugin. I am going to test the following patch at HW. It works at emulator.

v1.4.5-iOS11.patch.zip

My branch is available here.
https://github.com/fogfish/cordova-plugin-googlemaps/tree/v1.4.5-iOS11

All 9 comments

Just adding that I'm also seeing this issue now - only on iOS 11.

The issue is also repeatable with demo application

git clone https://github.com/mapsplugin/v2.0-demo
cd v2.0-demo
cordova prepare
cd platforms/ios/cordova && npm install ios-sim && cd -

cordova plugin add [email protected] --variable API_KEY_FOR_IOS="..."

cordova emulate ios --target="iPhone-6"

then go to Polyline > map.addPolyline()

No more support v1.4.5

Polyline gets instanced by name, and there's something else called Polyline in iOS 11 which is getting instanced by Cordova instead, so I got it to work by changing the name of the plugin's Polyline class. We're in a bind because 2.0 doesn't support KML yet, but this gets it to work for now.

if you renamed the Polyline in Polyline.m and Polyline.h in the plugin to PolylineNewclass,

Plugins/Polyline.h line 12:

@interface PolylineNewclass : CDVPlugin <MyPluginProtocol>

Plugins/Polyline.m line 11:

@implementation PolylineNewclass

Looking at line 550 of CordovaLib/Public/CDVViewController.m you would add this code to have it instantiate Polyline to your new class name.

    if (!obj) {
        if([className isEqualToString:@"Polyline"]) { // added
            obj = [[NSClassFromString(@"PolylineNewclass")alloc] initWithWebViewEngine:_webViewEngine]; //added
            } //added
        else { //added
            obj = [[NSClassFromString(className)alloc] initWithWebViewEngine:_webViewEngine];
            } //added

This is from 1.3.9 and I'm assuming that the line numbers are similar in 1.4.5

Very helpful plugin even if you're unable to fully support kml, so thx to the authors for all your hard work.

@gitoplasm This solves an issue... I am still having an issue to integrate plugin 2.0 into app (due to animation) but this small patch helped a lot. Now, I am curious is it possible to rename a Polyline to something else so that we can avoid patching of CordovaLib.

Right... No needs to patch CordovaLib/Public/CDVViewController.m. You can rename a feature at the plugin. I am going to test the following patch at HW. It works at emulator.

v1.4.5-iOS11.patch.zip

My branch is available here.
https://github.com/fogfish/cordova-plugin-googlemaps/tree/v1.4.5-iOS11

@wf9a5m75 I'd be glad to contribute back iOS11 fix to 1.4.5 if you make a branch for this version.

Sorry, but I have no plan to support v1.4.5 anymore.

@fogfish Thank you your solution solved my problem and now its working fine without crashing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rosnaib11 picture rosnaib11  路  5Comments

nakulkundaliya picture nakulkundaliya  路  5Comments

christoph-puppe picture christoph-puppe  路  5Comments

lakano picture lakano  路  4Comments

bigbossmaher picture bigbossmaher  路  3Comments