transistorsoft/nativescript-background-geolocation-lt

Prevent Application Stop

Opened this issue · 6 comments

Your Environment

  • Plugin version: 1.8.0
  • Platform: Android
  • OS version: 6.0.1
  • Device manufacturer / model: Xiaomi Redmi Note 3
  • Nativescript version (tns info):
    ┌──────────────────┬─────────────────┬────────────────┬──────────────────┐
    │ Component │ Current version │ Latest version │ Information │
    │ nativescript │ 3.4.1 │ 3.4.2 │ Update available │
    │ tns-core-modules │ 3.4.1 │ 3.4.1 │ Up to date │
    │ tns-android │ 3.4.1 │ 3.4.1 │ Up to date │
    │ tns-ios │ 3.4.1 │ 3.4.1 │ Up to date │
    └──────────────────┴─────────────────┴────────────────┴──────────────────┘
  • Plugin config

Expected Behavior

            debug: false,
            desiredAccuracy: 0,
            stationaryRadius: 25,
            locationUpdateInterval: 30000,
            activityRecognitionInterval: 30000,
            heartbeatInterval: 30,
            autoSync: true

Actual Behavior

After getting some time in the background the application freezes completely, not sending more "heartbeats" or getting location at the specified time. How can i prevent the freezing or make an woke-up method?

Steps to Reproduce

Context

I`m trying to make the app read the current location every 30 seconds(+-) while it is moving.

What do you mean by "freezing"?

The events like location, motionchange, geofence and heartbeat do not getting triggered after some time in background.

Are you observing the plugin logs?

See docs for #getLog, #emailLog methods.

Chris, sorry by my late.
Following the logs from today tests. I start the applicaction at 02-28 13:57 (GMT -5) and from 02-28 16:45(GMT -5) i did not receive more location events.

background-geolocation (1).log

configuration:

{
"isMoving": false,
"enabled": true,
"odometer": 661.8531,
"schedulerEnabled": false,
"trackingMode": "location",
"distanceFilter": 10,
"desiredAccuracy": 0,
"desiredOdometerAccuracy": 100,
"locationUpdateInterval": 1000,
"fastestLocationUpdateInterval": 10000,
"locationTimeout": 60,
"deferTime": 0,
"disableElasticity": false,
"elasticityMultiplier": 1,
"allowIdenticalLocations": false,
"activityRecognitionInterval": 10000,
"minimumActivityRecognitionConfidence": 75,
"triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking",
"disableStopDetection": false,
"stationaryRadius": 25,
"stopTimeout": 5,
"stopOnStationary": false,
"url": "http://tracker.transistorsoft.com/locations/transistor-nativescript",
"method": "POST",
"autoSync": true,
"autoSyncThreshold": 0,
"batchSync": false,
"maxBatchSize": -1,
"params": {
"device": {
"platform": "Android",
"manufacturer": "Xiaomi",
"model": "Redmi Note 3",
"version": "6.0.1",
"uuid": "913d71a0c8a0acd8",
"framework": "NativeScript"
}
},
"headers": {},
"extras": {},
"httpRootProperty": "location",
"locationTemplate": "",
"geofenceTemplate": "",
"persist": true,
"maxDaysToPersist": 1,
"maxRecordsToPersist": -1,
"locationsOrderDirection": "ASC",
"httpTimeout": 60000,
"geofenceProximityRadius": 1000,
"geofenceInitialTriggerEntry": true,
"stopOnTerminate": false,
"startOnBoot": true,
"heartbeatInterval": 300,
"foregroundService": true,
"notificationPriority": 0,
"notificationTitle": "",
"notificationText": "Location Service activated",
"notificationColor": "",
"notificationIcon": "",
"notificationSmallIcon": "",
"notificationLargeIcon": "",
"forceReloadOnLocationChange": false,
"forceReloadOnMotionChange": false,
"forceReloadOnGeofence": false,
"forceReloadOnBoot": false,
"forceReloadOnHeartbeat": false,
"forceReloadOnSchedule": false,
"stopAfterElapsedMinutes": 0,
"schedule": [],
"configureUrl": "",
"configureInterval": -1,
"debug": false,
"logLevel": 5,
"logMaxDays": 3
}

Additionally, opening the screen after noticing the location sensitivity stops. I got this error:

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to destroy activity {org.nativescript.appTestGeonew/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
Calling js method onDestroy failed

TypeError: Cannot read property 'getIntent' of undefined
File: "file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/tns-core-modules/ui/frame/frame.js, line: 663, column: 18

StackTrace:
Frame: function:'BackgroundGeolocation.init', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/nativescript-background-geolocation-lt/background-geolocation.js', line: 624, column: 48
Frame: function:'BackgroundGeolocation.getAdapter', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/nativescript-background-geolocation-lt/background-geolocation.js', line: 639, column: 18
Frame: function:'BackgroundGeolocation.onActivityDestroyed', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/nativescript-background-geolocation-lt/background-geolocation.js', line: 41, column: 14
Frame: function:'', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/nativescript-background-geolocation-lt/background-geolocation.js', line: 33, column: 27
Frame: function:'Observable.notify', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 103, column: 23
Frame: function:'', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/tns-core-modules/application/application.js', line: 181, column: 24
Frame: function:'ActivityCallbacksImplementation.onDestroy', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 663, column: 19
Frame: function:'NativeScriptActivity.onDestroy', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/tns-core-modules/ui/frame/activity.js', line: 36, column: 25

at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3888)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3906)
at android.app.ActivityThread.access$1600(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1435)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5555)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)

Caused by: com.tns.NativeScriptException:
Calling js method onDestroy failed

TypeError: Cannot read property 'getIntent' of undefined
File: "file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/tns-core-modules/ui/frame/frame.js, line: 663, column: 18

StackTrace:
Frame: function:'BackgroundGeolocation.init', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/nativescript-background-geolocation-lt/background-geolocation.js', line: 624, column: 48
Frame: function:'BackgroundGeolocation.getAdapter', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/nativescript-background-geolocation-lt/background-geolocation.js', line: 639, column: 18
Frame: function:'BackgroundGeolocation.onActivityDestroyed', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/nativescript-background-geolocation-lt/background-geolocation.js', line: 41, column: 14
Frame: function:'', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/nativescript-background-geolocation-lt/background-geolocation.js', line: 33, column: 27
Frame: function:'Observable.notify', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 103, column: 23
Frame: function:'', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/tns-core-modules/application/application.js', line: 181, column: 24
Frame: function:'ActivityCallbacksImplementation.onDestroy', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 663, column: 19
Frame: function:'NativeScriptActivity.onDestroy', file:'file:///data/data/org.nativescript.appTestGeonew/files/app/tns_modules/tns-core-modules/ui/frame/activity.js', line: 36, column: 25

at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
at com.tns.Runtime.callJSMethod(Runtime.java:957)
at com.tns.Runtime.callJSMethod(Runtime.java:941)
at com.tns.Runtime.callJSMethod(Runtime.java:933)
at com.tns.NativeScriptActivity.onDestroy(NativeScriptActivity.java:54)
at android.app.Activity.performDestroy(Activity.java:6528)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1143)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3875)
... 9 more

1.9.0-beta.3 released. Be sure to do this