ufukhawk / safe_device

MIT License
47 stars 45 forks source link

com.xamdesign.safe_device.MockLocation is causing ANR #50

Closed tulioccalazans closed 1 month ago

tulioccalazans commented 5 months ago

Hi, MockLocation is causing ANR, safe_device version 1.1.7

Before version 1.1.6, the same thing happened with the trust_location package

Both issues were noticed in Android 14

My application does not check mock location. But I see that the package performs some initialization when the application runs. This is probably causing the problem.

MockLocation (safe_device v1.1.6)

main (timed waiting):tid=1 systid=13472 at jdk.internal.misc.Unsafe.park(Native method) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:717) at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1074) at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:276) at com.google.android.gms.internal.location.zzey.zza(com.google.android.gms:play-services-location@@21.1.0:3) at com.google.android.gms.internal.location.zzbb.getLocationAvailability(com.google.android.gms:play-services-location@@21.1.0:11) at com.xamdesign.safe_device.MockLocation.LocationAssistant.checkLocationAvailability(LocationAssistant.java:519) at com.xamdesign.safe_device.MockLocation.LocationAssistant.acquireLocation(LocationAssistant.java:468) at com.xamdesign.safe_device.MockLocation.LocationAssistant.access$000(LocationAssistant.java:41) at com.xamdesign.safe_device.MockLocation.LocationAssistant$1.run(LocationAssistant.java:462) at android.os.Handler.handleCallback(Handler.java:1000) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loopOnce(Looper.java:242) at android.os.Looper.loop(Looper.java:362) at android.app.ActivityThread.main(ActivityThread.java:8407) at java.lang.reflect.Method.invoke(Native method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:992)

trust_location (safe_device v1.1.4) trust_location ANR issue

main (timed waiting):tid=1 systid=25919 at jdk.internal.misc.Unsafe.park(Native method) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:717) at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1074) at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:276) at com.google.android.gms.internal.location.zzau.getLastLocation(com.google.android.gms:play-services-location@@21.0.1:12) at com.wongpiwat.trust_location.LocationAssistant.checkInitialLocation(LocationAssistant.java:494) at com.wongpiwat.trust_location.LocationAssistant.access$600(LocationAssistant.java:57) at com.wongpiwat.trust_location.LocationAssistant$8.onResult(LocationAssistant.java:730) at com.wongpiwat.trust_location.LocationAssistant$8.onResult(LocationAssistant.java:722) at com.google.android.gms.common.api.internal.BasePendingResult$CallbackHandler.handleMessage(com.google.android.gms:play-services-base@@18.1.0:6) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at android.app.ActivityThread.main(ActivityThread.java:8893) at java.lang.reflect.Method.invoke(Native method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

tulioccalazans commented 5 months ago

Hi, I created a fork removing all MockLocation checking part.

https://github.com/tulioccalazans/safe_device/tree/dev

If you want to use it in your project, use it this way:

  safe_device:
    git:
      url: https://github.com/tulioccalazans/safe_device.git
      ref: dev
jozefvodicka commented 4 months ago

Any update on this? is there a PR for this?

KhrisnaIndrawan commented 2 months ago

Any update on this? is there a PR for this?

I am trying version 1.1.4, it does not make my app freeze or not responding.

putrautama007 commented 2 months ago

Any update on this? is there a PR for this?

I am trying version 1.1.4, it does not make my app freeze or not responding.

did you use it on production project?

KhrisnaIndrawan commented 2 months ago

Any update on this? is there a PR for this?

I am trying version 1.1.4, it does not make my app freeze or not responding.

did you use it on production project?

My bad @putrautama007 , version 1.1.4 still have same issue. I am using @tulioccalazans workaround

fahmisatrio commented 1 month ago

safe_device: git: url: https://github.com/tulioccalazans/safe_device.git ref: dev

i found the same issue that cause ANR. my previous release was using safe_device 1.1.4 upgraded to safe_device 1.1.5 and even 1.1.7 still got same problem.

Now i'm using @tulioccalazans workaround and temporarily disabled my isMockLocation checking and it works like a charm.

ufukhawk commented 1 month ago

safe_device: ^1.1.8

quangduy-luong commented 1 month ago

I didn't see in the changelog or in the PR for 1.1.8 anything that addresses mock location, only the Sony issue. This isn't happening only on Sony devices. Is it really fixed?