React-native-background-geolocation: Background tracking doesnt work after android phone reboot in 0.5.0-alpha.50

Created on 9 Jan 2019  Â·  18Comments  Â·  Source: mauron85/react-native-background-geolocation

Hi. Background tracking isn't started on android after phone reboot in version 0.5.0-alpha.50, but it works fine in 0.5.0-alpha.48.
I think it was broken in this commit. mauron85/background-geolocation-android@aa0f20e


Your Environment


  • Plugin version: 0.5.0-alpha.50
  • Platform: Android
  • OS version: 6.0
  • Device manufacturer and model: sony xperia x dual
  • Running in Simulator: No
  • React Native version: 0.55.0
  • Plugin configuration options:
{
  desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,
  stationaryRadius: 5,
  distanceFilter: 5,
  debug: false,
  startOnBoot: true,
  startForeground: true,
  stopOnTerminate: false,
  locationProvider: Platform.select({
    android: BackgroundGeolocation.ACTIVITY_PROVIDER,
    ios: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER,
  }),
  fastestInterval: 3000,
  activitiesInterval: 5000,
  stopOnStillActivity: false,
  maxLocations: 50000,
  url: `${config.baseUrl}/track`,
  postTemplate: {
    latitude: "@latitude",
    longitude: "@longitude",
    altitude: "@altitude",
    timeUTC: "@time",
    accuracy: "@accuracy",
    speed: "@speed",
  },
  interval: 10000,
  syncUrl: `${config.baseUrl}/track-sync`,
  syncThreshold: 25,
  httpHeaders: {
        Authorization: `Bearer ${token}`,
        "app-version": VERSION,
   },
}
stale

Most helpful comment

I have tested another time on android 6 (sony xperia x dual). It woks in 0.5.0-alpha.48 and doesnt work in 0.5.0-alpha.50. Http post request isnt send and there isn't service's notification after reboot. @mauron85 Could you reproduce it?
I think it was broken in this commit. https://github.com/mauron85/background-geolocation-android/commit/aa0f20e26056a8f74c93cbbf77a9ae970b303587

src/preoreo/java/com/marianhello/bgloc/BootCompletedReceiver.java
Intent locationServiceIntent = new Intent(context, LocationServiceImpl.class);

All 18 comments

Do you have any log?

It's release build (It should work the same in debug build). Logcat after phone reboot filtered by com.marianhello. There is an error.

01-21 18:13:41.478 3259-3325/? I/ActivityManager: Start proc 5353:com.abcfinder:sync/u0a123 for service com.abcfinder/com.marianhello.bgloc.sync.SyncService
01-21 18:13:41.795 3259-3325/? I/ActivityManager: Start proc 5426:com.abcfinder/u0a123 for content provider com.abcfinder/com.marianhello.bgloc.data.provider.LocationContentProvider
01-21 18:13:42.114 5353-5423/? D/com.marianhello.bgloc.sync.SyncAdapter: Sync request isForced: false, batchId: 1548083622103, config: Config[distanceFilter=5 stationaryRadius=5.0 desiredAccuracy=0 interval=30000 fastestInterval=3000 activitiesInterval=5000 isDebugging=false stopOnTerminate=false stopOnStillActivity=false startOnBoot=true startForeground=true notificationsEnabled=true locationProvider=1 nTitle=Fam Finder nText=Background tracking nIconLarge= nIconSmall= nIconColor= url=https://spoten-api.digisoapps.com/api/track syncUrl=https://spoten-api.digisoapps.com/api/track-sync syncThreshold=25 httpHeaders={Authorization=Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvc3BvdGVuLWFwaS5kaWdpc29hcHBzLmNvbSIsImF1ZCI6Imh0dHBzOlwvXC9zcG90ZW4tYXBpLmRpZ2lzb2FwcHMuY29tIiwiaWF0IjoxNTQ4MDc1Nzg4LCJuYmYiOjE1NDgwNzU3ODgsImp0aSI6MTU1OX0.ESaQjJPeCBDoc25HLk-lIucm2tMiDrjTvfWbz3rkuyA, app-version=1.3.2} maxLocations=50000 postTemplate={"altitude":"@altitude","latitude":"@latitude","accuracy":"@accuracy","timeUTC":"@time","speed":"@speed","longitude":"@longitude"}]
01-21 18:13:42.116 5353-5423/? I/com.marianhello.bgloc.sync.BatchManager: Creating batch 1548083622103
01-21 18:13:42.144 5353-5423/? I/com.marianhello.bgloc.sync.SyncAdapter: Nothing to sync
01-21 18:13:52.437 5426-5426/? D/com.marianhello.bgloc.BootCompletedReceiver: Received boot completed
01-21 18:13:52.443 5426-5426/? D/com.marianhello.bgloc.BootCompletedReceiver: Boot completed Config[distanceFilter=5 stationaryRadius=5.0 desiredAccuracy=0 interval=30000 fastestInterval=3000 activitiesInterval=5000 isDebugging=false stopOnTerminate=false stopOnStillActivity=false startOnBoot=true startForeground=true notificationsEnabled=true locationProvider=1 nTitle=Fam Finder nText=Background tracking nIconLarge= nIconSmall= nIconColor= url=https://spoten-api.digisoapps.com/api/track syncUrl=https://spoten-api.digisoapps.com/api/track-sync syncThreshold=25 httpHeaders={Authorization=Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvc3BvdGVuLWFwaS5kaWdpc29hcHBzLmNvbSIsImF1ZCI6Imh0dHBzOlwvXC9zcG90ZW4tYXBpLmRpZ2lzb2FwcHMuY29tIiwiaWF0IjoxNTQ4MDc1Nzg4LCJuYmYiOjE1NDgwNzU3ODgsImp0aSI6MTU1OX0.ESaQjJPeCBDoc25HLk-lIucm2tMiDrjTvfWbz3rkuyA, app-version=1.3.2} maxLocations=50000 postTemplate={"altitude":"@altitude","latitude":"@latitude","accuracy":"@accuracy","timeUTC":"@time","speed":"@speed","longitude":"@longitude"}]
01-21 18:13:52.444 5426-5426/? I/com.marianhello.bgloc.BootCompletedReceiver: Starting service after boot
01-21 18:13:52.466 5426-5426/? I/com.marianhello.bgloc.service.LocationServiceImpl: Creating LocationServiceImpl
01-21 18:13:52.472 5426-5426/? I/com.marianhello.bgloc.PostLocationTask: Creating PostLocationTask
01-21 18:13:52.475 5426-6930/? I/com.marianhello.bgloc.service.LocationServiceImpl: Network condition changed has connectivity: true
01-21 18:13:52.476 5426-5426/? D/com.marianhello.bgloc.service.LocationServiceImpl: Service in [NOT STARTED] state. cmdId: [N/A]. startId: [1]
01-21 18:14:02.452 3259-3323/? W/ActivityManager: Bringing down service while still waiting for start foreground: ServiceRecord{82a29b5 u0 com.abcfinder/com.marianhello.bgloc.service.LocationServiceImpl}
01-21 18:14:02.456 5426-5426/? I/com.marianhello.bgloc.service.LocationServiceImpl: Destroying LocationServiceImpl
01-21 18:14:02.668 3259-3323/? E/ActivityManager: ANR in com.abcfinder
    PID: 5426
    Reason: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{82a29b5 u0 com.abcfinder/com.marianhello.bgloc.service.LocationServiceImpl}
    Load: 0.0 / 0.0 / 0.0
    CPU usage from 26627ms to 0ms ago (2019-01-21 18:13:35.829 to 2019-01-21 18:14:02.455):
      68% 3259/system_server: 46% user + 22% kernel / faults: 41821 minor 155 major
      14% 4472/adbd: 2.9% user + 11% kernel / faults: 607823 minor
      6.7% 572/[email protected]: 6.4% user + 0.3% kernel / faults: 6368 minor 4 major
      9.6% 3872/com.google.android.inputmethod.latin: 8% user + 1.5% kernel / faults: 23683 minor 46 major
      6.9% 3886/com.android.systemui: 5.9% user + 1% kernel / faults: 12762 minor 9 major
      4% 2530/zygote64: 0.6% user + 3.4% kernel / faults: 9964 minor
      3.3% 2519/surfaceflinger: 1.9% user + 1.3% kernel / faults: 111 minor
      3.1% 459/logd: 1.1% user + 2% kernel / faults: 98 minor
      2.3% 421/mmc-cmdqd/0: 0% user + 2.3% kernel
      2.3% 4155/com.android.phone: 1.4% user + 0.9% kernel / faults: 2326 minor 23 major
      2.2% 2532/audioserver: 1.5% user + 0.7% kernel / faults: 273 minor 11 major
      1.9% 575/[email protected]: 1% user + 0.8% kernel / faults: 4 minor
      1.6% 440/ueventd: 1.2% user + 0.4% kernel / faults: 2 minor
      1.3% 465/servicemanager: 0.3% user + 1% kernel
      1.3% 565/[email protected]: 0.8% user + 0.4% kernel / faults: 51 minor 10 major
      1.2% 2536/installd: 0.7% user + 0.4% kernel
      1.1% 581/[email protected]: 0.4% user + 0.6% kernel / faults: 1 minor
      0.7% 2588/mm-pp-dpps: 0.2% user + 0.5% kernel / faults: 13 minor
      0.7% 2511/jbd2/dm-1-8: 0% user + 0.7% kernel
      0.7% 605/lmkd: 0.1% user + 0.5% kernel
      0.6% 2389/kworker/u17:0: 0% user + 0.6% kernel
      0.6% 2486/kworker/u16:4: 0% user + 0.6% kernel
      0.6% 2550/statsd: 0.4% user + 0.1% kernel / faults: 4 minor
      0.6% 3915/VosMCThread: 0% user + 0.6% kernel
      0.5% 2502/kworker/u17:3: 0% user + 0.5% kernel
      0.5% 3916/VosTXThread: 0% user + 0.5% kernel
      0.5% 2390/kworker/u17:1: 0% user + 0.5% kernel
      0.4% 2348/kworker/u16:1: 0% user + 0.4% kernel
      0.4% 2504/kworker/u17:5: 0% user + 0.4% kernel
      0.4% 2506/kworker/u17:7: 0% user + 0.4% kernel
      0.4% 2507/kworker/u17:8: 0% user + 0.4% kernel
      0.4% 2531/zygote: 0.1% user + 0.3% kernel / faults: 1127 minor
      0.4% 3917/VosRXThread: 0% user + 0.4% kernel
      0.2% 89/kworker/u16:2: 0% user + 0.2% kernel
      0.4% 264/kgsl_worker_thr: 0% user + 0.4% kernel
      0.4% 2542/netd: 0.1% user + 0.3% kernel / faults: 198 minor 1 major
      0.4% 576/[email protected]: 0.1% user + 0.2% kernel
      0.2% 2446/kworker/5:0: 0% user + 0.2% kernel
      0.4% 2505/kworker/u17:6: 0% user + 0.4% kernel
      0.3% 564/healthd: 0% user + 0.3% kernel
      0.3% 2338/kworker/5:1: 0% user + 0.3% kernel
      0.3% 2476/mdss_fb0: 0% user + 0.3% kernel
      0.3% 4098/.dataservices: 0.3% user + 0% kernel / faults: 812 minor 2 major
      0.2% 487/[email protected]: 0% user + 0.1% kernel / faults: 134 minor 2 major
      0.3% 2529/hvdcp_opti: 0% user + 0.2% kernel
      0.3% 2746/qcrild: 0.2% user + 0% kernel / faults: 80 minor 4 major
      0.3% 2795/netmgrd: 0% user + 0.3% kernel / faults: 864 minor 1 major
      0.3% 7/rcu_preempt: 0% user + 0.3% kernel
      0.3% 2501/kworker/u17:2: 0% user + 0.3% kernel
      0.3% 4279/com.qualcomm.qcrilmsgtunnel: 0.1% user + 0.1% kernel / faults: 306 minor
      0.2% 2503/kworker/u17:4: 0% user + 0.2% kernel
      0.2% 4129/se.dirac.acs: 0.2% user + 0% kernel / faults: 1976 minor 2 major
      0.2% 8/rcu_sched: 0% user + 0.2% kernel
      0.2% 45/rcuop/4: 0% user + 0.2% kernel
      0.2% 584/[email protected]: 0% user + 0.1% kernel / faults: 388 minor
      0.2% 2537/keystore: 0% user + 0.1% kernel / faults: 42 minor 2 major
      0.1% 61/rcuop/6: 0% user + 0.1% kernel
      0.1% 466/hwservicemanager: 0% user + 0.1% kernel / faults: 12 minor
      0.1% 587/[email protected]: 0.1% user + 0% kernel / faults: 192 minor 9 major
      0.1% 2500/kworker/6:2: 0% user + 0.1% kernel
      0

You need to build with oreo sdk to support start on boot on oreo devices. Here is the line that is checking if building with oreo sdk

https://github.com/mauron85/background-geolocation-android/blob/19a9972b46eee4e176c6de3e523ce70e2b8d5fae/src/oreo/java/com/marianhello/bgloc/BootCompletedReceiver.java#L53

Thank you for quick answer. I will try with oreo sdk and comment here.

I tested it on android 6 (sony xperia x dual). There is another issue.

01-22 10:55:56.146 1275-4229/? I/ActivityManager: Start proc 8007:com.abcfinder/u0a292 for broadcast com.abcfinder/com.marianhello.bgloc.BootCompletedReceiver
01-22 10:55:56.644 8007-8007/com.abcfinder D/com.marianhello.bgloc.BootCompletedReceiver: Received boot completed
01-22 10:55:56.672 8007-8007/com.abcfinder D/com.marianhello.bgloc.BootCompletedReceiver: Boot completed Config[distanceFilter=5 stationaryRadius=5.0 desiredAccuracy=0 interval=30000 fastestInterval=3000 activitiesInterval=5000 isDebugging=false stopOnTerminate=false stopOnStillActivity=false startOnBoot=true startForeground=true notificationsEnabled=true locationProvider=1 nTitle=Fam Finder nText=Background tracking nIconLarge= nIconSmall= nIconColor= url=http://spoten-api-stage.digisoapps.com/api/track syncUrl=http://spoten-api-stage.digisoapps.com/api/track-sync syncThreshold=25 httpHeaders={app-version=1.3.2, Authorization=Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9zcG90ZW4tYXBpLXN0YWdlLmRpZ2lzb2FwcHMuY29tIiwiYXVkIjoiaHR0cDpcL1wvc3BvdGVuLWFwaS1zdGFnZS5kaWdpc29hcHBzLmNvbSIsImlhdCI6MTU0ODE0MzYzMSwibmJmIjoxNTQ4MTQzNjMxLCJqdGkiOjMwfQ.Y7CQ6A5jnrIgu7ej_augF4dR5J164vFerN9W_d65A_g} maxLocations=50000 postTemplate={"altitude":"@altitude","latitude":"@latitude","timeUTC":"@time","speed":"@speed","accuracy":"@accuracy","longitude":"@longitude"}]
01-22 10:55:56.672 8007-8007/com.abcfinder I/com.marianhello.bgloc.BootCompletedReceiver: Starting service after boot
01-22 10:55:56.758 8007-8007/com.abcfinder I/com.marianhello.bgloc.service.LocationServiceImpl: Creating LocationServiceImpl
01-22 10:55:56.779 8007-8007/com.abcfinder I/com.marianhello.bgloc.PostLocationTask: Creating PostLocationTask
01-22 10:55:56.797 8007-8007/com.abcfinder D/com.marianhello.bgloc.service.LocationServiceImpl: Service in [NOT STARTED] state. cmdId: [N/A]. startId: [1]
01-22 10:55:56.797 8007-8057/com.abcfinder I/com.marianhello.bgloc.service.LocationServiceImpl: Network condition changed has connectivity: true
01-22 10:56:11.691 1275-1302/? I/ActivityManager: Waited long enough for: ServiceRecord{42f3510 u0 com.abcfinder/com.marianhello.bgloc.service.LocationServiceImpl}

Where do you see issue?

On Tue, 22 Jan 2019 at 09:01, Stanislav Mayorov notifications@github.com
wrote:

I tested it on android 6 (sony xperia x dual). There is another issue.

01-22 10:55:56.146 1275-4229/? I/ActivityManager: Start proc 8007:com.abcfinder/u0a292 for broadcast com.abcfinder/com.marianhello.bgloc.BootCompletedReceiver
01-22 10:55:56.644 8007-8007/com.abcfinder D/com.marianhello.bgloc.BootCompletedReceiver: Received boot completed
01-22 10:55:56.672 8007-8007/com.abcfinder D/com.marianhello.bgloc.BootCompletedReceiver: Boot completed Config[distanceFilter=5 stationaryRadius=5.0 desiredAccuracy=0 interval=30000 fastestInterval=3000 activitiesInterval=5000 isDebugging=false stopOnTerminate=false stopOnStillActivity=false startOnBoot=true startForeground=true notificationsEnabled=true locationProvider=1 nTitle=Fam Finder nText=Background tracking nIconLarge= nIconSmall= nIconColor= url=http://spoten-api-stage.digisoapps.com/api/track syncUrl=http://spoten-api-stage.digisoapps.com/api/track-sync syncThreshold=25 httpHeaders={app-version=1.3.2, Authorization=Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9zcG90ZW4tYXBpLXN0YWdlLmRpZ2lzb2FwcHMuY29tIiwiYXVkIjoiaHR0cDpcL1wvc3BvdGVuLWFwaS1zdGFnZS5kaWdpc29hcHBzLmNvbSIsImlhdCI6MTU0ODE0MzYzMSwibmJmIjoxNTQ4MTQzNjMxLCJqdGkiOjMwfQ.Y7CQ6A5jnrIgu7ej_augF4dR5J164vFerN9W_d65A_g} maxLocations=50000 postTemplate={"altitude":"@altitude","latitude":"@latitude","timeUTC":"@time","speed":"@speed","accuracy":"@accuracy","longitude":"@longitude"}]
01-22 10:55:56.672 8007-8007/com.abcfinder I/com.marianhello.bgloc.BootCompletedReceiver: Starting service after boot
01-22 10:55:56.758 8007-8007/com.abcfinder I/com.marianhello.bgloc.service.LocationServiceImpl: Creating LocationServiceImpl
01-22 10:55:56.779 8007-8007/com.abcfinder I/com.marianhello.bgloc.PostLocationTask: Creating PostLocationTask
01-22 10:55:56.797 8007-8007/com.abcfinder D/com.marianhello.bgloc.service.LocationServiceImpl: Service in [NOT STARTED] state. cmdId: [N/A]. startId: [1]
01-22 10:55:56.797 8007-8057/com.abcfinder I/com.marianhello.bgloc.service.LocationServiceImpl: Network condition changed has connectivity: true
01-22 10:56:11.691 1275-1302/? I/ActivityManager: Waited long enough for: ServiceRecord{42f3510 u0 com.abcfinder/com.marianhello.bgloc.service.LocationServiceImpl}

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/mauron85/react-native-background-geolocation/issues/345#issuecomment-456304615,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAV8GuHxJV2KEIRO6ZTS1VpWL3FJM10Kks5vFsVBgaJpZM4Z32Vd
.

>

S pozdravom,

Marián Hello
freelance programmer

About.me http://about.me/marian.hello | LinkedIn
https://www.linkedin.com/in/marianhello/ | Twitter
http://twitter.com/mauron85

In case of sensitive data, please consider using encryption using my public
PGP key https://keybase.io/mauron85/key.asc.

Http post request isnt send and there isn't service's notification after reboot. I have monitored traffic using charles.

I have tested another time on android 6 (sony xperia x dual). It woks in 0.5.0-alpha.48 and doesnt work in 0.5.0-alpha.50. Http post request isnt send and there isn't service's notification after reboot. @mauron85 Could you reproduce it?
I think it was broken in this commit. https://github.com/mauron85/background-geolocation-android/commit/aa0f20e26056a8f74c93cbbf77a9ae970b303587

src/preoreo/java/com/marianhello/bgloc/BootCompletedReceiver.java
Intent locationServiceIntent = new Intent(context, LocationServiceImpl.class);

Hi @mauron85. Do you have any updates for the issue?
Or maybe you could help me to investigate. I'd do pull request if i could fix it.

Hello bro, im having the same problem, you found a solution?

Hi. No, we didn't fix it.

and how i install version 0.5.0-alpha.48 that you say that works fine?

you can use previous deprecated npm package to install this version. https://www.npmjs.com/package/react-native-mauron85-background-geolocation

but 0.5.0-alpha.48 doesn't work when the app is terminated on ios.

Thanks man, it will serve for my project for now.

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.

Was this page helpful?
0 / 5 - 0 ratings