React-native-background-geolocation: App crash when using BackgroundGeolocation.stop()

Created on 19 Dec 2018  路  19Comments  路  Source: mauron85/react-native-background-geolocation


Your Environment


  • Plugin version: 0.5.0-alpha.50
  • Platform: Android
  • OS version: any
  • Device manufacturer and model: any
  • Running in Simulator: yes
  • React Native version: 0.52.0
  • Plugin configuration options:
  • Link to your project: yes

Context

On calling

BackgroundGeolocation.stop()

app got freezed then crash after sometime

Expected Behavior

BackgroundGeolocation service should stop without any side effects

Actual Behavior

App got freezed then crash after sometime

Possible Fix

Steps to Reproduce

On calling

BackgroundGeolocation.stop()

Context

Unable to stop background geolocation service

Debug logs

2018-12-19 17:16:24.167 1641-1654/? E/ActivityManager: ANR in drivezy.admin
PID: 23144
Reason: executing service drivezy.admin/com.marianhello.bgloc.service.LocationServiceImpl
Load: 1.7 / 1.43 / 0.99
CPU usage from 26372ms to 0ms ago (2018-12-19 17:15:56.983 to 2018-12-19 17:16:23.355):
10% 23144/drivezy.admin: 8.4% user + 2.4% kernel / faults: 4304 minor
5.1% 1299/surfaceflinger: 0.4% user + 4.6% kernel / faults: 1 minor
4.2% 1641/system_server: 2.2% user + 1.9% kernel / faults: 4819 minor
1.4% 1343/audioserver: 0.1% user + 1.2% kernel
1% 1972/com.google.android.gms.persistent: 0.8% user + 0.2% kernel / faults: 132 minor
0.6% 1935/adbd: 0.1% user + 0.5% kernel / faults: 1145 minor
0.4% 1715/com.android.systemui: 0.2% user + 0.2% kernel / faults: 3 minor
0.3% 22405/kworker/u5:2: 0% user + 0.3% kernel
0.2% 21036/kworker/u5:0: 0% user + 0.2% kernel
0.2% 1324/dmcrypt_write: 0% user + 0.2% kernel
0.1% 1840/com.android.phone: 0% user + 0.1% kernel / faults: 2 minor
0.1% 23112/kworker/0:0: 0% user + 0.1% kernel
0.1% 563/kswapd0: 0% user + 0.1% kernel
0.1% 1336/jbd2/dm-0-8: 0% user + 0.1% kernel
0% 3/ksoftirqd/0: 0% user + 0% kernel
0% 8/rcu_preempt: 0% user + 0% kernel
0% 1242/kworker/0:1H: 0% user + 0% kernel
0% 12/ksoftirqd/1: 0% user + 0% kernel
0% 1249/logd: 0% user + 0% kernel
0% 1298/servicemanager: 0% user + 0% kernel
0% 1352/netd: 0% user + 0% kernel / faults: 63 minor
0% 1434/dhcpclient: 0% user + 0% kernel
0% 22591/com.android.vending: 0% user + 0% kernel / faults: 14 minor
10% TOTAL: 5.6% user + 3.5% kernel + 0.3% iowait + 0.4% softirq
CPU usage from 303ms to 808ms later (2018-12-19 17:16:23.658 to 2018-12-19 17:16:24.163):
9.9% 1641/system_server: 7.9% user + 1.9% kernel / faults: 2593 minor
7.9% 2069/Binder:1641_8: 3.9% user + 3.9% kernel
1.9% 1648/FinalizerDaemon: 1.9% user + 0% kernel
5.7% 1935/adbd: 0% user + 5.7% kernel / faults: 572 minor
1.9% 1935/adbd: 0% user + 1.9% kernel
9% TOTAL: 4% user + 5% kernel

stale

All 19 comments

I have the same exact issue.

@hackyxicor Hi did you find any solution or workaround?

I have the same exact issue.

@hackyxicor Hi did you find any solution or workaround?

add a delay of at least 1 sec before the next action. And increase ping interval of location detection.

I did setTimeout(this.stopTracking.bind(this), 1000). Still crashes. These are my intervals

interval: 60000,
fastestInterval: 120000,
activitiesInterval: 100000

I did setTimeout(this.stopTracking.bind(this), 1000). Still crashes. These are my intervals

interval: 60000,
fastestInterval: 120000,
activitiesInterval: 100000

You have to add a timeout to any action/function call invoking just after stop tracking

Hi,

I'm having the same issue, the app says that it's not responding after calling BackgroundGeolocation.stop() on Android. @hackyxicor I'm not calling any other function before/after calling the stop function, but are there still some other functions that I should be aware of and add a timeout for them?

I have the same intervals as hari-devaraj and the same environment as you except I'm using RN 0.55.4.

Okay I'm not sure if this was clear but I tested with Oneplus 3T(running Android 8.0) and Samsung Galaxy Neo(running Android 6.0.1) and I had no problems calling the stop() function so at least for me the problem only seems to occur on simulators.

@joppeel
I am also having the same issue. My application not responding after calling BackgroundGeolocation.stop(). Have you found any solution? I have the Problem in real device too.

@dhrupalG Hi, I'm still having the problem on a simulator so unfortunately I haven't found any solution.

@dhrupalG Okay now I managed to produce this error on a real device and I solved it partially with hackyxicor's workaround(by setting timeouts), but the crash still occurs from time to time.

Okay now I managed to solve this problem for good, the Android Gradle Plugin that I was using forced the application to use a version of Android SDK Build-Tools which was different from the one that was specified in this plugin's documentation.

@joppeel can you post how solve this problem? I have same issue in a real device. :(

@WilliamPeralta So I think at least in my case the issue was due to the fact that I had specified the Android Gradle plugin that I was using like this:

dependencies {
  classpath 'com.android.tools.build:gradle:3.1.4'
}

This version(3.1.4) of the plugin forced the app to use the build tools version of 27.0.3, but as I was using the experimental Android Orio support, I needed to use the version 26.0.2 of the build tools as it is defined in this background tracking plugin's documentation like this:

ext {
  compileSdkVersion = 26
  targetSdkVersion = 26
  buildToolsVersion = "26.0.2"
  supportLibVersion = "26.1.0"
  googlePlayServicesVersion = "11.8.0"
  oreoEXPERIMENTAL = "yes"
}

So by downgrading to using Android Gradle plugin version 3.0.1 fixed this problem, since it allowed me to use the correct version of the build tools. I can't say if this is the only solution to the problem or whether it's a good or bad solution(I guess it depends on the case) but this is how I fixed it :)

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.

This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn't be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it's important. Thank you for your contributions.

Hi

App crashes on calling Background.stop() function,
please anyone help on this?

Adicione o seguinte em android/build.gradle:

ext {
googlePlayServicesVersion = "9.8.0"
}

Clear the Application storage.

Using following permission fixed it.
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

Was this page helpful?
0 / 5 - 0 ratings