react-native-background-fetch: Headless tasks acquire long-running PARTIAL_WAKE_LOCK and is killed on Nokia devices
Your Environment
- Plugin version: 2.4.1
- Platform: Android
- OS version: all
- Device manufacturer / model: Nokia 7 Plus
- React Native version (
react-native -v
): 0.51 - Plugin config { minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed) stopOnTerminate: false, // <-- Android-only, startOnBoot: true, // <-- Android-only enableHeadless: true }
Context
This is connected to the issue I was having with my background location tasks being force stopped on new Nokia devices (originally here: https://github.com/transistorsoft/react-native-background-geolocation-android/issues/469).
The key moment in the log is:
05-10 23:42:40.168 3515 22614 I [PowerSavingAppG3]WakelockCleanService: pkg = to.synced.synced
05-10 23:42:40.169 3515 22614 I PowerSavingAppG3: [PowerSavingUtils] isLauncherAP = to.synced.synced,true
05-10 23:42:40.170 1490 13577 I ActivityManager: Force stopping to.synced.synced appid=10201 user=0: from pid 3515
05-10 23:42:40.170 1490 13577 I ActivityManager: Killing 5386:to.synced.synced/u0a201 (adj 905): stop to.synced.synced
05-10 23:42:40.179 1490 13577 I ActivityManager: Force finishing activity ActivityRecord{81ff8d u0 to.synced.synced/.MainActivity t11}
I had turned off background-geolocation
and so the only fetch location tasks running are then ones run via background-fetch
. And my app was still getting force stopped.
After looking through logs further, and I think the issue might be to do with my background-fetch
headless task acquiring a PARTIAL_WAKE_LOCK
that it doesn’t seem to release promptly.
Here are some occurrences of PARTIAL_WAKE_LOCK
. Notice the length of time background-fetch has acquired the lock, it is orders of magnitude above any other app.
So the app is being killed not because of a foreground service, but because of a headless task (node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/HeadlessJsTaskService.java
is the only place grep -r PARTIAL_WAKE_LOCK
gave )
05-10 22:28:22.405 1490 2249 D PowerManagerService: WAKE_LOCK_SCREEN_BRIGHT Change, Total ACQUIRED:
05-10 22:28:22.405 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK '*job*/to.synced.synced/com.transistorsoft.tsbackgroundfetch.FetchJobService' ACQ=-5m9s914ms LONG (uid=1000 pid=1490 ws=WorkSource{10201})
05-10 22:28:22.405 1490 2249 D PowerManagerService: DOZE_WAKE_LOCK 'DreamManagerService' ACQ=-3m28s29ms (uid=1000 pid=1490)
05-10 22:28:22.405 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK 'WhatsApp VoiceService' ACQ=-991ms (uid=10186 pid=7822)
05-10 22:28:22.405 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK 'GOOGLE_C2DM' ACQ=-983ms (uid=10091 pid=3380 ws=WorkSource{10186 com.whatsapp})
05-10 22:28:22.405 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK '*vibrator*' ACQ=-253ms (uid=1000 pid=1490 ws=WorkSource{10186})
05-10 22:28:22.405 1490 2249 D PowerManagerService: SCREEN_BRIGHT_WAKE_LOCK 'WindowManager' ON_AFTER_RELEASE (uid=1000 pid=1490 ws=WorkSource{10186})
05-10 22:28:22.413 1490 2249 I PowerManagerService: Waking up from dozing (uid 1000)...
05-10 22:28:22.632 1490 2249 D PowerManagerService: WAKE_LOCK_SCREEN_BRIGHT Change, Total ACQUIRED:
05-10 22:28:22.632 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK '*job*/to.synced.synced/com.transistorsoft.tsbackgroundfetch.FetchJobService' ACQ=-5m10s142ms LONG (uid=1000 pid=1490 ws=WorkSource{10201})
05-10 22:28:22.632 1490 2249 D PowerManagerService: DOZE_WAKE_LOCK 'DreamManagerService' ACQ=-3m28s256ms (uid=1000 pid=1490)
05-10 22:28:22.632 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK 'WhatsApp VoiceService' ACQ=-1s218ms (uid=10186 pid=7822)
05-10 22:28:22.632 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK 'GOOGLE_C2DM' ACQ=-1s210ms (uid=10091 pid=3380 ws=WorkSource{10186 com.whatsapp})
05-10 22:28:22.632 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK '*vibrator*' ACQ=-480ms (uid=1000 pid=1490 ws=WorkSource{10186})
05-10 22:28:22.632 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK 'RILJ_ACK_WL' ACQ=-169ms (uid=1001 pid=2704)
05-10 22:28:22.632 1490 2249 D PowerManagerService: SCREEN_BRIGHT_WAKE_LOCK 'WindowManager' ON_AFTER_RELEASE (uid=1000 pid=1490 ws=WorkSource{10186})
05-10 22:28:22.638 1490 1655 I DisplayPowerController: Unblocked screen on after 217 ms
05-10 23:07:51.255 1490 3561 D PowerManagerService: WAKE_LOCK_SCREEN_BRIGHT Change, Total ACQUIRED:
05-10 23:07:51.255 1490 3561 D PowerManagerService: PARTIAL_WAKE_LOCK '*job*/to.synced.synced/com.transistorsoft.tsbackgroundfetch.FetchJobService' ACQ=-1m6s403ms LONG (uid=1000 pid=1490 ws=WorkSource{10201})
05-10 23:07:51.255 1490 3561 D PowerManagerService: PARTIAL_WAKE_LOCK '*launch*' ACQ=-537ms (uid=1000 pid=1490 ws=WorkSource{10186})
05-10 23:07:51.255 1490 3561 D PowerManagerService: PARTIAL_WAKE_LOCK 'AudioMix' ACQ=-289ms (uid=1041)
05-10 23:07:51.255 1490 3561 D PowerManagerService: PARTIAL_WAKE_LOCK 'AudioIn' ACQ=-10ms (uid=1041)
05-10 23:07:51.255 1490 3561 D PowerManagerService: PARTIAL_WAKE_LOCK 'AudioMix' ACQ=-32ms (uid=1041)
05-10 23:07:51.255 1490 3561 D PowerManagerService: SCREEN_BRIGHT_WAKE_LOCK 'WindowManager' ON_AFTER_RELEASE (uid=1000 pid=1490 ws=WorkSource{10186})
05-10 23:08:03.112 1490 1490 V Telecom : Logging: No stale logging sessions needed to be cleaned...
05-10 23:08:03.519 1490 2249 D PowerManagerService: WAKE_LOCK_SCREEN_BRIGHT Change, RELEASE:
05-10 23:08:03.520 1490 2249 D PowerManagerService: SCREEN_BRIGHT_WAKE_LOCK 'WindowManager' ON_AFTER_RELEASE ACQ=-12s264ms (uid=1000 pid=1490 ws=WorkSource{10186})
05-10 23:08:04.622 1490 3561 D ActivityManager: userId2 =0
05-10 23:08:04.623 1490 3561 D ActivityManager: resolveActivity - rInfo =ResolveInfo{e95d873 com.whatsapp/.MediaView m=0x0}
05-10 23:08:04.623 1490 3561 I ActivityManager: START u0 {cmp=com.whatsapp/.MediaView (has extras)} from uid 10186
05-10 23:08:04.911 1490 6378 D PowerManagerService: WAKE_LOCK_SCREEN_BRIGHT Change, Total ACQUIRED:
05-10 23:08:04.911 1490 6378 D PowerManagerService: PARTIAL_WAKE_LOCK '*job*/to.synced.synced/com.transistorsoft.tsbackgroundfetch.FetchJobService' ACQ=-1m20s58ms LONG (uid=1000 pid=1490 ws=WorkSource{10201})
05-10 23:08:04.911 1490 6378 D PowerManagerService: PARTIAL_WAKE_LOCK 'AudioMix' ACQ=-21ms (uid=1041 ws=WorkSource{10186})
05-10 23:08:04.911 1490 6378 D PowerManagerService: PARTIAL_WAKE_LOCK 'AudioMix' ACQ=-118ms (uid=1041)
05-10 23:08:04.911 1490 6378 D PowerManagerService: PARTIAL_WAKE_LOCK '*launch*' ACQ=-279ms (uid=1000 pid=1490 ws=WorkSource{10186})
05-10 23:08:04.911 1490 6378 D PowerManagerService: PARTIAL_WAKE_LOCK 'AudioIn' ACQ=-37ms (uid=1041)
05-10 23:08:04.911 1490 6378 D PowerManagerService: SCREEN_BRIGHT_WAKE_LOCK 'WindowManager' ON_AFTER_RELEASE (uid=1000 pid=1490 ws=WorkSource{10186})
05-10 23:11:13.411 1490 2249 D PowerManagerService: WAKE_LOCK_SCREEN_BRIGHT Change, Total ACQUIRED:
05-10 23:11:13.411 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK '*job*/to.synced.synced/com.transistorsoft.tsbackgroundfetch.FetchJobService' ACQ=-4m28s559ms LONG (uid=1000 pid=1490 ws=WorkSource{10201})
05-10 23:11:13.411 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK 'AudioMix' ACQ=-3m8s522ms LONG (uid=1041 ws=WorkSource{10186})
05-10 23:11:13.411 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK 'SCREEN_FROZEN' ACQ=-244ms (uid=1000 pid=1490)
05-10 23:11:13.411 1490 2249 D PowerManagerService: PARTIAL_WAKE_LOCK 'AudioIn' ACQ=-50ms (uid=1041)
05-10 23:11:13.411 1490 2249 D PowerManagerService: SCREEN_BRIGHT_WAKE_LOCK 'WindowManager' ON_AFTER_RELEASE (uid=1000 pid=1490 ws=WorkSource{10186})
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (12 by maintainers)
I’m not American, I’m Canadian 😃