Preventing background service blocking due to "excessive processor detection on a forked process"

I am debugging Android Syncthing wrapper issue . The Android application wraps its own binary file of the Syncthing project and provides some additional functions, such as start / stop based on WiFi connection, power, etc.

Unfortunately, there were problems with the service, and not with the automatic launch of the WiFi change, especially with phones that were updated to Android 6. Since my personal phone has been updated to version 6.0.1 recently, I can finally debug the question , and today I noticed the following:

07-06 20:52:26.562 1181 1363 I ActivityManager: [BgDetect]chkExcessCpu doKills: true uptime: 300309 07-06 20:52:26.960 1181 1363 I ActivityManager: [BgDetect]detect excessive cpu on forked process libsyncthing.so(pid : 2758) plan to stop it 371060 during 300309 07-06 20:52:26.960 1181 1363 I ActivityManager: [BgDetect]force stop com.nutomic.syncthingandroid.debug (uid 10132) 07-06 20:52:26.965 1181 1363 I ActivityManager: Force stopping com.nutomic.syncthingandroid.debug appid=10132 user=0: from pid 1181 07-06 20:52:26.966 1181 1363 I ActivityManager: Killing 1360:com.nutomic.syncthingandroid.debug/u0a132 (adj 15): stop com.nutomic.syncthingandroid.debug 07-06 20:52:26.968 1181 1363 W ActivityManager: Scheduling restart of crashed service com.nutomic.syncthingandroid.debug/com.nutomic.syncthingandroid.syncthing.SyncthingService in 1000ms 07-06 20:52:26.968 1181 1354 V ActivityManager: killProcessGroupAsync took 1 ms for PID 1360 on thread 14 07-06 20:52:26.971 1181 6410 I libprocessgroup: Killing pid 2758 in uid 10132 as part of process group 1360 07-06 20:52:26.973 1181 6410 I libprocessgroup: Killing pid 2758 in uid 10132 as part of process group 1360 07-06 20:52:26.974 1181 1363 I ActivityManager: Force stopping service ServiceRecord{47304c8 u0 com.nutomic.syncthingandroid.debug/com.nutomic.syncthingandroid.syncthing.SyncthingService} 

The Syncthing protocol is pretty heavy on the processor side, in terms of encryption, hashing, etc. Thus, it seems that the service is disabled forcibly because of the high demands on the processor of the bifurcated native binary file.

The app is already marked as "No battery optimization", but still they kill it. Is there a way to prevent ActivityManager due to forked process processor requirements?

+9
android native syncthing
source share
2 answers

Unfortunately, this is a OnePlus / OxygenOS feature that will kill any background process based on who knows which rules make it possible to improve battery life.

At the moment, I have found a workaround without code in the GitHub problem, which seems to help, but is far from ideal: withdraw / block the application on the recents screen .

+2
source share

I tested my priority service and realized that this is a performance problem, mainly with the processor. Thus, I enhanced performance with the profiler and added to the white list.

Reduced consumption of processor resources, RAM and battery and you're done.

Foreground notification service does not work on one device plus

0
source share

All Articles