android-maps-utils icon indicating copy to clipboard operation
android-maps-utils copied to clipboard

Crash: NPE: Attempt to read from field 'com.google.maps.android.clustering.algo.StaticCluster.mItems' on a null object reference

Open nostra13 opened this issue 5 years ago • 2 comments

Summary

Had single crash from production inside the lib: java.lang.NullPointerException: Attempt to read from field 'java.util.List com.google.maps.android.clustering.algo.StaticCluster.mItems' on a null object reference

Environment details

  1. Xiaomi Redmi 9A
  2. Android 10
implementation "com.google.maps.android:android-maps-utils-v3:2.0.3" 
implementation "com.google.android.libraries.maps:maps:3.1.0-beta"

Stack trace

Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
       at android.os.AsyncTask$4.done(AsyncTask.java:399)
       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:919)
Caused by java.lang.NullPointerException: Attempt to read from field 'java.util.List com.google.maps.android.clustering.algo.StaticCluster.mItems' on a null object reference
       at com.google.maps.android.clustering.algo.StaticCluster.remove(StaticCluster.java:48)
       at com.google.maps.android.clustering.algo.NonHierarchicalDistanceBasedAlgorithm.getClusters(NonHierarchicalDistanceBasedAlgorithm.java:212)
       at com.google.maps.android.clustering.algo.PreCachingAlgorithmDecorator.getClustersInternal(PreCachingAlgorithmDecorator.java:141)
       at com.google.maps.android.clustering.algo.PreCachingAlgorithmDecorator.getClusters(PreCachingAlgorithmDecorator.java:104)
       at com.google.maps.android.clustering.algo.ScreenBasedAlgorithmAdapter.getClusters(ScreenBasedAlgorithmAdapter.java:71)
       at com.google.maps.android.clustering.ClusterManager$ClusterTask.doInBackground(ClusterManager.java:312)
       at com.google.maps.android.clustering.ClusterManager$ClusterTask.doInBackground(ClusterManager.java:306)
       at android.os.AsyncTask$3.call(AsyncTask.java:378)
       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:919)

nostra13 avatar Oct 05 '20 09:10 nostra13

@nostra13 Thanks for the report! Is this something you can reproduce? What was happening inside the app when the crash occurred?

barbeau avatar Oct 05 '20 15:10 barbeau

@barbeau No, I couldn't reproduce it.

According to logs last 2 actions on map were:

  • refresh markers on map
  • remove all markers from map

So last action was com.google.maps.android.clustering.ClusterManager.removeItems(...) + cluster(). And probably (not sure) just before that markers were updated by ClusterManager.updateItem(...) or ClusterManager.addItems(...) + ClusterManager.cluster().

So possible calls before crash were:

clusterManager.updateItem(...) // maybe
clusterManager.updateItem(...) // maybe
clusterManager.addItems(...) // maybe
clusterManager.cluster()
clusterManager.removeItems(...)
clusterManager.cluster()

nostra13 avatar Oct 05 '20 15:10 nostra13

Not reproducible.

wangela avatar Sep 14 '22 08:09 wangela