lostzen / lost

A drop-in replacement for Google Play services location APIs for Android
http://mapzen.github.io/lost/
Other
352 stars 70 forks source link

Location updates received only once #241

Closed Guardiola31337 closed 7 years ago

Guardiola31337 commented 7 years ago

Description

  1. Set lost location engine -> Create a lost api client, add connection listener and activate the lost api client. When connected request location updates
  2. On location changed is fired. So far so good.
  3. Set no engine -> Remove the location updates, remove the location listener and deactivate the lost api client.
  4. Repeat step 1.
  5. On location changed is not fired anymore.

Noting that after ☝️ you don't receive any location updates either even if you navigate between the different activities of the app (setting no engine when onPause and restoring it when onResume). The only way that I found to receive again the location update (only once as described above) was to force stop the app.

Steps to Reproduce

You can reproduce the behavior described above running the test app included in this branch https://github.com/mapbox/mapbox-java/tree/pg-lost-issue following the steps 👇

  1. Run the test app
  2. Navigate to Location engine activity example
  3. Choose Lost as location provider (Description's step 1)
  4. After that, you'll see your location (Description's step 2)
  5. Choose None as location provider (Description's step 3)
  6. Choose Lost as location provider (Description's step 4)
  7. No location updates (Description's step 5)

Lost & Android Version

Lost 3.0.3 Moto X 2nd gen Android 5.0 Nexus 5 Android 6.0

During testing I hit a DeadObjectException (👀 https://github.com/mapzen/lost/issues/218) but I'm not sure if it could be related to this one (maybe crashing silently?). Sadly I don't have a reproducible use-case. https://github.com/mapzen/lost/issues/221 seems related too.

10-02 21:04:34.349 22294-22309/com.mapbox.services.android.testapp:lost E/FusedLocationProviderServiceDelegate: Error occurred trying to report a new Location
                                                                                                                android.os.DeadObjectException
                                                                                                                    at android.os.BinderProxy.transactNative(Native Method)
                                                                                                                    at android.os.BinderProxy.transact(Binder.java:503)
                                                                                                                    at com.mapzen.android.lost.internal.IFusedLocationProviderCallback$Stub$Proxy.onLocationChanged(IFusedLocationProviderCallback.java:129)
                                                                                                                    at com.mapzen.android.lost.internal.FusedLocationProviderServiceDelegate.reportLocation(FusedLocationProviderServiceDelegate.java:95)
                                                                                                                    at com.mapzen.android.lost.internal.FusionEngine.onLocationChanged(FusionEngine.java:191)
                                                                                                                    at com.mapzen.android.lost.internal.FusionEngine.checkLastKnownAndNotify(FusionEngine.java:183)
                                                                                                                    at com.mapzen.android.lost.internal.FusionEngine.checkLastKnownGps(FusionEngine.java:169)
                                                                                                                    at com.mapzen.android.lost.internal.FusionEngine.enable(FusionEngine.java:119)
                                                                                                                    at com.mapzen.android.lost.internal.LocationEngine.addRequest(LocationEngine.java:47)
                                                                                                                    at com.mapzen.android.lost.internal.FusedLocationProviderServiceDelegate.requestLocationUpdates(FusedLocationProviderServiceDelegate.java:65)
                                                                                                                    at com.mapzen.android.lost.internal.FusedLocationProviderService$1.requestLocationUpdates(FusedLocationProviderService.java:43)
                                                                                                                    at com.mapzen.android.lost.internal.IFusedLocationProviderService$Stub.onTransact(IFusedLocationProviderService.java:101)
                                                                                                                    at android.os.Binder.execTransact(Binder.java:453)
sarahsnow1 commented 7 years ago

Thanks for the detailed report, it's very helpful and greatly appreciated. I'm not able to reproduce this exactly, what I see is a noticeable delay receiving any locations after switching providers. Would you mind retesting and letting the app sit for a while after switching from None to Lost to see if you too eventually get a location update?

What causes the delay is that we aren't clearing cached ReportedChanges for each listener when it is removed from LostClientManager. So in this case, when you resubscribe, we receive notifications from the engine but don't notify your listener (https://github.com/mapzen/lost/blob/master/lost/src/main/java/com/mapzen/android/lost/internal/LostClientManager.java#L307). Removing reported changes for each listener/pending intent/callback when it is removed from the manager will solve this. Expect a PR shortly.

I haven't hit the DeadObjectException but will look into it more.

dev-myatminsoe commented 4 years ago

Happening the same.