Closed segfault-bilibili closed 3 weeks ago
I changed max_phantom_processes
to 1
and rebooted my phone (Xiaomi Redmi K40, aka "alioth", running Android-13-based LineageOS 20)
Then I observed these lines in logcat | grep PhantomProcess | grep naive
06-09 15:23:21.597 1807 1876 I ActivityManager: Killing PhantomProcessRecord {159acd9 15309:11261:libnaive.so/
u0a18}: Trimming phantom processes
06-09 15:23:21.607 1807 1878 I ActivityManager: Process PhantomProcessRecord {159acd9 15309:11261:libnaive.so/
u0a18} died
Possibly related: https://github.com/shadowsocks/shadowsocks-android/pull/594
(I guess nb4a already inherited the GuardedProcess auto-restart mechanism 😂)
Google introduced a mechanism called "phantom process monitoring" since Android 12, without documenting it anywhere.
The lead developer of Termux was probably the first to make efforts to address this issue: https://github.com/agnostic-apollo/Android-Docs/blob/master/en/docs/apps/processes/phantom-cached-and-empty-processes.md
He also opened an issue thread at google's issue tracker.
(However unfortunately this change has already been made and even if Google could reverse it in the future there would still remain millions of devices being affected, let alone the fact that Google clearly does not want to reverse it)
Then how this could affect NekoBox for Android?
In the SagerNet era, I experienced connection loss with naive-plugin, when I was downloading gigabytes of data.
I now suspect that it's possible (or maybe I'm simply wrong) that the native process was trimmed by the system's phantom process killer.
Unfortunately I didn't keep log for that. However I still want to ask a question: is NekoBox affected by this issue?
Here, to me it seems that NekoBox is launching processes exactly in the "phantom" way.
https://github.com/MatsuriDayo/NekoBoxForAndroid/blob/1b022eb2f1d6a939531d8ccdc5b3fa5495f1a2ee/app/src/main/java/io/nekohasekai/sagernet/bg/GuardedProcessPool.kt#L39-L43