You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue has long story behind, raised here, reworked here and the official following with the documented recommendation to avoid leaks using WeakReferences here implemented here.
Actually the issue with FusedLocationApi leaking listeners is tracked for a long time at 1, 2 and Google claims it will be resolved in the upcoming version 20 of Google play services library.
At the same time it seems that we can apply an easy fix that would make all the workarounds with WeakReferences unneeded.
This is how the leak path look like :
Obfuscated gms.location.zzx holds reference to the instance of LocationCallback that is our GoogleLocationEngineCallbackTransport instance, which in turn holds private final LocationEngineCallback<LocationEngineResult> callback that is actual callback passed by user. It seems we can just reset this field to null when removeLocationUpdates is called in addition to actual removal from the FusedLocationApis.
So it would still leak the GoogleLocationEngineCallbackTransport, but not the external callback passed by users (making activity or other big leaks not possible at all).
Expected
No leaks, happy users :)
Logging
Please attach logs or error messages
The text was updated successfully, but these errors were encountered:
Configuration
Steps to Reproduce
Discovered the issue while debugging maps-android leak.
LocationCallback passed to GoogleLocationEngineImpl.requestLocationUpdates leaks after GoogleLocationEngineImpl.removeLocationUpdates is called.
The issue has long story behind, raised here, reworked here and the official following with the documented recommendation to avoid leaks using WeakReferences here implemented here.
Actually the issue with FusedLocationApi leaking listeners is tracked for a long time at 1, 2 and Google claims it will be resolved in the upcoming version 20 of Google play services library.
At the same time it seems that we can apply an easy fix that would make all the workarounds with WeakReferences unneeded.
This is how the leak path look like :
Obfuscated
gms.location.zzx
holds reference to the instance of LocationCallback that is our GoogleLocationEngineCallbackTransport instance, which in turn holdsprivate final LocationEngineCallback<LocationEngineResult> callback
that is actual callback passed by user. It seems we can just reset this field to null whenremoveLocationUpdates
is called in addition to actual removal from the FusedLocationApis.So it would still leak the
GoogleLocationEngineCallbackTransport
, but not the external callback passed by users (making activity or other big leaks not possible at all).Expected
No leaks, happy users :)
Logging
Please attach logs or error messages
The text was updated successfully, but these errors were encountered: