Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

MergeOfflineRegionsCallbacks are never fired #14485

Closed
Guardiola31337 opened this issue Apr 23, 2019 · 0 comments · Fixed by #14514 or #14601
Closed

MergeOfflineRegionsCallbacks are never fired #14485

Guardiola31337 opened this issue Apr 23, 2019 · 0 comments · Fixed by #14514 or #14601
Labels
Android Mapbox Maps SDK for Android bug offline

Comments

@Guardiola31337
Copy link
Contributor

Integrating offline maps downstream in mapbox-navigation-android 👀 mapbox/mapbox-navigation-android#1895 we've noticed that when trying to mergeOfflineRegions the OfflineManager.MergeOfflineRegionsCallback listeners are never fired https://github.com/mapbox/mapbox-navigation-android/blob/1ced0224aab1484024af079745498dd401d0882f/libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/MapOfflineManager.java#L58-L68

We were able to reproduce in mapbox-gl-native https://github.com/mapbox/mapbox-gl-native/tree/pg-downstream-module and after debugging it seems that the WeakReferences callbacks implemented in FileUtils

private final WeakReference<OnCheckFileReadPermissionListener> listenerWeakReference;
private final WeakReference<OnCheckFileWritePermissionListener> listenerWeakReference;
are garbage collected somehow and always returning null
OnCheckFileReadPermissionListener listener = listenerWeakReference.get();
OnCheckFileWritePermissionListener listener = listenerWeakReference.get();
which means that the listeners are never fired because when null, nothing is done.

For debugging purposes we've removed the WeakReferences and the callbacks were 👌 Obviously, in order to keep avoiding potential memory leaks, this is not enough, but maybe we could add a setter in the tasks, that could be set to null accordingly, so it's garbage collected without needing WeakReference. Thoughts?

cc @zugaldia

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android bug offline
Projects
None yet
2 participants