transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
655 stars 277 forks source link

App is getting crashed and keep getting ANR #1228

Closed Taxi4you closed 2 years ago

Taxi4you commented 3 years ago

Your Environment

Expected Behavior

App shouldn't get crashed or cause ANR.

Actual Behavior

Plugin (not to blame, but maybe) charges in crashing the app.

Steps to Reproduce

  1. Start geolocation on foreground.
  2. Minimise the app and go to other apps
  3. Back to the app and its starts from the splash screen all over again as the app was crashed while on background.

    Context

    Avoid crashes and ANRs.

Debug logs

Logs ``` # first android.app.RemoteServiceException android.app.RemoteServiceException: at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2137) at android.os.Handler.dispatchMessage (Handler.java:107) at android.os.Looper.loop (Looper.java:237) at android.app.ActivityThread.main (ActivityThread.java:7948) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1075) # second "main" prio=5 tid=1 Runnable #00 pc 00000000004117d4 /apex/com.android.runtime/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+140) #00 pc 00000000004f9af8 /apex/com.android.runtime/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream>&, bool, BacktraceMap*, bool) const+512) #00 pc 0000000000514158 /apex/com.android.runtime/lib64/libart.so (art::DumpCheckpoint::Run(art::Thread*)+828) #00 pc 00000000004fa804 /apex/com.android.runtime/lib64/libart.so (art::Thread::RunCheckpointFunction()+176) #00 pc 000000000059149c /apex/com.android.runtime/lib64/libart.so (art::JniMethodFastEndWithReference(_jobject*, unsigned int, art::Thread*)+68) at dalvik.system.VMStack.getThreadStackTrace (Native method) at java.lang.Thread.getStackTrace (Thread.java:1720) at com.transistorsoft.tslocationmanager.Application.iH (unavailable) at com.transistorsoft.locationmanager.notification.TSLocalNotification.build (unavailable) at com.transistorsoft.locationmanager.service.ForegroundNotification.a (unavailable) at com.transistorsoft.locationmanager.service.AbstractService.f (unavailable) at com.transistorsoft.locationmanager.service.AbstractService.a (unavailable) at com.transistorsoft.locationmanager.service.TrackingService.onStartCommand (unavailable) at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4288) at android.app.ActivityThread.access$1800 (ActivityThread.java:268) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2014) at android.os.Handler.dispatchMessage (Handler.java:107) at android.os.Looper.loop (Looper.java:237) at android.app.ActivityThread.main (ActivityThread.java:7814) at java.lang.reflect.Method.invoke (Native method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1068) # third "Jit thread pool worker thread 0" daemon prio=5 tid=2 Native #00 pc 000000000008033c /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28) #00 pc 000000000014c1f4 /apex/com.android.runtime/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+148) #00 pc 0000000000515bb8 /apex/com.android.runtime/lib64/libart.so (art::ThreadPool::GetTask(art::Thread*)+256) #00 pc 0000000000514f44 /apex/com.android.runtime/lib64/libart.so (art::ThreadPoolWorker::Run()+144) #00 pc 0000000000514a04 /apex/com.android.runtime/lib64/libart.so (art::ThreadPoolWorker::Callback(void*)+148) #00 pc 00000000000e6f10 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) #00 pc 00000000000850c8 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) #thourth "ReferenceQueueDaemon" daemon prio=5 tid=9 Waiting at java.lang.Object.wait (Native method) at java.lang.Object.wait (Object.java:442) at java.lang.Object.wait (Object.java:568) at java.lang.Daemons$ReferenceQueueDaemon.runInternal (Daemons.java:215) at java.lang.Daemons$Daemon.run (Daemons.java:137) at java.lang.Thread.run (Thread.java:919) and there more and more like that. ```
christocracy commented 3 years ago

See CHANGELOG then scroll up. Install latest version.

Taxi4you commented 3 years ago

How update the plugin safely? There couple of configurations that were configured in the past, which I don't remember now and concern to ruin them.

christocracy commented 3 years ago

Do you want your app to be supporting iOS 14 / Android 11? Currently it's not with the version 3.6.3 that you're using.

Taxi4you commented 3 years ago

Chris, I understand, I am not argue with you, I just ask how to upgrade to the latest version - I clearly want it to support iOS 14 and Android 11. If you kind just give me some tips of how to upgrade the plugin easily - as I said, there couple of configurations I concern to ruin. If you don't have any clue of how to upgrade the plugin easily without breaking all of the configurations, that's also okay.

christocracy commented 3 years ago

I don't know what you're talking about. Upgrading is as easy as installing the latest version.

Try it on your dev device and start field-testing until you're satisfied.

Taxi4you commented 3 years ago

but should I remove the plugin and reinstall it? or that there is a way to update without uninstalling?

christocracy commented 3 years ago

but should I remove the plugin and reinstall it?

Yes. That's how you update any Cordova plugin. Remove / install.

Taxi4you commented 3 years ago

Installing "cordova-background-geolocation-lt" for android Failed to install 'cordova-background-geolocation-lt': CordovaError: Version of installed plugin: "cordova-plugin-background-fetch@6.0.5" does not satisfy dependency plugin requirement "cordova-plugin-background-fetch@~6.1.1". Try --force to use installed plugin as dependency. at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:544:43 at processTicksAndRejections (internal/process/task_queues.js:97:5)

christocracy commented 3 years ago

FYI: multi-line Syntax highlighting requires 3 backticks.

Remove cordova-plugin-background-fetch. background-geolocation will re-install it.

Taxi4you commented 3 years ago

Ok, successfully installed and launched on device. A question please: before removing the plugin I have this in the config.xml:

<plugin name="cordova-background-geolocation-lt" spec="^3.9.4">
    <variable name="GOOGLE_API_VERSION" value="16.+"/>
    <variable name="APPCOMPAT_VERSION" value="28.+"/>
    <variable name="OKHTTP_VERSION" value="3.12.+"/>
    <variable name="EVENTBUS_VERSION" value="3.0.0"/>
    <variable name="BACKGROUND_MODE_LOCATION" value="&lt;string>location&lt;/string>"/>
  </plugin>

Should I put this this again or not?

christocracy commented 3 years ago

Cordova platform version (cordova platform ls): android 8.1.0

Are you aware that Google Play Store now requires a minimum targetSdkVersion 29?

This requires Cordova 10.0.0 / cordova-android@9.0.0.

Taxi4you commented 3 years ago

So what to do?

christocracy commented 3 years ago

So what to do?

$ sudo npm install -g cordova
$ cordova platform remove android
$ cordova platform add android
Taxi4you commented 3 years ago

and then what?

Taxi4you commented 3 years ago

Update: app is still getting closed on Android 11, Xiamo - only when location enabled in the background - no location - app not getting closed.

christocracy commented 3 years ago

see http://dontkillmyapp.com

christocracy commented 3 years ago

Also see wiki Debugging.

Taxi4you commented 3 years ago

Still got those crashes even when upgrading to the latest version. See the marked answer of this question: https://stackoverflow.com/questions/51222082/why-do-i-get-remoteserviceexception-for-creating-updating-a-notification Maybe this is something that can help you fix the problem

IanMcGhie commented 3 years ago

Also see wiki Debugging.

christocracy commented 3 years ago

Maybe this is something that can help you fix the problem

The plugin doesn't have a problem.

IanMcGhie commented 3 years ago

Ok. Let's look at the error. Usually starting at the top of the message. There should be a reference to a line in your code. If you paste some code in here. I will try to help.

Taxi4you commented 3 years ago

Ok. Let's look at the error. Usually starting at the top of the message. There should be a reference to a line in your code. If you paste some code in here. I will try to help.

Thanks for your assist, but all I have has been posted in the first, under the Log.

Taxi4you commented 3 years ago

Maybe this is something that can help you fix the problem

The plugin doesn't have a problem.

I also got crash that was reported in the Google Play Console:

java.lang.OutOfMemoryError
com.transistorsoft.locationmanager.logger.TSSQLiteAppender.append

Log:

java.lang.OutOfMemoryError: 
  at java.lang.Thread.nativeCreate (Native Method)
  at java.lang.Thread.start (Thread.java:883)
  at java.util.concurrent.ThreadPoolExecutor.addWorker (ThreadPoolExecutor.java:975)
  at java.util.concurrent.ThreadPoolExecutor.execute (ThreadPoolExecutor.java:1393)
  at com.transistorsoft.locationmanager.logger.TSSQLiteAppender.append (Unknown Source:15)
  at com.transistorsoft.locationmanager.logger.TSSQLiteAppender.append (Unknown Source:2)
  at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend (Unknown Source:84)
  at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders (Unknown Source:15)
  at ch.qos.logback.classic.Logger.appendLoopOnAppenders (Unknown Source:4)
  at ch.qos.logback.classic.Logger.callAppenders (Unknown Source:5)
  at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend (Unknown Source:15)
  at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus (Unknown Source:28)
  at ch.qos.logback.classic.Logger.warn (Unknown Source:9)
  at com.transistorsoft.locationmanager.service.AbstractService.a (Unknown Source:194)
  at com.transistorsoft.locationmanager.service.TrackingService.onStartCommand (Unknown Source:1)
  at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4145)
  at android.app.ActivityThread.access$1900 (ActivityThread.java:224)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1919)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:223)
  at android.app.ActivityThread.main (ActivityThread.java:7562)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:539)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:950)
christocracy commented 3 years ago
java.lang.OutOfMemoryError: 
  at java.lang.Thread.nativeCreate (Native Method)
  at java.lang.Thread.start (Thread.java:883)
  at java.util.concurrent.ThreadPoolExecutor.addWorker (ThreadPoolExecutor.java:975)
  at java.util.concurrent.ThreadPoolExecutor.execute (ThreadPoolExecutor.java:1393)
  at com.transistorsoft.locationmanager.logger.TSSQLiteAppender.append (Unknown Source:15)

Perhaps your device is OutOfMemory and there's not more space to add log-events in the database.

You're not actually submitting a release version of your app with LOG_LEVEL_VERBOSE, are you?

Taxi4you commented 3 years ago

How to know it?

christocracy commented 3 years ago

Well, if you're not using the plugin's built-in http service for uploading locations to your server, the plugin is storing 3 days worth of locations in its database. In that case, you should be configuring maxRecordsToPersist: 0

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

stale[bot] commented 2 years ago

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.