mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
Run a session's programs as ordinary children when the child-process limit is off
Since #3338 every session hands its programs to :gN worker processes, so a game runs as 40 or more processes of the app. Cocoon's enhanced access (3.11 and 3.12) snapshots a player through its app processes and gives up above 32 ("Too many player processes"), so Home no longer pauses a game it launched: no Resume or Close, no game frame, and play logging stops. The workers only matter while Android counts the session's children. With the limit off, which Steam required before #3338, the session runs as one app process again. Producer acquire fences still get their worker, as they need gamescope in one.
This commit is contained in:
1 parent
b072cedd16
commit
eb2a3202c9
3 files changed
+27
-1
No files matched your search
@@ -64,6 +64,19 @@ object PhantomProcessLimit {
|
||||
PhantomProcessStatus.UNCOUNTED else status
|
||||
}
|
||||
|
||||
/** The limit as the device sets it, whether or not the session keeps its programs out of the count. */
|
||||
fun setting(context: Context, sdk: Int = Build.VERSION.SDK_INT): PhantomProcessStatus =
|
||||
if (sdk < Build.VERSION_CODES.S) PhantomProcessStatus.NOT_APPLICABLE else readSetting(context, sdk)
|
||||
|
||||
/**
|
||||
* Whether the session should run its programs in worker processes. Each worker is a process of
|
||||
* the app, and frontends that track the app's processes (Cocoon gives up above 32) lose a game
|
||||
* that runs in dozens, so with the limit off they run as ordinary children. Producer acquire
|
||||
* fences need gamescope in a worker.
|
||||
*/
|
||||
fun workersWanted(setting: PhantomProcessStatus, producerFences: Boolean): Boolean =
|
||||
setting != PhantomProcessStatus.DISABLED || producerFences
|
||||
|
||||
private fun readSetting(context: Context, sdk: Int): PhantomProcessStatus {
|
||||
if (usesDeviceConfig(sdk)) {
|
||||
val off = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getBoolean(PREF_ANDROID_12_OFF, false)
|
||||
|
||||
@@ -407,7 +407,10 @@ object GuestWorkers {
|
||||
fun enabled(context: Context): Boolean = handoffAllowed(context) && NativeGuest.enabled(context)
|
||||
|
||||
private fun handoffAllowed(context: Context): Boolean =
|
||||
android.os.Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.session.SessionPrefs.childProcessHandoff(context)
|
||||
android.os.Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.session.SessionPrefs.childProcessHandoff(context) &&
|
||||
com.droiddeck.launcher.core.PhantomProcessLimit.workersWanted(
|
||||
com.droiddeck.launcher.core.PhantomProcessLimit.setting(context),
|
||||
com.droiddeck.launcher.session.SessionPrefs.producerAcquireFences(context))
|
||||
|
||||
/** How the running session's root was started: in a worker (true) or counted (false); null with none running. */
|
||||
@Volatile var sessionRootUncounted: Boolean? = null
|
||||
|
||||
@@ -6,6 +6,16 @@ import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class PhantomProcessLimitTest {
|
||||
@Test
|
||||
fun workersOnlyWhileAndroidCountsTheSessionsChildren() {
|
||||
assertFalse(PhantomProcessLimit.workersWanted(PhantomProcessStatus.DISABLED, producerFences = false))
|
||||
assertTrue(PhantomProcessLimit.workersWanted(PhantomProcessStatus.DISABLED, producerFences = true))
|
||||
for (status in listOf(PhantomProcessStatus.ENABLED, PhantomProcessStatus.UNSET, PhantomProcessStatus.UNREADABLE,
|
||||
PhantomProcessStatus.NOT_APPLICABLE)) {
|
||||
assertTrue(status.name, PhantomProcessLimit.workersWanted(status, producerFences = false))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun developerOptionsToggleAloneCountsAsOff() {
|
||||
assertEquals(PhantomProcessStatus.DISABLED, PhantomProcessLimit.status(null, "false"))
|
||||
|
||||
Reference in new issue
Block a user