Repository: googlemaps/android-maps-utils

Issue #660: android-map-utils: Crash in ClusterTask
Created: 2020-03-17T13:26:17Z
The ClusterTask doInBackground() method does sometimes crash. It seems that the write lock is released in a different thread than it is being acquired. The internal ReentrantReadWriteLock.tryRelease() method complains that the lock is not being held exclusively. This might have something to do with the fact that the ClusterTask is now running on the thread pool executor.
Environment details
Tested with android-map-utils 1.0.0 on Android API 28.
Steps to reproduce
Execute the cluster() method repeatedly with lots of items.
Stack trace
2020-03-17 13:56:31.860 29075-29148/ch.infoflora.florapp.dev E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
    Process: ch.infoflora.florapp.dev, PID: 29075
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:354)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.IllegalMonitorStateException
        at java.util.concurrent.locks.ReentrantReadWriteLock$Sync.tryRelease(ReentrantReadWriteLock.java:373)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1285)
        at java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.unlock(ReentrantReadWriteLock.java:1138)
        at com.google.maps.android.clustering.algo.AbstractAlgorithm.unlock(AbstractAlgorithm.java:37)
        at com.google.maps.android.clustering.ClusterManager$ClusterTask.doInBackground(ClusterManager.java:297)
        at com.google.maps.android.clustering.ClusterManager$ClusterTask.doInBackground(ClusterManager.java:290)
        at android.os.AsyncTask$2.call(AsyncTask.java:333)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:764) 

Duplicate issue #694: Crash after updating from version 0.6.2 to 1.1.0
Created: 2020-04-15T20:42:35Z
Environment details

Custom look with NonHierarchicalViewBasedAlgorithm
Huawei P20 lite, Android 9
android-maps-utils:1.1.0

Steps to reproduce
I have a fab for moving to the current location

Press on my location fab
Go back to the previous screen, before map shows the current location
Come back to the map screen and press my location fab again.

It's not crashing every time and I'm able to reproduce it only on the mentioned device.
Stack trace
java.util.concurrent.locks.ReentrantReadWriteLock$Sync.tryRelease ReentrantReadWriteLock.java:373
java.util.concurrent.locks.AbstractQueuedSynchronizer.release AbstractQueuedSynchronizer.java:1285
java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.unlock ReentrantReadWriteLock.java:1138
com.google.maps.android.clustering.algo.AbstractAlgorithm.unlock AbstractAlgorithm.java:37
com.google.maps.android.clustering.ClusterManager$ClusterTask.doInBackground ClusterManager.java:297
com.google.maps.android.clustering.ClusterManager$ClusterTask.doInBackground ClusterManager.java:290
android.os.AsyncTask$2.call AsyncTask.java:334
java.util.concurrent.FutureTask.run FutureTask.java:266
java.util.concurrent.ThreadPoolExecutor.processTask ThreadPoolExecutor.java:1187
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java:1152
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java:641
java.lang.Thread.run Thread.java:784
android.os.AsyncTask$3.done AsyncTask.java:355
java.util.concurrent.FutureTask.finishCompletion FutureTask.java:383
java.util.concurrent.FutureTask.setException FutureTask.java:252
java.util.concurrent.FutureTask.run FutureTask.java:271
java.util.concurrent.ThreadPoolExecutor.processTask ThreadPoolExecutor.java:1187
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java:1152
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java:641
java.lang.Thread.run Thread.java:784

Closing comment (2020-06-22T14:21:30Z): @HermineSan Thanks for reporting this! Looks like this is a duplicate of #660, so I'm going to close this so the discussion can continue at #660.