cowbell / cordova-plugin-geofence

Geofencing plugin for cordova
Apache License 2.0
265 stars 316 forks source link

java.util.NoSuchElementException after app is running for 2-4 days #139

Open bromeostasis opened 8 years ago

bromeostasis commented 8 years ago

After we leave our app in the background for a few days with this plugin running, it crashes in the background with no explanation. After writing a custom java exception handler, I finally was able to grab the following stacktrace:

Date: Fri Apr 15 07:57:44 EDT 2016
java.util.NoSuchElementException
    at java.util.LinkedList.removeFirstImpl(LinkedList.java:689)
    at java.util.LinkedList.removeFirst(LinkedList.java:676)
    at java.util.LinkedList.poll(LinkedList.java:895)
    at com.cowbell.cordova.geofence.GoogleServiceCommandExecutor.ExecuteNext(GoogleServiceCommandExecutor.java:26)
    at com.cowbell.cordova.geofence.GoogleServiceCommandExecutor.onCommandExecuted(GoogleServiceCommandExecutor.java:35)
    at com.cowbell.cordova.geofence.AbstractGoogleServiceCommand.CommandExecuted(AbstractGoogleServiceCommand.java:101)
    at com.cowbell.cordova.geofence.AddGeofenceCommand$1.onResult(AddGeofenceCommand.java:73)
    at com.cowbell.cordova.geofence.AddGeofenceCommand$1.onResult(AddGeofenceCommand.java:55)
    at com.google.android.gms.common.api.internal.zzb$zza.zzb(Unknown Source)
    at com.google.android.gms.common.api.internal.zzb$zza.handleMessage(Unknown Source)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5290)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)

The issue seems to mostly happen while moving around in the car (presumably entering/exiting a lot of geofences). As mentioned, it takes a long time to reproduce, so we don't have a ton of info on root causes.

I haven't had much time to look at this/analyze today, but I was wondering if anyone else has seen this issue or could provide some insight into why this might happen. I'm happy to provide any more details about cause/testing/etc.

Thanks in advance!

bromeostasis commented 8 years ago

Got another different error with a build in the background for a few days:

java.lang.RuntimeException: Init failed
    at android.media.ToneGenerator.native_setup(Native Method)
    at android.media.ToneGenerator.<init>(ToneGenerator.java:771)
    at com.cowbell.cordova.geofence.BeepHelper.<init>(BeepHelper.java:10)
    at com.cowbell.cordova.geofence.GeoNotificationNotifier.<init>(GeoNotificationNotifier.java:24)
    at com.cowbell.cordova.geofence.ReceiveTransitionsIntentService.onHandleIntent(ReceiveTransitionsIntentService.java:45)
    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.os.HandlerThread.run(HandlerThread.java:61)

which I've linked to #73

jyyblue1987 commented 6 years ago

I have same error as first stack trace.

bromeostasis commented 6 years ago

@jyyblue1987 we've since moved to https://github.com/transistorsoft/cordova-background-geolocation , which does not have as many problems in the background, but we do pay for Android use.