防止后台服务因“检测到派生进程中的CPU过多"而被杀死.

编程入门 行业动态 更新时间:2024-10-28 20:24:15
本文介绍了防止后台服务因“检测到派生进程中的CPU过多"而被杀死.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在调试问题: //github/syncthing/syncthing-android"rel =" noreferrer>同步Android 包装器. Android应用程序包装了Syncthing项目的本机二进制文件,并提供了一些其他功能,例如基于连接的WiFi,电源等来启动/停止.

I am debugging an issue of the Syncthing Android wrapper. The Android application wraps a native binary of the Syncthing project and provides some additional functionality like starting/stopping based on connecting WiFi, power, etc.

不幸的是,出现了服务无法通过WiFi更改自动启动的问题,尤其是在已升级到Android 6的手机上.由于我的个人手机最近已升级到6.0.1,因此我终于能够调试问题,今天我注意到以下内容:

Unfortunately, there have been issues about the service not auto-starting on WiFi change anymore, especially with handsets that have been upgraded to Android 6. Since my personal handset has been upgraded to 6.0.1 recently, I finally am able to debug into the issue 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}

在加密,哈希等方面,Syncthing协议在CPU方面非常繁琐.因此,由于派生的本机二进制文件对CPU的要求很高,因此该服务被迫停止.

The Syncthing protocol is quite heavy on the CPU side, regarding encryption, hashing, etc. So it seems that the service is force-stopped due to the high CPU demands of the forked native binary.

该应用程序已被标记为无电池优化",但仍然被杀死.有没有办法防止ActivityManager由于派生进程的CPU需求而终止应用程序?

The application is already marked as "No battery optimization", but still it is being killed. Is there a way to prevent the ActivityManager from killing the application due to the CPU demands of the forked process?

推荐答案

不幸的是,这是OnePlus/OxygenOS功能,它将基于谁知道什么规则终止任何后台进程,从而使电池寿命更长.

Unfortunately, this is a OnePlus / OxygenOS feature that will kill any background process based on who-knows what rules in order to give the appearance of a better battery life.

就目前而言,我在 GitHub问题中找到了一种非代码的解决方法似乎有帮助,但远非理想:在最近"屏幕上固定/锁定应用程序.

For now, I found a non-code workaround in a GitHub issue that seems to help, but is far from ideal: pin/lock the application on the recents screen.

更多推荐

防止后台服务因“检测到派生进程中的CPU过多"而被杀死.

本文发布于:2023-11-27 05:53:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636858.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:被杀   检测到   后台   进程   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!