E3F6 Possible issue with map hit testing · Issue #2786 · mapsplugin/cordova-plugin-googlemaps · GitHub
[go: up one dir, main page]

Skip to content

Possible issue with map hit testing #2786

@yiannis-spyridakis

Description

@yiannis-spyridakis

I'm submitting a ... (check one with "x")

  • question
  • any problem or bug report

OS: (check one with "x")

  • Android
  • iOS
  • Browser

cordova information: (run $> cordova plugin list)

cordova-admob-sdk 0.24.1 "AdMob SDK"
cordova-admob-sdklibs 2.1.6 "Google Mobile Ads SDK for Cordova"
cordova-plugin-actionsheet 2.3.3 "ActionSheet"
cordova-plugin-admob-free 0.27.0 "Cordova AdMob Plugin"
cordova-plugin-advanced-http 2.4.1 "Advanced HTTP plugin"
cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter"
cordova-plugin-appavailability 0.4.2 "AppAvailability"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-email-composer 0.9.2 "EmailComposer"
cordova-plugin-enable-multidex 0.2.0 "Enable Multidex"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-geolocation 4.0.2 "Geolocation"
cordova-plugin-googlemaps 2.7.1 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.3 "cordova-plugin-ionic-webview"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-screen-orientation 3.0.2 "Screen Orientation"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.4 "Whitelist"
cordova-plugin-x-socialsharing 5.6.4 "SocialSharing"
cordova-promise-polyfill 0.0.2 "cordova-promise-polyfill"
cordova-sqlite-storage 5.0.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version"
cordova.plugins.diagnostic 5.0.1 "Diagnostic"
es6-promise-plugin 4.2.2 "Promise"
uk.co.workingedge.phonegap.plugin.launchnavigator 4.2.2 "Launch Navigator"

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly)

@ionic-native/core : 5.0.7
@ionic-native/google-maps : 5.5.0

Current behavior:
I observe intermittent crashes when clicking on polylines on the map when multiple polylines are displayed simultaneously.

Expected behavior:
No crash.

I have debugged the app with Android Studio and I get the following stack trace:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.bmi.evaluway, PID: 8923
    java.lang.NullPointerException: Attempt to read from field 'double com.google.android.gms.maps.model.LatLng.latitude' on a null object reference
        at plugin.google.maps.PluginMap.onOverlayEvent(PluginMap.java:2444)
        at plugin.google.maps.PluginMap.onPolylineClick(PluginMap.java:2450)
        at plugin.google.maps.PluginMap$33$1.run(PluginMap.java:3158)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/Process: Sending signal. PID: 8923 SIG: 9

The problem is that an invalid point is passed up the stack.
By looking at the code here


I believe that the problem is in the fact that when a polyline is matched with the point the loop continues:

                  if (touchPoint != null) {
                    hitOverlay = polyline;
                    maxZIndex = zIndex;
                    continue;
                  }

and touchPoint can become null while hitOverlay isn't. I think continue should be break in this case, can you have a look?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0