termux / proot

An chroot-like implementation using ptrace.
https://wiki.termux.com/wiki/PRoot
Other
742 stars 162 forks source link

Can PRoot be used to help work around the Phantom Process Kill introduced in Android 12 #260

Open corbinlc opened 1 year ago

corbinlc commented 1 year ago

Problem description In Android 12, a phantom process killer started killing background processes if more than 32 total were in use. This has been discussed in quite a few places. Here is one example that also provides some known workarounds. https://github.com/agnostic-apollo/Android-Docs/blob/master/en/docs/apps/processes/phantom-cached-and-empty-processes.md

Steps to reproduce That same write up describes how to trigger the phantom process killer in Termux. https://github.com/agnostic-apollo/Android-Docs/blob/master/en/docs/apps/processes/phantom-cached-and-empty-processes.md#how-to-manually-trigger-phantom-process-killing-in-termux Running something complicated like a full DE will also trigger this (please note, the killer might not kill the process for a few seconds or minutes after the threshold is crossed)

Expected behavior Obviously we don't want our processes killed.

Additional information My curiosity is have you thought about using proot as a way to workaround this? The trick might involve making child processes look like an extension of the parent as opposed to a separate process. If possible, this would artificially reduce the number of seen child processes. This is something I am noodling on right now, but I am wondering what others think.

corbinlc commented 1 year ago

My initial thoughts are to play around with some of the flags with clone() but I am going to research a bit how Android keeps track of which processes are background processes compared to app processes. Possibilities would be like CLONE_PARENT or CLONE_THREAD