android-maps-utils: "Released unknown imageData reference"

I am doing the clustering dynamically to get an acceptable performance:

 private class DynamicallyAddMarkerTask extends AsyncTask {
        @Override
        protected void onPostExecute(Object o) {
            super.onPostExecute(o);
            clusterManager.cluster();
        }

        @Override
        protected Object doInBackground(Object[] objects) {
            LatLngBounds bounds = (LatLngBounds) objects[0];
            clusterManager.clearItems();

            for (LoyaltyOutlet currentMarker : sortedAndFilteredOutlets) {
                if (bounds.contains(currentMarker.getPosition())) {
                    clusterManager.addItem(currentMarker);
                }
            }

            return null;
        }
    }

This is triggered in a OnCameraChangeListener but unfortunately this makes the lib crash my app now and then. Do you think it will possible to fix this issue in the lib by for example just ignoring the exception?

Crash stack trace:

 java.lang.IllegalArgumentException: Released unknown imageData reference
            at com.google.common.base.j.a(Unknown Source)
            at com.google.maps.api.android.lib6.impl.f.c(Unknown Source)
            at com.google.maps.api.android.lib6.impl.ap.a(Unknown Source)
            at com.google.maps.api.android.lib6.impl.ap.remove(Unknown Source)
            at com.google.android.gms.maps.model.internal.IMarkerDelegate$Stub.onTransact(IMarkerDelegate.java:51)
            at android.os.Binder.transact(Binder.java:347)
            at com.google.android.gms.maps.model.internal.zzi$zza$zza.remove(Unknown Source)
            at com.google.android.gms.maps.model.Marker.remove(Unknown Source)
            at com.google.maps.android.MarkerManager$Collection.remove(MarkerManager.java:163)
            at com.google.maps.android.MarkerManager.remove(MarkerManager.java:140)
            at com.google.maps.android.clustering.view.DefaultClusterRenderer$MarkerModifier.removeMarker(DefaultClusterRenderer.java:637)
            at com.google.maps.android.clustering.view.DefaultClusterRenderer$MarkerModifier.performNextTask(DefaultClusterRenderer.java:628)
            at com.google.maps.android.clustering.view.DefaultClusterRenderer$MarkerModifier.handleMessage(DefaultClusterRenderer.java:596)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:176)
            at android.app.ActivityThread.main(ActivityThread.java:5419)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
            at dalvik.system.NativeStart.main(Native Method)

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 18

Most upvoted comments

Looks like I have found another workaround for the issue. Before doing anything asynchronous with a marker, check clusterManager.markerCollection.markers.contains(marker) and proceed only if it’s true - when clustermanager is removing markers for whatever reason, it first removes the marker from this markers array, but it can still fail somehow later removing actual marker from the map.

Additionally, wrap your calls to marker.setIcon() with try/catch of IllegalArgumentException, and also place this repo as a source library and change this method in MarkerManager.java:

public boolean remove(Marker marker) {
            if (mMarkers.remove(marker)) {
                mAllMarkers.remove(marker);
                try {
                    marker.remove();
                } catch (Throwable t) {
                    t.printStackTrace();
                }

                return true;
            }
            return false;
        }