cordova-plugin-googlemaps icon indicating copy to clipboard operation
cordova-plugin-googlemaps copied to clipboard

Race Condition in PluginMarkerCluster class

Open d4ex opened this issue 8 years ago • 10 comments

[ ] question [X] any problem or bug report [ ] feature request

[X] Android [ ] iOS

cordova information: (run $> cordova plugin list)

cordova-custom-config 5.0.2 "cordova-custom-config"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-device 1.1.7 "Device"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-opener2 2.0.19 "File Opener2"
cordova-plugin-google-analytics 1.8.3 "Google Universal Analytics Plugin"
cordova-plugin-googlemaps 2.1.1 "cordova-plugin-googlemaps"
cordova-plugin-inappbrowser 1.7.2 "InAppBrowser"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-ios-non-exempt-encryption 1.0.0 "ITSAppUsesNonExemptEncryption false"
cordova-plugin-network-information 1.3.4 "Network Information"
cordova-plugin-splashscreen 4.1.0 "Splashscreen"
cordova-plugin-statusbar 2.4.0 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

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

Current behavior: We are using ionic to build our Apps...

The following Problem occurs (sometimes) if i close the Page displaying the Map:

  • PluginMarkerCluster:removeOverlaysOnUiThread calls synchronized (deleteMarkers) parallel:
  • PluginMarkerCluster:clear calls synchronized (pluginMarkers)

after this:

  • PluginMarkerCluster:removeOverlaysOnUiThread waits for synchronized(pluginMarkers) and
  • PluginMarkerCluster:clear waits for synchronized(deleteMarkers)

That causes a deadlock and results in the following Stacktrace (the App hangs infinitely):

"main" prio=5 tid=1 Blocked
  | group="main" sCount=1 dsCount=0 obj=0x76b2cc98 self=0x7c54cc7a00
  | sysTid=18987 nice=-4 cgrp=default sched=0/0 handle=0x7c59742a98
  | state=S schedstat=( 0 0 0 ) utm=193 stm=35 core=7 HZ=100
  | stack=0x7fe51a6000-0x7fe51a8000 stackSize=8MB
  | held mutexes=
  at plugin.google.maps.PluginMarkerCluster$2.run(PluginMarkerCluster.java:112)
  - waiting to lock <0x03a783eb> (a java.util.concurrent.ConcurrentHashMap) held by thread 25
  at android.os.Handler.handleCallback(Handler.java:751)
  at android.os.Handler.dispatchMessage(Handler.java:95)
  at android.os.Looper.loop(Looper.java:154)
  at android.app.ActivityThread.main(ActivityThread.java:6682)
  at java.lang.reflect.Method.invoke!(Native method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

"pool-1-thread-1" prio=5 tid=25 Blocked
  | group="main" sCount=1 dsCount=0 obj=0x12ef5790 self=0x7c31bc0e00
  | sysTid=19066 nice=0 cgrp=default sched=0/0 handle=0x7c2bb02450
  | state=S schedstat=( 0 0 0 ) utm=4 stm=0 core=3 HZ=100
  | stack=0x7c2ba00000-0x7c2ba02000 stackSize=1037KB
  | held mutexes=
  at plugin.google.maps.PluginMarkerCluster.clear(PluginMarkerCluster.java:62)
  - waiting to lock <0x095f2792> (a java.util.ArrayList) held by thread 1
  - locked <0x087e8563> (a java.lang.Object)
  - locked <0x03a783eb> (a java.util.concurrent.ConcurrentHashMap)
  at plugin.google.maps.PluginMap.clear(PluginMap.java:1650)
  at plugin.google.maps.PluginMap.remove(PluginMap.java:638)
  at plugin.google.maps.CordovaGoogleMaps.removeMap(CordovaGoogleMaps.java:753)
  at plugin.google.maps.CordovaGoogleMaps$2.run(CordovaGoogleMaps.java:296)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
  at java.lang.Thread.run(Thread.java:762)
....


d4ex avatar Dec 29 '17 12:12 d4ex

please share your project files on github.

wf9a5m75 avatar Dec 29 '17 15:12 wf9a5m75

ping

wf9a5m75 avatar Dec 29 '17 23:12 wf9a5m75

ping

wf9a5m75 avatar Jan 01 '18 03:01 wf9a5m75

Since there is no update for a while, I close this thread.

wf9a5m75 avatar Jan 03 '18 17:01 wf9a5m75

Sorry i was in holiday the last days. I try to reproduce the issue in a ionic base Project and share it on github.

d4ex avatar Jan 08 '18 09:01 d4ex

I have added a github project (Base Project was your quickdemo): https://github.com/d4ex/ionic-googlemaps-quickdemo-issue1968

Changes (see last commit): I have changed the HomePage (added a LOAD_MAP Button) to switch fast between MarkerClusterPage and HomePage.

But the change that matters is in the maker-cluster.ts. I've added a maxZoomLevel of one. If i switch now between HomePage and MarkerClusterPage the App runs into the deadlock.

I've tested this on Samsung Galaxy S6 Edge (SM-G925F) with Android 7 and Galaxy Tab A (SM-T580) with Android 7 and build the App with Android 5.1.1 (API 22)

d4ex avatar Jan 08 '18 13:01 d4ex

Did you try the mutliple_maps branch version?

wf9a5m75 avatar Jan 08 '18 17:01 wf9a5m75

maxZoomLevel: 1 kills the marker cluster feature. If you are just kidding me, please do that only for yourself.

wf9a5m75 avatar Jan 09 '18 00:01 wf9a5m75

I try multiple_maps branch today.

maxZoomLevel: 1 was only to reproduce the deadlock (stacktrace is the same). It looks like that the problem only appears on Maps with Markers only and Maps mixed with Markers and Clusters. On maps with clusters only i can not reproduce this. If i use the addMarker function instead of the addMarkerCluster function the app runs without problems.

In our app we are using maxZoomLevel: 6

I keep on trying today... i'm not kidding you, my only goal is to get this issue solved.

d4ex avatar Jan 09 '18 07:01 d4ex

I can not reproduce the deadlock on the multiple_maps branch, it seems to work. Thank you.

I'm closing this issue.

One last question: In which intervals the multiple_maps branch gets merged back to master?

d4ex avatar Jan 09 '18 10:01 d4ex