chore: merge main into feat/lse-emu

This commit is contained in:
Kurt Himebauch committed 2026-11-24 00:23:06 -05:00
commit 83f9067a51
609 files changed
+46314 -8272

No files matched your search

+37 -1
View File
@@ -122,9 +122,12 @@ tools/droiddeckctl stop
tools/droiddeckctl resume
tools/droiddeckctl launch 489830 --wait
tools/droiddeckctl library --source xbox
tools/droiddeckctl launch --game "dead space" --wait
tools/droiddeckctl wait focused 489830
tools/droiddeckctl wait game
tools/droiddeckctl quit 489830
tools/droiddeckctl quit
tools/droiddeckctl focus
tools/droiddeckctl input key ENTER
@@ -132,6 +135,7 @@ tools/droiddeckctl input text 'hello world'
tools/droiddeckctl input tap 640 360
tools/droiddeckctl input swipe 100 600 100 100 --duration 400
tools/droiddeckctl input pad a
tools/droiddeckctl input gamepad b rb up --hold 120 --gap 400
tools/droiddeckctl input stick left 0 -1 --hold 500
tools/droiddeckctl input trigger right 1.0
tools/droiddeckctl input pen tap 0.5 0.5 --pressure 0.7
@@ -145,6 +149,10 @@ tools/droiddeckctl ui click --match "Play"
tools/droiddeckctl ui set-text some-field --text abc
tools/droiddeckctl guest -- xprop -root GAMESCOPE_FOCUSED_APP
tools/droiddeckctl native -- ls /usr/local/lib/droiddeck-xbox
tools/droiddeckctl xodus --timeout 60 -- resolve-package 9N51S9QZMSB6 --json --market US
tools/droiddeckctl cloud down ubisoft 92c79ab6-a69a-411d-ba2b-625ab104235d
tools/droiddeckctl cloud up ea DR:105641400 --force
tools/droiddeckctl cdp targets
tools/droiddeckctl cdp eval 'SteamClient.Apps.GetMyRunningApps?.()'
tools/droiddeckctl env set DXVK_HUD=fps
@@ -209,9 +217,36 @@ every 10 s until the battery is under that temperature, so runs being compared s
`input` needs a session that has drawn its first frame. Pad input goes through the session screen's
virtual pad, the same one the on-screen controls drive, so games that ignore touch still respond.
`launch`, `quit` and `cdp` need a Steam session; `focus` and `wait focused` need gamescope (every
`launch` with an app id and `cdp` need a Steam session; `focus` and `wait focused` need gamescope (every
mode except the desktop).
Store and added games (Xbox, EA, Ubisoft, GOG, Epic, Battle.net, Rockstar, a folder added by hand) are
launched by their library id, the same `droiddeck://game/<id>` link a home screen shortcut opens, so
they go through the front end's own launch path and start a session when none is running. `library`
lists the ids with each game's name, source, store id and folder (`--query` and `--source` narrow it),
and `launch --game` takes an id or a unique part of a name; an ambiguous name exits with
`GAME_AMBIGUOUS` and lists the matches. With `--wait` it returns once a game other than the Steam
client has focus. `quit` without an id quits the focused game, so store games close the same way.
`xodus` runs the Xbox backend with the app's own credentials and runtime, as the Xbox store does,
and returns its exit code with the last 160 KiB of stdout and stderr (`--timeout` stops it).
`cloud down|up <store> <id>` syncs one game's cloud saves now, without launching it, with the
`result`, `files`, `bytes`, `reason`, `conflicts` and `detail` the game page shows; `--force` takes
that side over conflicts. The store id is the one in the game's install record (`library` shows
it). Both need Setup > Developer > Debugging tools.
`input pad` writes to the session's virtual pad, the one the guest sees, and never reaches the app's
own key handling. To test how DroidDeck's own screens treat a controller (menu focus and outlines,
page switching with LB and RB, Back and Steam shortcuts), use `input gamepad`. It registers a real
gamepad called "DroidDeck test pad" with `adb shell uinput -`, so Android reports a physical
controller, and presses the buttons in order: `a b x y lb rb select start guide l3 r3` and the
d-pad `up down left right`. `--hold` (120 ms) is how long each stays down and `--gap` (400 ms) the
pause after it; a d-pad press always waits at least 20 ms, so Android sees each release before
the next press. The device exists only while the command runs, takes about a second to appear, and
works without a session or Setup > Developer > Debugging tools. Its name does not start with
`uinput-`, which the app treats as a system virtual device. `UINPUT_UNAVAILABLE` and `UINPUT_FAILED`
mean the same as for `input pen`.
`input pen` does not go through the app. It registers a virtual pen with `adb shell uinput -`, so
Android's own input reader makes the stylus events, as for a built-in pen, and it works on whatever
is on screen, without a session or Setup > Developer > Debugging tools. Positions are fractions of
@@ -402,6 +437,7 @@ Automator show them:
| Tag | Where |
|---|---|
| `rail-steam`, `rail-games` (the Library), `rail-desktop`, `rail-store`, `rail-components`, `rail-android-apps`, `rail-setup`, `rail-updates` | the front end's rail |
| `dual-rail-<key>` (`dual-rail-games`, `dual-rail-downloads`, ...) | the rail on the second screen of a dual-screen device |
| `play-steam` | Play on the Steam page, and on the Library when it has no games |
| `library-source-<source>` | the Library's source filter chips (`all`, `steam`, `gog`, ...) |
| `game-tab-<about\|achievements\|launch\|saves\|install>` | the open tab of a game page |
+36
View File
@@ -0,0 +1,36 @@
# Compose previews
Previews show production composables with sample data, without a device, the Linux runtime or a network. Use them in two
ways:
- **Android Studio:** select the `debug` build variant and open `app/src/debug/java/com/droiddeck/launcher/ui/LauncherPreviews.kt`
in Split or Design view.
- **Rendered to PNG files**, with no Studio or device needed (also how an agent can look at a UI change):
```sh
./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*PreviewRenderTest'
```
Each preview is drawn with Robolectric's native graphics at handheld (960x540 dp at xhdpi, the Duo's top screen,
1920x1080 px) and portrait (540x960 dp) sizes, into `app/build/preview-renders/{handheld,portrait}/<case>.png`. The test
fails if a preview throws, or draws a single flat colour.
## Files
| File | What |
| --- | --- |
| `app/src/debug/.../ui/PreviewSupport.kt` | `PreviewHost` (the production theme), `@DroidDeckPreviews` (the two sizes), sample `FrontEndState`, no-op `FrontEndActions` and `DrawerActions`, sample games |
| `app/src/debug/.../ui/LauncherPreviews.kt` | The previews, and `previewCases`, the list the render test draws |
| `app/src/testDebug/.../ui/PreviewRenderTest.kt` | The render test |
Previews cover the launcher on each tab (Steam, Library, Library with no games, Stores, Downloads, Settings, Settings with
no runtime) and the in-game menu's pages (Controller, Display, HUD, Session, and the Desktop menu).
## Adding one
Write the preview in `LauncherPreviews.kt` (or a new file beside it) with `@DroidDeckPreviews`, wrapping the content in
`PreviewHost`. Add a `PreviewCase` to `previewCases` so it is rendered and checked too. The launcher opens on a tab via
`sampleState(navigate = "<tab key>")`.
Everything here is in the debug source sets, so none of it ships in release builds. Sample art is left out, so cards use
their fallback gradients. Previews check layout and look; they do not exercise launching, input or the runtime.
+6
View File
@@ -293,6 +293,12 @@ configuration falls back to the inherited environment without evaluating its
contents. Both component and environment selection normalize signed non-Steam
prefix IDs to unsigned IDs.
A Dragon's Dogma 2 launch (Steam app 2054970) appends the game's own
`/WineDetectionEnabled:False` switch: the game checks for Wine and its Wine path
does not start. The switch is added only at launch, never to Steam's stored
Launch Options, and a user's own `/WineDetectionEnabled:` value in Launch
Options keeps priority and is not repeated.
The published file also carries generated `dxvkConfig` and `dxvkConfigGames`
values the app's own file never has. The session menu's texture filtering
(`core/TextureFiltering`) becomes `d3d9/d3d11.samplerAnisotropy` and
+120 -82
View File
@@ -1,42 +1,127 @@
# Low-memory reclaim and userspace compression
# Automatic memory management
The Steam session monitor uses the existing `libddsession.so` page-out request to reclaim
private anonymous launcher memory. The default remains a request 20 seconds after game focus,
with five minutes between requests. With client compression enabled, low system headroom can
also trigger a request while a game is loading, before its first focused window.
The Steam session keeps enough memory free on its own. There are no memory settings: the
session monitor in `droiddeck-session` measures how much memory is available and how fast it is
being taken, and compresses just enough idle memory into zRAM to stay ahead of it.
Every five seconds the monitor reads `MemAvailable`, swap headroom and memory PSI. Low
headroom means less than one fifth of total RAM (bounded to 512–1536 MiB), or at least 1%
`some avg10` memory stall with less than one third of RAM available. Pressure requests target
only the launcher processes already recognized by the monitor, never the game. They require
at least 128 MiB launcher RSS and enough free swap to cover its anonymous RSS while leaving
one fifth of swap (at least 256 MiB) free. File-backed resident pages do not consume this
budget: the page-out helper targets private anonymous mappings. If `RssAnon` is absent from a
process's status, its full RSS is used instead. The regular automatic client request uses the
same swap guard. An explicit session RAM cap retains its existing behavior.
## What the monitor measures
Pressure requests are at least 30 seconds apart. Reclaiming less than 16 MiB doubles the
retry delay, up to five minutes. After game exit, speculative launcher readback is deferred
until the session is under any explicit RAM cap, pressure has subsided, and available RAM
can cover twice the launcher's swap while leaving the headroom reserve. Normal demand paging
continues while readback is deferred; Steam does not have to wait for the monitor to recover.
The same readback runs while the game is still running once the client has been in front of it
for five seconds (a game stuck on a black screen and left through Steam, or a long stay in the
Steam menu), under the same memory checks and only without an explicit RAM cap. Missing or
unreadable focus data never counts as the client in front. Demand paging
alone left the Steam library and menus blank for about half a minute in that case. The
client is compressed again 20 seconds after the game is back in front.
Missing memory counters disable automatic pressure reclaim and speculative readback. Missing
PSI alone still permits the `MemAvailable` fallback. No root settings, swap sizes, compression
algorithms, Android process priorities or game-specific settings are changed.
Each pass reads four things:
- `MemAvailable` from `/proc/meminfo`.
- The fall rate: how much `MemAvailable` dropped since the last pass, plus what the monitor
itself freed in between, per second. A peak decays by a quarter per pass, so one burst keeps
the monitor alert for a few seconds without holding it there.
- Memory stall: the change in the `some` total of `/proc/pressure/memory`, as a percentage of
the time between passes. A missing PSI file reads as no stall.
- zRAM room and saving: free space on the zRAM swap devices in `/proc/swaps` after a reserve
of one eighth of zRAM (at least 128 MiB), and the measured saving per compressed byte from
`/sys/block/zram0/mm_stat` (bounded to 1.2:1–6:1, 2.5:1 before 64 MiB has been stored).
Disk swap is not counted as room: paging to storage is what causes long stalls.
The monitor sleeps five seconds between passes while more than two fifths of RAM is available
and memory is steady, and one second otherwise.
## Levels
| Level | Value | Meaning |
| --- | --- | --- |
| Floor | one eighth of RAM, bounded to 640–1280 MiB | Below this the system is close to killing the session. `lmkd` ended a session on a 7.5 GiB device with 490 MiB available. |
| Target | floor + ten seconds of the fall rate | Where the monitor wants available memory to stay. |
| Burst | two seconds of the fall rate, when that is at least 64 MiB and less than two fifths of RAM is available | Memory that will be taken before the next passes can react. |
The amount to free is the distance to the target or the burst, whichever is larger. The hard
part of it is what available memory is short of the floor, and nothing when it is above. With
a memory stall of at least 1% the hard part is two seconds of the fall rate when that is
larger, whatever the size of the fall and however much memory is available.
## What gets compressed, in order
1. The Steam client and hidden launchers, while a game is running and the client is not known
to be in front (unreadable focus data counts as not in front), or at any time when there is
a hard need. Without a hard need the client is left alone for 30 seconds after
it was read back.
2. Processes of the session that loaded `libddsession.so` (the game, Wine and its services),
largest first, only for the hard part that the client did not cover. One pass moves at
most 256 MiB.
Both use the preload's cold-only request (`2 <kB>`): each process pages out only memory it has
not touched recently and stops at the budget, so memory in use stays in RAM and is not read
straight back. The budget is the amount to free divided by the measured saving, limited to the
zRAM room. With less than half the floor available the request ignores heat (`3 <kB>`), moves
up to 1 GiB, and runs at most once every ten seconds.
Two things keep memory from going in and out of zRAM. The preload remembers each 1 MiB chunk
it paged out: when a quarter or more of those pages are resident again at the next visit, the
chunk is hot and is passed over for the next 64 visits, then 128, then 255. And the monitor
reads `pswpin` from `/proc/vmstat`: what was read back from swap, fading over half a minute,
is taken off what one pass may move (1 GiB in all, at most 256 MiB of it from the session). A device
whose working set does not fit therefore stops being trimmed and is left to the kernel, until
the forced level is reached.
A pass that gives back less than a quarter of what the floor is short by is followed by a wait:
five seconds, doubling after each such pass up to a minute. The wait ends early when available
memory drops another eighth of the floor or reaches the forced level, and is forgotten after a
pass that gives back enough or once nothing is needed.
Requests go to one process at a time. The monitor waits for that process's acknowledgement
(the kB it paged out) before the next, reads `MemAvailable` again, and stops once the budget is
met or available memory is back at the level the pass was started for. A process that has not
started within half a second, or has not finished when the pass (client and session together)
has waited five seconds in total or six seconds have gone by since it began, is skipped for a
minute, and a late answer from it is discarded. A process is known by its number and start time, so a new process that got the
number of a skipped one is asked. Processes with less
than 8 MiB of anonymous memory are skipped. While the app pages the session out for suspend, or
reads it back on resume, it holds the monitor off with `/tmp/.dd-zram.hold` and writes its own
request (`1` to page out, `0` to read back) into that file. A signalled process reads the hold
file first and the control file only when the hold file is missing or empty, so a trim request
the monitor wrote at the same moment cannot replace the app's. The suspend page-out answers `1`
in `/tmp/.dd-zram.ack.<pid>` and a trim answers its kB in `/tmp/.dd-zram.trim.<pid>`, so the
monitor never removes or reads an answer the app is waiting for, and the app never takes a
trim's answer for its own. A trim budget smaller than a chunk covers the stretch of the chunk
that holds that many resident pages, and the next request continues from where it ended. With less than 64 MiB of zRAM room nothing is requested and the
session log says so once a minute.
With no shortage nothing is compressed. A game that fits in memory is never touched, and Steam
is no longer compressed on a timer.
## Reading the client back
Once the client has been compressed, it is read back in one request when the game has exited,
or the client has been in front of the game for five seconds, and at least 30 seconds have
passed since the last request, and available memory covers the client's swap plus the target
and the floor. Missing or unreadable focus data never counts as the client in front. Demand
paging alone left the Steam library and menus blank for about half a minute in that case.
Suspending the session while it is asleep, hidden or the screen is off still pages everything
out, and resuming reads it back when available memory is at least twice what those processes
have in swap at that moment and, after it, 1 GiB or a tenth of RAM, whichever is larger, stays
available.
## Threads
When a worker can be started, page-out runs outside the game's threads. The preload's signal
handler starts a `zr-worker` thread for the request, which does the `madvise` calls and exits once no request
is left, so a process that is not paging out has no thread the preload added. Programs that
check they are single-threaded before they fork or call `unshare(CLONE_NEWUSER)`, such as
Chromium's zygote, keep working. The worker is a bare `clone` with the flags of a normal
thread, on a stack the preload maps itself, and makes only raw system calls, so starting it
from the signal handler is safe and seccomp filters that only allow thread clones accept it. A
process that has a single thread, or whose signalled thread added a seccomp filter after the
process started, as browser sandboxes do, gets no worker. When there is no worker, the process trims inline in steps of at most 32 MiB per request and
looks at no more than 512 MiB of its address space each time. The page-out for a suspend and the read-back
after it are not limited there: they run once, while the process is being stopped or
started, and cover all of it. The monitor is a
shell loop in the session, outside every game process.
The session log gets a line once at least 16 MiB has moved since the last one, at most every
five seconds:
`memory: available N MB, falling N MB/s, compressed N MB of the client and N MB of the session`.
No root settings, swap sizes, compression algorithms, Android process priorities or
game-specific settings are changed.
## Measurements behind the levels
A bounded live test of the pressure helper on the FIT during Caravan SandWitch loading
requested page-out at 20:52:37 UTC, 18 seconds before the installed timed reclaimer. Aggregate
launcher RSS fell from 608 to 283 MiB across that request; this is summed process RSS, not a
measurement of net physical RAM saved. The game reached its main menu at 60 FPS. The test ran
the candidate monitor functions alongside the old APK's monitor, not a newly built APK;
the old monitor's later request is visible separately at 20:52:55 in the session log. This
does not establish gameplay performance or resolve Stellar Blade's larger memory failure.
Continuing an existing Caravan save reproduced a whole-session low-memory kill with the
pressure helper running. Android recorded `ApplicationExitInfo` reason `LOW_MEMORY`, and
@@ -49,39 +134,6 @@ reduced aggregate launcher RSS only from 263 to 255 MiB and backed off. Thus lau
does not resolve this load failure, and this run did not exhaust swap. The unevictable/shmem
growth needs allocation attribution before treating it as a driver or GPU-memory diagnosis.
## Pressure reclaim: compressing idle game memory
The monitor also compresses the game session itself when observed pressure approaches the
system kill boundary. There is no RAM-size gate. The trigger is absolute real headroom, not a
percentage: Android's `lmkd` killed a session on a 7.5 GiB device with
490 MiB still available, so a 95% used threshold (about 400 MiB left on 8 GB) is already past the
kill. A world load added 1 GiB of GPU memory in about ten seconds, and compressing 1.4 GiB took
2.6 seconds, so the request has to leave room for both.
Performance > Compress idle game memory turns this off (`DD_ZRAM_IDLE=0`); launcher compression
and the RAM cap are unaffected.
The session request runs when real headroom falls below a quarter of RAM (bounded to
768–2560 MiB), or below one and a half times that with at least 1% `some` or `full avg10`
memory stall. Real headroom subtracts positive growth in KGSL allocation, `Unevictable`, and
`Shmem` from `MemAvailable`; a rapid fall also qualifies below twice the headroom or two fifths of RAM, whichever is larger (a 15 GB Thor Max was killed with 5.3 GB still available while memory fell about 400 MB per tick). The monitor
may first request page-out of idle Steam and hidden launchers, subject to the Performance
setting and client reclaim limits. When both qualify, both requests are sent before waiting
for either to complete, so a slow launcher acknowledgement does not delay the game request. Until the client
request finishes, its anonymous RSS remains reserved from the session's swap budget. Completion
and backoff are measured against the processes that received each request, even if a later scan
finds different processes. The session request targets processes that loaded
`libddsession.so`: the game, Wine and its services, and excludes Steam and hidden launchers.
Requests are at least 30 seconds apart and need the same
swap reserve as launcher requests. When the session has read back more than half of what the
previous request compressed, that memory is in use: the request is skipped and the wait doubles,
up to five minutes. A completed request must also raise `MemAvailable` by at least one
sixteenth of the tier headroom, with a 16 MiB minimum; otherwise the same wait doubles because
the pass did not provide meaningful system headroom. A request whose memory stayed compressed or
whose available memory recovers resets the wait to 30 seconds. Below half the headroom the wait
is ignored and only the 30-second spacing applies, so critical pressure can still trigger a
request. The state resets when the game exits.
Measured on a Retroid Pocket Duo (7.5 GiB, kernel 6.6, 6 GiB lzo-rle zram plus a 4 GiB swap file)
entering the world in World of Warcraft: Forever, one run each:
@@ -99,20 +151,6 @@ allocation, not swap capacity. Little Nightmares at the same settings compressed
the following minute at its menu and 440 MiB while loading the next area; frame rate stayed at
44–46 FPS with one or two short frame-time spikes. These are single runs, not averages.
On the PR build without any manual step, the monitor compressed WoW before character select and
again during the load; the game entered the world and stayed there at 33 FPS. Once in the world,
available memory settled near 1 GiB, under the headroom, and the first version of the policy
compressed 200–400 MiB every 30 seconds while the game read back about 15 MiB/s. The
read-back check therefore compares against the last request instead of all compressed memory.
A second run on that build showed the trigger arriving too late: character select sat at
1.5–1.6 GiB available, just above the original one-fifth headroom, so nothing was compressed
there. During the load, available memory crossed the headroom 9 seconds after Enter World, but the
launcher check ran first and waited 12 seconds for acknowledgements; the game request started at
21 seconds, moved about 200 MiB, and `lmkd` ended the session at 30 seconds. The quarter-of-RAM
level starts reclaim earlier. Sending both requests before waiting removes the launcher
acknowledgement delay; it does not guarantee that reclaim can keep up with every loading peak.
Without root an app cannot write its memory cgroup's `memory.reclaim` (owned by `system`),
`process_madvise` on another process returns `EPERM`, `PAGEMAP_SCAN` is absent before Linux 6.7,
and KGSL's per-process GPU reclaim `state` is root-only. Page-out therefore runs inside each
+24 -1
View File
@@ -128,10 +128,32 @@ What it does, per feature:
- Pipelines and `vkCmdSetColorBlendEquationEXT` both.
- Why alpha: output 0's color is the paint, its alpha is the usual coverage. Per-channel coverage collapses to one value; blending stays plain alpha blending, not tinted by the paint.
The SPIR-V version the driver gets:
- The phone's own driver compiles the guest's SPIR-V, and its compiler is old: on the MT6897
Mali-G615 (r44p1, "Vulkan 1.3.247") it dies with a null read in `cmpbe_v2_compile_multiple_shaders`
while compiling a pipeline, and the render server dies with it, so every guest client that
draws loses its device.
- Zink writes SPIR-V 1.6 for any Vulkan 1.3 device (`zink_screen.c`: `spirv_version` from the
device's version), and SPIR-V 1.4 changed the entry point's interface: it has to list every
global variable, not only the input and output ones.
- The layer therefore lowers every module to SPIR-V 1.3 before the driver sees it: the version
word, the interface list (back to the input and output variables) and `OpTerminateInvocation`
(SPIR-V 1.6's name for `OpKill`). This covers shader modules, and code given inline to
graphics and compute pipelines.
- A module that uses something 1.3 cannot express is left alone and the layer says so in its
log: a `ShaderViewportIndex` capability, the Vulkan memory model, `OpCopyLogical`, an
`OpSelect` of a structure or array, the newer loop controls and image operands, or a
capability, decoration or instruction that became core later without the extension 1.3
needs for it (`ShaderNonUniform` without `SPV_EXT_descriptor_indexing`).
- The version cap runs on every device the layer is active on; clip and cull distances are
only taken out where the layer emulates them. `DROIDDECK_MALI_COMPAT=0` turns both off.
- This is what Dawn ("Disable SPIR-V 1.4 on Android ARM"), ANGLE (`supportsSPIRV14`) and naga
(`AVOID_SPIRV_COPY_LOGICAL`) do for a proprietary compiler they cannot trust.
Files:
- `layer.c`: loader plumbing, feature and limit reporting, device creation, the hook table.
- `pipeline.c`: pipelines, shader modules, viewports.
- `spirv.c`: the SPIR-V rewriter for clip and cull distances and the second blend source.
- `spirv.c`: the SPIR-V rewriter for clip and cull distances and the second blend source, and the version cap.
- `bc.c`: BC formats, images and uploads.
- `VkLayer_droiddeck_mali_compat.json`: implicit layer manifest.
@@ -149,6 +171,7 @@ How it ships:
Not done yet:
- Unit tests for the clip and cull distance rewriter. It is untested beyond DXVK's shaders, and unknown whether Silksong's shaders used clip distances at all.
- The dual-source rewrite has them: `tools/tests/test_mali_compat_layer.py`.
- The version cap has them: `tools/tests/test_mali_compat_spirv.py`.
- Performance: BC decoding on the CPU makes loads slow. A compute-shader decoder would be the next step.
## Changes on the branch
+123
View File
@@ -0,0 +1,123 @@
# Keep-top guard A/B on dual screens
`KeepTopActivity` (#2763, removed in the change that added this section) covered every other
display while a session was on top, so that display's home was not its top activity. The
reasoning: on the Thor, lmkd kills the bottom home under memory pressure, Android relaunches it
to the front, the session loses the top spot, drops to adj 50 and is killed next.
It had three side effects:
- Android gives a translucent activity alone in its task an `ActivityRecordInputSink` that
consumes every touch in the task bounds whatever the window's flags say
(`ENABLE_TOUCH_OPAQUE_ACTIVITIES`), so the bottom screen took no touch (#2910 worked around it).
- Cocoon tracks the top activity of each display; with a DroidDeck activity on the bottom it
could not suspend or resume DroidDeck properly.
- The Thor's `com.odin.gameassistant` gives every app with an activity on top of the bottom
display that display's volume (`secondary_screen_volume_level`). With the guard up, all of
DroidDeck's audio played at the bottom screen's volume (AudioFlinger track gain -37, -13 and
-2.6 dB at levels 3, 8 and 13; -7.4 dB, the top level, once the guard was removed).
The A/B below found no case on either device where the guard kept the session alive, so it was
removed.
## Tool
`tools/memory_guard_ab.py` drives a rooted dual-screen device over adb (`su` required) with a
build that has the debugging tools:
```sh
python3 tools/memory_guard_ab.py --label main --apk main.apk states
python3 tools/memory_guard_ab.py --label fix --apk fix.apk states
python3 tools/memory_guard_ab.py --label fix pressure --stop-mb 650 --hold 30 --runs 3
python3 tools/memory_guard_ab.py --label fix pressure --burst --stop-mb 1500 --hold 20 --runs 3
python3 tools/memory_guard_ab.py --label fix summarize ~/.cache/droiddeck-memory-guard-ab/fix-stop650-1-events.txt
```
Results are JSON lines in `~/.cache/droiddeck-memory-guard-ab/<label>.jsonl`, next to the
event log of every probe.
- `states` starts a fresh Steam session and walks the reachable states. In each one it records
the focused display, the guards, the panel and DroidDeck's `oom_score_adj`, then kills the
bottom home with `kill -9` (what lmkd does) and samples the adj for 5 s. It also counts guard
launches during 3 idle seconds and `SessionActivity` instances, which catch a guard loop.
- `pressure` fills a private tmpfs with `/dev/urandom` until `MemAvailable` reaches
`--stop-mb`, holds it, and releases it. zram cannot compress that data and no app owns it,
so lmkd keeps killing by adj. It records lmkd's `killinfo`, process deaths, focus loss and
whether DroidDeck survived.
- `pressure --burst` takes everything above `--stop-mb` at once instead: it copies a 256 MiB
random file into the tmpfs with all copies running in parallel (about 5 GiB in 2 to 3 s on a
Thor), the way a game's GPU allocation burst lands on lmkd.
- `oom_score_adj` is read without `su`. Under pressure lmkd keeps killing the root manager app,
and a `su` call can then open its request screen on top of the game.
- If the bottom display has no home (a killed home is not always restarted), the visible app on
top of it stands in.
- `--bottom-tap` must point at an inert spot of the bottom home; `--panel-close` at the
panel's close button. Both are fractions of the bottom display.
- `am start` of `SessionActivity` needs `--display 0`; without it, it creates a second
session on the focused bottom display.
## Results: Retroid Pocket Duo, Android 16, Cocoon as the bottom home
Builds: `main` (45c31a4), `fix` (this branch), and `no-guard` (`main` with
`guardOtherDisplays` returning at once, the behaviour before #2763).
### Bottom home killed in each state
| State | main | fix | no-guard |
| --- | --- | --- | --- |
| Panel open | guard, adj 0 | guard, adj 0 | adj 0 |
| Panel closed, bottom untouched | guard, adj 0 | guard, adj 0 | adj 0 |
| One bottom touch, under 5 s ago | guard, adj 0 (touch eaten) | no guard, adj 0 | focus on bottom, adj 50 |
| One bottom touch, then 8 s in the game | guard, adj 0 | guard, adj 0 | focus on bottom, adj 50 |
| Used the bottom screen, then tapped the game | guard, adj 0 | guard, adj 0 | adj 0 |
| Home (session in PiP) | guard, adj 50 | no guard, adj 50 | adj 50 |
| Using the bottom screen now | not reachable (touches eaten) | focus on bottom, adj 50 | focus on bottom, adj 50 |
No probe on any build lost the session's top spot or raised its adj when the bottom home was
killed. The fix has the guard on top wherever `main` has it, except in the 5 s after a bottom
touch and in PiP, where the session is at adj 50 with or without it. There were no guard
launches while idle and one session in every state.
### Real memory pressure, panel closed, game focused
| Run | lmkd kills (down to adj 0) | Bottom home deaths | Session lost the top spot | DroidDeck |
| --- | --- | --- | --- | --- |
| no-guard, stop at 650 MB | 42 (0) | 14 | no | survived |
| main, stop at 650 MB | 10 (0) | 0 | no | survived |
| fix, stop at 650 MB | 42 (0) | 18 | no | survived |
| no-guard, stop at 500 MB | 36 (2) | 15 | no | killed at adj 0 |
| main, stop at 500 MB | 73 (4) | 28 | no | killed at adj 0 |
| fix, stop at 500 MB | 74 (1) | 31 | no | survived |
Around 650 MB available, lmkd kills down to adj 50: the bottom home dies over and over and the
session survives. At 500 MB lmkd reaches its adj 0 pass and kills the foreground session
whatever the guard does; which build survives that is luck.
### What the Duo cannot show
Android 16 on the Duo restarts a killed bottom home in place (`wm_restart_activity`) and never
moves it to the front, even with no guard. The Thor's focus steal does not happen here, so the
Duo shows that the guard covers the same states as before, not that it saves the session. That
needs a Thor: run `states` and `pressure --stop-mb` near its adj-50 level on `main` and on the
fix, and look for `task_to_front` and `session_top_lost` before `droiddeck_died_at_adj` 50.
## Results: AYN Thor (12 GB), Android 13
Builds: `main` (56986b5, guard with the #2910 touch yield) and `no-guard` (`main` with
`guardOtherDisplays` returning at once). The game was focused on the top screen in every run.
| Pressure | Bottom app | no-guard | main |
| --- | --- | --- | --- |
| Fill to 650 MB free, hold 30 s | stock launcher | survived 1/1 usable run (launcher not reached) | survived 3/3 (launcher killed 80, 25, 0 times) |
| Fill to 550 MB free, hold 30 s | Cocoon as home | survived 3/3, Cocoon killed 387, 400, 84 times | survived 3/3, Cocoon killed 384, 127, 338 times |
| Burst to 400 MB free (about 5 GB in 2.5 to 3.4 s) | stock launcher | killed at adj 0 in 3/3 | killed at adj 0 in 3/3 |
| Burst to 1500 MB free (2.0 to 2.4 s) | stock launcher | survived 1/2, killed at adj 0 in 1/2 | killed at adj 0 in 2/2 |
No run on either build lost the top spot (`wm_on_top_resumed_lost_called` for
`SessionActivity`), moved a task to the front, or killed DroidDeck at adj 50. A killed bottom
home is either restarted in place or its task disappears and the next app shows on the bottom
screen, without taking focus. A burst big enough to matter makes lmkd kill the foreground
session at adj 0, which no activity on another display can prevent.
`kill -9` of the bottom app (`states`) is noisy on a Thor with many recent apps: each kill
surfaces the next app on the bottom screen, and every tap the tool sends there moves focus.
+16 -11
View File
@@ -8,10 +8,7 @@ A theme is a `Palette` (`ui/Theme.kt`): a dark background scale (`background`, `
## Gradient theme
`Themes.GRADIENT` is the one theme whose colours the person picks: a primary and a secondary,
kept in `SessionPrefs.gradientColors` and in `Themes.gradientColors`, a Compose state, so a change
restyles the whole app at once. `App.onCreate` loads the saved colours; code outside a composition
uses `Themes.current(context)`.
`Themes.GRADIENT` is the one of the theme whose colours the person picks: a primary and a secondary, kept in `SessionPrefs.gradientColors` and in `Themes.gradientColors`, a Compose state, so a change restyles the whole app at once. `App.onCreate` loads the saved colours; code outside a composition uses `Themes.current(context)`.
`ThemeColors.palette` builds the full palette from the two colours: primary becomes
`primary` / `signal`, secondary becomes `primary2`, the background scale is a dark neutral tinted with
@@ -24,16 +21,24 @@ square. It opens `ColorPickerDialog`: a wheel (hue and saturation, touch), hue /
brightness sliders (they work with a controller) and a hex box, with the old and new colour side by
side. OK applies it.
## Custom theme
`Themes.CUSTOM` stores a separate preference for every configurable palette colour:
background, surfaces, borders, text, accent, button text, signals, success and error.
`SessionPrefs.customThemeColors` restores the saved values, while `Themes.customColors`
is Compose state so changes update the interface immediately.
The custom palette does not derive its surfaces from the accent. `primary2` intentionally
equals `primary`, keeping components that use the existing two-stop button and launch
effects visually solid. The colour picker reused from Gradient supports the wheel, sliders
and hexadecimal input.
## Inner Gamer theme
`Themes.INNER_GAMER` is an RGB theme: the accent walks round the colour wheel. It sits just above
Gradient in the list, and Setup shows a Speed slider (1 to 10, `SessionPrefs.rgbSpeed`) under the
theme while it is chosen.
Gradient in the list, and Setup shows a Speed slider (1 to 10, `SessionPrefs.rgbSpeed`) under the theme while it is chosen.
`Themes.innerGamer(hue)` builds the palette for one hue through `ThemeColors.palette`, so button text
keeps the same contrast along the gradient at every hue. `DroidDeckTheme` runs one
`rememberInfiniteTransition` while Inner Gamer is chosen, so the system's animation clock drives it.
Compose applies Android's animator scale to it, and the colour holds still when animations are off
in the app (`Motion.scale`) or in Android's own settings. The hue is written to `Themes.rgbHue` in 3° steps, which restyles the
`Themes.innerGamer(hue)` builds the palette for one hue through `ThemeColors.palette`, so button text keeps the same contrast along the gradient at every hue. `DroidDeckTheme` runs one `rememberInfiniteTransition` while Inner Gamer is chosen, so the system's animation clock drives it.
Compose applies Android's animator scale to it, and the colour holds still when animations are off in the app (`Motion.scale`) or in Android's own settings. The hue is written to `Themes.rgbHue` in 3° steps, which restyles the
app only when the colour visibly moves; a slow cycle costs few recompositions.
@@ -451,3 +451,69 @@ synchronous directory updates, so SD installs stay bound by them (about 4 to 5 m
2,000 files of reserving plus commit on this card). Removing those costs needs fewer
directory operations per file, not faster path translation.
## Repeated round trips in the Steam client (2026-11-19)
Measured on an AYANEO Pocket FIT Elite with a SanDisk 128 GB U1 card (exFAT, `dirsync`,
MediaProvider FUSE) as the second Steam library, by timing every file call the Steam
client makes under `/steamapps` during a real uninstall and install.
Where the time went before, for one install of 3,800 files and directories:
| Call | Total before | Total after |
| --- | --- | --- |
| `faccessat` | 31.1 s | 0 s |
| `stat` | 29.4 s | 0 s |
| `access` | 40.3 s | 13.2 s |
| `opendir` | 8.6 s | 3.3 s |
| `__xstat64` | 5.4 s | about 0 s |
| `rename` | 124.8 s | 91 to 106 s |
| file creation | about 22 s | about 22 s |
Most of the removed calls asked the card a question the directory cache could already
answer:
- A directory the cache holds a fresh listing for is now opened from that listing without
a `stat` of the directory first, and its own create, rename and remove calls update the
listing from what the call returned instead of re-reading the directory and the new
entry.
- `access`, `faccessat` and `__xstat64` on a name that a fresh listing shows is missing
return `ENOENT` without a round trip, including the differently cased spellings the
client probes. An absolute path passed with a directory descriptor takes the same path.
- The path cache spreads its slots with the high hash bits, which stops install paths that
differ only near the end from evicting each other.
Results on the card (the first four rows are the 3,800 entry install; the moves are
single runs timed to about 3 s):
| Step | Before | After |
| --- | --- | --- |
| Reserving space | 68.9 s | 27 to 28 s |
| Commit | 150.9 s | 97 to 111 s |
| Whole install | 261.0 s | 172 to 195 s |
| Uninstall | about 31 s | 28.5 to 29.4 s |
| Reserving space, second program (4.4 GB, few files) | 33.9 s | 12.5 s |
| Uninstall, second program | 12.3 s | 9.2 s |
| Steam move, internal storage to card | 156.8 s | 121.7 s |
| Steam move, card to internal storage | 56.5 s | 62.0 s |
What is left is the card: each rename and each file creation is one synchronous directory
update, and the second program's 4.4 GB download and final commit took the same time
before and after.
### Launching from the card
A program started from the card was traced the same way. Three things were measured:
- Sequential reads through the mount run at the card's own speed (88 MB/s cold), with or
without read-ahead hints. A launch that reads 1 GB spends about 12 s there on this card.
- A warm directory listing takes about 0.8 ms. A cold one takes about 77 ms for every
128 KB directory cluster, even for a directory with one entry, so listing a 167
directory install tree takes 12.9 s cold and 0.37 s warm.
- The listings stay warm while the device is idle, but a launch that fills memory pushes
them out again in bursts, so a program that lists its tree more than once pays the cold
price more than once. Keeping the tree warm from outside for the whole launch moved the
traced program's start-up forward by 5.5 to 7 s out of about 89 s.
The rest of that launch was the program's own launcher and CPU-bound start-up, which did
not wait on the card in these traces.
-28
View File
@@ -1,28 +0,0 @@
# Reported video memory budget
The Performance VRAM setting enables `VK_LAYER_DROIDDECK_vram_cap` for games and reports smaller device-local `VK_EXT_memory_budget` budgets. DXVK exposes these through DXGI's `QueryVideoMemoryInfo`, including to D3D12 games using DXVK's DXGI alongside vkd3d-proton. Games that consult this budget can choose smaller working sets. The driver still supplies real heap sizes, usage figures, memory types, and actual allocation results. DXVK also receives `dxgi.maxDeviceMemory` and `dxgi.maxSharedMemory`, which separately reduce the adapter's advertised dedicated and shared video memory (on a single-heap GPU DXVK reports the heap as both, so a game adding the two would otherwise still see the whole heap as shared), and, for caps below DXVK's 4096 MiB D3D9 default, `d3d9.maxAvailableMemory`, which caps the texture memory DXVK's D3D9 frontend reports, since D3D9 games do not read the DXGI setting. Higher caps leave the D3D9 setting alone so DXVK's lower per-game limits still apply. OpenGL games are not covered. A lower driver budget remains lower; the layer never increases it.
This does not make vkd3d-proton automatically enforce the selected budget. In the [upstream allocator inspected during this investigation](https://github.com/HansKristian-Work/vkd3d-proton/blob/865b12ba0cc20796b3709397ce5d6d3b8a205b04/libs/vkd3d/memory.c), `heapBudget` is used for diagnostic reporting, while the [DXVK adapter](https://github.com/doitsujin/dxvk/blob/cf0a0d90f8965147741ad17dcd0b263817572ab3/src/dxgi/dxgi_adapter.cpp) returns the Vulkan budget to applications. Seeing a smaller budget in a VKD3D log verifies reporting, not reduced allocation or eviction.
This is a budget hint, not a physical reservation or a GPU paging implementation. Games may exceed it. On UMA hardware, host-visible Vulkan allocations can share the same device-local heap as textures. Rejecting every allocation above a fixed total can therefore break required upload buffers and other allocations, rather than make a game reduce its texture pool. The layer does not intercept `vkAllocateMemory` or `vkFreeMemory`, and preserves the real heap size so individual allocations larger than the budget remain Vulkan-valid.
The layer activates only with `DROIDDECK_VRAM_CAP=1` and a positive `DROIDDECK_VRAM_CAP_MB`. With the Performance setting on Auto, the game environment does not enable it. Explicit DXVK configuration remains available, while the Vulkan layer also covers D3D12 and games that replace their DXVK configuration.
## Physical investigation
On an 8 GB Pocket FIT Elite with DD Turnip 0.4.0, Proton 11-12.1, and Caravan SandWitch build 25301828:
- A native Vulkan probe reported a device-local heap of 5,650,776,064 bytes. All exposed memory types used the same device-local UMA heap. The initial implementation clamped both heap and budget to 2048 MiB; the revised layer preserves heap capacity and clamps only the budget.
- The initial hard allocation cap caused the existing save to fail a required 603,979,776-byte D3D12 allocation. Android survived, but the game crashed. Discord testers also reported crashes after reaching the cap in Fallout 76.
- In the initial test with allocation rejection disabled, vkd3d-proton logged the smaller 2048 MiB heap and budget. Caravan still exhausted system memory while loading the save. A reported budget alone does not solve this workload.
- DX11 loaded the same save and supported movement around the station at approximately 60 FPS for more than five minutes, both with and without the reported budget layer. Graphics settings were unchanged. This establishes a renderer workaround, not proof that the layer solved Caravan's OOM.
- The final release-signed APK, preserving real heap size and clamping only the budget to 2048 MiB, also passed more than five minutes of loaded-save DX11 movement. D3D12 with the same budget still exhausted system memory.
- Launching D3D12 through `droiddeck-proton-run --app` without the Linux Steam client reached the loaded save and allowed movement, then Android killed the session for low memory. Removing the client footprint alone was insufficient.
A separate Windows DXGI query probe on a **12 GB AYN Thor** with the same APK and Proton queried the adapter without allocating game resources. With the layer disabled, dedicated video memory was 8,858,370,048 bytes and the local budget was 5,656,018,944 bytes. Enabling only the layer at 2048 MiB preserved that dedicated-memory value and changed the local and UMA non-local budgets to 2,147,483,648 bytes. Adding the existing `DXVK_CONFIG="dxgi.maxDeviceMemory = 2048"` setting also lowered advertised dedicated memory to 2,147,483,648 bytes while retaining the 2048 MiB budgets. These probes verify the application-facing budget path; they are not 8 GB gameplay results.
On that Thor, subsequent D3D12 runs both with and without the 2048 MiB budget reached the existing save and supported more than five minutes of movement. Both used the Stability preset and `VKD3D_CONFIG=log_memory_budget`. The budgeted run ended with an Android low-memory kill during the shutdown window; the unbudgeted retry stopped cleanly. Earlier runs also encountered low-memory kills or a separate exception-stack startup failure. These observations do not establish a reduction in Caravan's memory use from the budget hint or a stable D3D12 fix.
Native regression coverage exercises core and KHR memory-property queries, chained budget structures, unchanged real usage above the budget, separate heap types, disabled behavior, device lifecycle dispatch, and successful driver allocations whose individual and combined sizes exceed the reported budget.
The Vulkan specification describes [`heapBudget` as a guideline](https://docs.vulkan.org/refpages/latest/refpages/source/VkPhysicalDeviceMemoryBudgetPropertiesEXT.html). Transparent movement between device-local and host-local memory requires driver and operating-system support for [pageable device-local memory](https://docs.vulkan.org/refpages/latest/refpages/source/vkAllocateMemory.html).
+109 -1
View File
@@ -131,6 +131,18 @@ The client's web helper draws its whole UI. There are two:
blank. `LinuxRuntime` binds an empty folder over `/sys/bus/pci/devices` on such devices; device:
0 GPU process exits, ANGLE on zink and Turnip.
FEX ships per-program AppConfigs, and `/usr/local/share/fex-emu/AppConfig/steamwebhelper.json` turns
the GL thunk off for every program named `steamwebhelper`. A program's AppConfig is read after
`FEX_THUNKCONFIG`, so the x86 helper got the rootfs's x86 Mesa while the client next to it had the
thunk. Steam's browser compositor creates its output window through SDL3 and GLX in the helper's
browser process, and x86 Mesa's `driCreateNewScreen3` (kisak libgallium 26.1.6) faulted there
(SIGSEGV, exit 139) about 11 s after every start; the client restarted it each time (device: 57
restarts in 11 minutes). `x64_env` therefore writes, for every global AppConfig that turns off a
thunk the session uses, a local AppConfig (`$X64_HOME/.config/fex-emu/AppConfig/<name>.json`, read
after the global one) with the session's thunk set. It never touches a local file with other content,
so a user's own AppConfig wins, and removes its own files when the client runs in software. Device:
helper up for over 10 minutes with no restart, ANGLE on zink and Turnip through the thunk.
The session shim (`preload/net.c`) turns `steamrt64/steamwebhelper.sh`'s exec of `./steamwebhelper`
into `DD_X64_ARM_WEBHELPER`. Nothing in the client's folder is edited: the client checksums its files
as it starts and reinstalled itself over an edited launcher (2-3 minutes) on every start.
@@ -197,13 +209,109 @@ alone would then read as an installed client.
restarted from the top forever (found with `perf_event_open` IP sampling, since proot holds
ptrace). Such a range is now skipped whole and a second exhausted scan returns `-ENOMEM`, as the
kernel does (`fex-2610-r3`).
- `0006-smc-alias-of-code-created-after-translation`: a JIT with a double-mapped memfd (CoreCLR's
W^X allocator) maps its writable alias after the executable alias was translated. Under
`SMCChecks=mtrack` the new alias was not write-protected, so writes through it never faulted and
never invalidated the translated code; x86-64 .NET programs ran stale code (access violations,
NullReferenceException, internal CLR errors). A writable mapping or mprotect now write-protects the
overlapping part of any alias that is already executable, so the first write faults and invalidates.
`FEX_SMCCHECKS=full` was the only workaround; no setting is needed with the patch.
- `0007-cmake-install-code-without-depends`: CMake 4.5 rejects the `DEPENDS` argument FEX passes to
`install(CODE ...)` for the guest thunk libraries, so builds with host thunks stopped at configure.
The guest libraries are external projects in the default build, which `install` already follows.
- `0008-signal-return-restores-syscall-state`: a guest `rt_sigreturn` is a system call, so FEX's
syscall stub marks every static register as spilled (`InSyscallInfo = 0xFFFF`). When the handler
left RIP alone, the return resumed the interrupted JIT code without passing the stub's reset, and
the mark stayed. Every asynchronous signal after that (until the next system call ended) skipped the
register spill and handed the guest handler stale registers from the last system call: only RIP was
right. CoreCLR suspends threads for the GC with such signals and reads or redirects the interrupted
context, so x86-64 .NET programs failed at random (`AccessViolationException` in whatever code ran
next, then SIGABRT). `tools/fex/probes/async-signal-context.c` shows it: under FEX-2611.1 one signal in
2000 carried the interrupted registers, natively all of them. The return now restores the value saved
when the signal arrived, and only when the signal interrupted JIT code, which is the only case that
saves it. Restoring it for a signal that interrupted a system call cleared the mark while that call
was still running, so the next signal in the call's return path spilled clobbered registers:
`setitimer` at 100 Hz around `time()` crashed in 15 of 15 runs, and with the guard as often as the
same build without the patch (about half; a separate crash that FEX-2611.1 also shows).
- `0009-signal-handler-escape-frees-host-stack`: FEX keeps each signal's host context on the host
stack and frees it only on `rt_sigreturn`. A guest that leaves its handler another way (`siglongjmp`,
or CoreCLR resuming a `catch` after a NullReferenceException) left that 2 KB block and one
`SignalHandlerRefCounter` count behind. About 3500 such exceptions on one thread overran the 8 MB
host stack, which has no guard page, and the CurseForge agent died with "Internal CLR error.
(0x80131506)" and "Stack overflow occurred on the same thread again!" at the start of its second
addon scan. FEX now chains each thread's signal frames with the guest frame range and alternate
stack they used. When a signal arrives in JIT code that runs at the host level of the newest frame
and the guest stack pointer shows the guest has left that frame (above its frame, or back off the
alternate stack above where the outermost frame on it interrupted), the left frames are dropped and
the new context is stored where the newest live frame (or the dispatcher entry) left the host stack.
`rt_sigreturn` pops its frame and any newer ones it skips. Signals that arrive inside system calls or
thunk callbacks are left alone. `tools/fex/probes/signal-handler-escape.c` leaves handlers on and
off the alternate stack, mixes them with handlers that return, and leaves nested handlers: FEX-2611.1
with 0001 to 0008 crashed (SIGSEGV) before 2000 iterations of it, and `siglongjmp` out of a SIGSEGV
handler died after about 3500; with this patch 350000 escapes and 200000 straight `siglongjmp`s
finish, as natively. The approach is the one suggested in FEX-Emu/FEX#2487.
- `0010-syscall-exit-resets-host-stack` (`Fixed-upstream: FEX-2612`): a backport of FEX's
"JIT: Ensure IR ops that jump out of the JIT reset the stack" (FEX-Emu/FEX#6122). A system call or
code-entry removal that ends a block jumps to the dispatcher without dropping the block's spill
slots, and the syscall handler's fast path branches straight into the next block, so every such
exit leaked up to 32 bytes per spill slot of host stack. AVX and MMX code keeps enough values live to
spill, and `tools/fex/probes/syscall-host-stack.c` overran the 8 MB host stack after about 65000
system calls; with the patch 2000000 finish, as natively. The CPUID hunk of the upstream commit is
left out, since CPUID returns to the JIT in 2611.
- `0011-thunk-calls-mark-spilled-state`: a thunk call (every vDSO `clock_gettime`, `gettimeofday`
and `time`, and the host library thunks) spills the static registers to the guest frame and calls
host code, which clobbers the caller-saved host registers. A signal that arrived in the JIT code
after the host call returned and before the registers were refilled took the interrupted state from
those clobbered host registers: the guest handler got garbage registers, and the interrupted code
resumed with them, or FEX built the signal frame at a garbage stack pointer and crashed. The thunk
call now marks every static register as spilled (`InSyscallInfo = 0xFFFF`, as the system call
handler does) until the refill ends, and a fully spilled mark takes only RIP from the host PC and
leaves the frame's GPRs, vector registers and flags alone (the 16-bit mask could not name the
x16/x17 and v16 to v31 registers the host call clobbers). Every guest signal now saves and clears the
mark, so guest handlers and nested signals never inherit it, and every return puts back the value it
saved; 0008 restored it only for JIT code because the other paths saved none. A handler that changes
RIP restarts at the dispatcher with no mark, and thunk callbacks into guest code run with none.
`tools/fex/probes/vdso-signal-state.c` calls `clock_gettime` under a 1 kHz `SIGALRM` and checks the
values held across each call: FEX-2611 crashed in 3 of 8 runs, with 0001 to 0010 in 7 of 8; with
this patch 0 of 28, as natively. This was the "separate crash" noted under 0008.
- `0012-signal-return-applies-guest-registers`: a signal return that kept RIP threw away every
register change the guest handler made in its `ucontext`; only a changed RIP made FEX reload the
guest state from it. CoreCLR suspends threads for garbage collection with a signal and, in fully
interruptible code, runs the collection from that handler and writes the moved object references
back into the interrupted registers, so under FEX the thread resumed with pointers into the old heap.
The CurseForge agent's crashes during parallel addon scans (an `AccessViolationException` in
`Curse.Hashing.MurmurHash2.ComputeHash` or `RegexInterpreter`, or "Internal CLR error. (0x80131506)"
with a stack overflow) look like this, but they still happen with this patch, so it is not a fix for
them. When RIP is
unchanged, each guest GPR the handler changed is now written where the resumed code reads it: the
guest frame for registers the interrupted code had spilled (all of them inside a system call or
thunk call), otherwise the static host register. Unchanged registers are left alone, signals that
interrupted code outside the JIT (and not inside a system call or thunk call) keep the old
behaviour, and 32-bit frames compare and write only the low 32 bits. `tools/fex/probes/signal-register-update.c`
spins until a `SIGALRM` handler sets a register (R12, or ESI in 32-bit `rt` and legacy frames):
FEX-2611.1 with 0001 to 0011 never sees it in any of the three frame types, with this patch all
three see it on the first signal, as natively.
- `0013-path-syscalls-through-libc`: FEX passes most path system calls of the guest (`mkdirat`,
`unlinkat`, `renameat`, `renameat2`, `symlinkat`, `linkat`, `mknodat`, `fchmodat`, `fchmodat2`,
`fchownat`, `utimensat`, `truncate`, `chdir`, `chroot`, `inotify_add_watch`) straight to the kernel
with an inline `svc`, which the native userland's path hook never sees, so an x86-64 program wrote
`/opt/...` or `/root/...` to the Android root instead of the rootfs, and `cd` into a rootfs folder
failed. They now go through libc's `syscall()`, which the hook maps like every other path; without
the hook it is the same system call. `tools/tests/test_native_hook_path_syscalls.py` checks the hook
side, including that an allocator which opens files before the hook has started does not hang.
FEX also mirrors each guest signal handler with `syscall(SYS_rt_sigaction, ...)`; for `SIGSYS` the
hook records the guest handler as it does for `sigaction()` and keeps its own installed, so a
program that sets a crash handler is no longer killed by the next blocked system call
(`tools/tests/test_native_hook_sigsys_mask.py`).
- **Building and publishing.** Droid-Deck/DroidDeck-Components' `build-fex.yml` builds `tools/fex` from
this repository at a chosen ref (default `main`) with host thunks, in the same Arch Linux ARM container
with a read-only token, then a separate job replaces `fex.tzst` on Components' single `fex` release,
checks the digest GitHub stored, and records the build's version, sha256 and size in its `fex.json`
(in that order: a device that reads the old `fex.json` meanwhile gets a mismatching archive and keeps
its FEX). This repository's `build-fex.yml` only builds `tools/fex` when it changes (and on dispatch,
for diagnostic builds such as `-DDEBUG_STRACE`); nothing is published from it.
for diagnostic builds such as `-DDEBUG_STRACE`); nothing is published from it. It builds FEX's latest
release, point releases (`FEX-2611.1`) included; `build-in-arch.sh` takes the tag from `FEX_VERSION`
and compares only its four-digit release against a patch's `Fixed-upstream`.
- Releases so far: `fex-2609-r2` (no thunks), `fex-2609-r3` (thunks), `fex-2610-r1`, `fex-2610-r2`,
`fex-2610-r3`, `fex-2610-r4` (in-root resolution when openat2 is missing, exact MAP_32BIT
marking), `fex-2610-r5` (current: bundles libxxhash, which the Linux runtime does not ship; the
+85 -2
View File
@@ -1,7 +1,8 @@
# Xbox / PC Game Pass on Thor
This integrates PC Microsoft Store MSIXVC packages,
not Xbox console emulation or UWP/APPX packages.
This integrates PC Microsoft Store packages, both streamed MSIXVC packages and the legacy
EAppx containers older desktop titles still ship as. It is not Xbox console emulation and
does not run UWP titles in a packaged-app host.
## Testing on Thor
@@ -69,14 +70,96 @@ not Xbox console emulation or UWP/APPX packages.
cleanup must preserve installed game files reached through view symlinks.
10. Sign out from Xbox. Installed files should remain, account library data should
clear, and Play/download licensing should require sign-in again.
11. Install a legacy title that ships an EAppx bundle, such as Forza Horizon 4
(`9PNQKHFLD2WQ`). The download shows as a percentage rather than a streamed
install, Stop kills it rather than pausing, and a finished install registers
the executable named by `AppxManifest.xml`. Expect tens of gigabytes: check
free space first, since the preflight needs the download plus two copies of
the largest container.
Do not uninstall DroidDeck or clear application data to troubleshoot this build.
The signed APK is installed in place to retain existing Steam and store data.
## Legacy EAppx packages
A title that predates MSIXVC ships as an EAppx bundle: an archive of Appx packages, encrypted,
with an `AppxManifest.xml` per package instead of `MicrosoftGame.config`. `streaming` rejects the
format, so the installer reads the format the catalogue recorded and runs `xodus-cli
legacy-install` instead. `MSIXVC`, `EAPPX` and `EAPPXBUNDLE` are the only formats listed for a
`Windows.Desktop` package; the format is carried into the install record so a later update or
resume dispatches the same way.
The verb resolves, licenses, downloads, extracts, then hoists the manifest to the game root:
- **Resolution.** The Xbox content service is asked first. Some legacy bundles it answers with no
files at all; Windows Update (`fe3cr.delivery.mp.microsoft.com`, SOAP `GetCookie`,
`SyncUpdates`, `GetExtendedUpdateInfo2`) is asked next through the title's `WuCategoryId` and
returns the full bundle with a time-signed CDN URL. That endpoint is a public Windows Update
service and needs no Xbox credential, but it presents a certificate chained to Microsoft's ECC
Product Root CA 2018, which Android's CA bundle does not carry, so `wu-root.pem` is pinned for
those requests only. A WU result is reduced to its `.eappx`/`.eappxbundle` files: the plain
`.appx` framework packages delivered beside it (VCLibs) and the differential `.cab` metadata are
not containers this path can unpack.
- **Licensing.** The existing `license` verb runs before the first byte is fetched and must return
content keys; no keys means no install.
- **Space.** Free space is checked up front against the download plus two copies of the largest
container, because a bundle is expanded in place. Each container is removed as soon as it is
unpacked, so the peak is the archive plus its contents rather than both plus the earlier
archives. A container a stopped attempt finished is counted as reclaimable, since the retry
truncates it before writing.
- **Pause and resume.** A legacy download has no control channel: Stop kills the downloader, and
the next attempt starts an unfinished container again from byte zero, while a container that
completed is kept and reused. Nothing is checkpointed inside a container.
- **Frameworks.** An installed package gets its `PackageDependency` frameworks from the package
graph; an unpacked folder has none, so the loader fails with `0xc0000135` on
`VCRUNTIME140_APP.dll` and friends. The verb fetches each declared framework from its Windows
Update category and copies its libraries beside the title, which is where the loader looks. A
category lists one package per architecture under identifier-only names, so each is unpacked
until one declares `ProcessorArchitecture="x64"`; taking the first one puts 32-bit DLLs into a
64-bit folder and every load fails with `0xc000007b`. Only the libraries that copy put there
are withdrawn when a framework is replaced, so a title's own DLL of the same name survives.
- **Updates.** Installing over a folder that already holds a manifest lifts the new package over
the old files; on a first install an existing target is an error rather than a merge.
- **Failure detail.** A release build hides logcat from adb, so a failed install writes the
backend's stderr tail to `files/xbox-install.log` beside the app and repeats the last lines in
the failure message.
## Evidence and limits
Verified during development:
- The catalogue lists a legacy title beside the MSIXVC ones, and its detail page
offers Install with the recorded format.
- Resolution of a real legacy PC bundle on Thor without any Xbox token: Forza
Horizon 4 (`9PNQKHFLD2WQ`) through Windows Update as
`Microsoft.SunriseBaseGame_2023.1122.1704.2_neutral_~_8wekyb3d8bbwe.eappxbundle`,
85,219,173,025 bytes, with a signed CDN URL. The Xbox content service returns
no files for that product, which is why the WU route exists.
- `AppxManifest.xml` identity and executable extraction, and its rejection rules,
are unit-tested against a manifest of that shape.
- An install of that bundle completed on Thor. The 85,219,173,025-byte container
produced 79.3 GB at the game root with `AppxManifest.xml` and the package DLLs
directly beneath it, which the launcher reports as installed.
- Unpacking that bundle ran at about 40 MB/s on one thread and about 200 MB/s
across four, measured as growth of the destination folder. The container is
deleted once its members are on disk, so the peak footprint is one package at
a time rather than the archive plus everything under it. The install bubble
advances through this stage: each file's declared length is counted as it is
written, and a bundle member is one file, so the folder's growth covers it.
- A launch of this title through Xodus/ARM64 Proton reaches the loader with every declared
framework in place, then fails inside Wine: its manifest names `EntryPoint="Forza.App"`, a UWP
application that expects the app model to activate a view, which Wine has no host for. The
Play action reads that entry point from `AppxManifest.xml` and refuses the launch with a
message, and a launch that does reach the runtime reports `uwp-entry-point` rather than dying
silently. A package naming `Windows.FullTrustApplication` starts as an ordinary Win32
executable instead.
- Activation itself is not the missing piece. A DLL registered under
`HKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId\Windows.ApplicationModel.Core.CoreApplication`
is loaded by `combase.dll`, and its `DllGetActivationFactory` is called for that class. Such a
title still stops earlier: `GetCurrentPackageFullName` and `GetCurrentPackageFamilyName` are
Wine stubs, so a package has no identity, and an activation factory alone cannot supply the
`IFrameworkViewSource`/`CoreWindow` host the view asks for.
- Native AArch64 CLI execution on Thor's existing Linux runtime.
- Abstract-socket credential transport with a synthetic account on Thor; this
does not establish a real Microsoft sign-in.
+88
View File
@@ -0,0 +1,88 @@
# Launching DroidDeck games from a frontend
Frontends such as ES-DE, Daijisho, Cocoon, Beacon and iiSU can start any game in the DroidDeck library. DroidDeck can be the default player for a whole Windows or PC platform folder: it reads every file format listed below and starts the matching library game.
## Launch target
Send an explicit intent to `com.droiddeck.launcher/com.droiddeck.launcher.FrontEndActivity`. This activity is never disabled. `.MainActivity` is a launcher-icon alias and is disabled when the user picks the light icon, so do not target it.
The release variants use other package names but the same activity class and action:
| Build | Package |
| --- | --- |
| Standard | `com.droiddeck.launcher` |
| PUBG | `com.tencent.ig` |
| AnTuTu | `com.antutu.benchmark.full` |
| Ludashi | `com.ludashi.benchmark` |
An intent that names only the action `com.droiddeck.launcher.LAUNCH_GAME`, without a package, reaches whichever build is installed.
## Intents
**Action with extras**, the same shape other PC game apps use:
```sh
am start -n com.droiddeck.launcher/.FrontEndActivity \
-a com.droiddeck.launcher.LAUNCH_GAME --es app_id 620 --es game_source STEAM
```
- `app_id`: an int, long or decimal string. DroidDeck ids for added and store games are unsigned 64-bit, so send them with `--es`, not `--ei`. `--el` only accepts the signed 64-bit form, so an id above 9223372036854775807 such as `18446744073709551615` must be sent as `-1`, or better with `--es`.
- `game_source` (optional, default `STEAM`): `STEAM`, `EPIC`, `GOG`, `AMAZON`, `XBOX`, `UBISOFT`, `EA`, `ROCKSTAR`, `BATTLENET`, `ITCH`, `GAMEJOLT` or `CUSTOM_GAME`.
**View a link or a file**:
```sh
am start -n com.droiddeck.launcher/.FrontEndActivity -a android.intent.action.VIEW -d 'droiddeck://game/620'
am start -n com.droiddeck.launcher/.FrontEndActivity -a android.intent.action.VIEW -d '<file or content URI>'
```
The data can be `droiddeck://game/<id>`, `steam://rungameid/<id>`, a bare id, or a `file://`, `content://` or absolute path to one of the files below.
## Game files
**Frontend files** (the sync button at the top of the Games page) keeps a chosen folder filled with one file per installed game, named after the game, holding only its DroidDeck id. Steam and added games use `.steam`; store games use the store's own extension.
| Extension | Games |
| --- | --- |
| `.steam` | Steam games and games added from a folder |
| `.epic` `.gog` `.amazon` | Epic, GOG and Amazon games |
| `.xbox` `.ubisoft` `.ea` `.rockstar` `.battlenet` `.itch` `.gamejolt` | Xbox, Ubisoft, EA, Rockstar, Battle.net, itch.io and Game Jolt games |
DroidDeck also reads files written by other apps:
- A bare id in any of the extensions above, plus `.pcgame` and `.droiddeck`. For `.epic`, `.gog`, `.amazon` and `.pcgame`, an id DroidDeck does not know falls back to the store's product id (GOG) and then to the game's title from the file name.
- Daijisho player templates (`.steamappid`) with a `[steamappid] <id>` line.
- Windows Internet Shortcuts (`.url`) whose `URL=` is `steam://rungameid/<id>`.
- `.exe` and `.bat` files. DroidDeck starts the library game whose folder holds the program. A program that belongs to no library game is not run; add its folder in DroidDeck first.
## Frontend examples
**ES-DE** (`ES-DE/custom_systems/es_find_rules.xml`):
```xml
<emulator name="DROIDDECK">
<rule type="androidpackage">
<entry>com.droiddeck.launcher/com.droiddeck.launcher.FrontEndActivity</entry>
</rule>
</emulator>
```
and in `es_systems.xml` for the `steam` or `windows` system:
```xml
<command label="DroidDeck">%EMULATOR_DROIDDECK% %ACTION%=android.intent.action.VIEW %DATA%=%ROMSAF%</command>
```
`%ROMPROVIDER%` works as well. DroidDeck reads the file through the URI, or through the shared-storage path behind it when the URI grants no access.
**Daijisho** player:
```text
-n com.droiddeck.launcher/.FrontEndActivity -a android.intent.action.VIEW -d {file.uri}
```
**Frontends that inject the file's contents** can send `-a com.droiddeck.launcher.LAUNCH_GAME --es app_id <contents>` or `-a android.intent.action.VIEW -d <contents>`.
## What happens on launch
DroidDeck matches the request against a fresh library scan and starts the game the same way its own Play button does, through Steam or without Steam as the game is set up. A cold launch boots the session straight into the game. A warm launch hands the game to the running Steam session. When the game exits, DroidDeck returns to the frontend that started it.
+3 -2
View File
@@ -1449,8 +1449,9 @@ State: **main = `90c7574`** (PR #14 merge), main build run 35895701784. No tag,
- A runtime script must be named `bannerlator-*` or CI never packages it.
- `gh release create --target` needs the full sha.
- A proot bind is invisible to a program's "Computer" list; put what users need under home.
- The compositor decides its driver and its HDR gate once per app process - anything that changes
them applies after the app is fully closed, and the UI must say so.
- The compositor decides its driver once per app process - anything that changes it applies after
the app is fully closed, and the UI must say so. Its HDR gate follows what the device can present,
so the HDR setting itself switches during a session.
- Bannerlator's File Manager ports mechanically (`port_fm.py` anchors) once the container hooks
are cut; do not hand-edit 2,500 lines.
- Deleting a release asset on GitHub can drop a sibling asset - re-list and restore.
+6 -5
View File
@@ -19,10 +19,6 @@ Links of the form `droiddeck://settings/<section>` open a Settings section direc
| Skip GL error checks | Settings › Performance (`droiddeck://settings/performance`) | |
| gamescope: realtime GPU queue | Settings › Performance (`droiddeck://settings/performance`) | gamescope |
| Hold the GPU at its top clock | Settings › Performance (`droiddeck://settings/performance`) | gpu, clock, max |
| RAM cap | Settings › Performance (`droiddeck://settings/performance`) | ram, memory |
| VRAM cap | Settings › Performance (`droiddeck://settings/performance`) | vram, memory |
| Compress idle game memory | Settings › Performance (`droiddeck://settings/performance`) | zram, swap, memory |
| Compress Steam while a game runs | Settings › Performance (`droiddeck://settings/performance`) | zram, swap, memory |
| Clear cached apps before a session | Settings › Performance (`droiddeck://settings/performance`) | memory, ram, crash, sleep, killed |
| Background apps during a session | Settings › Performance (`droiddeck://settings/performance`) | memory, ram, background apps |
| Memory readout | Settings › Performance (`droiddeck://settings/performance`) | memory, ram, overlay |
@@ -48,6 +44,8 @@ Links of the form `droiddeck://settings/<section>` open a Settings section direc
| Launcher orientation | Settings › Launcher (`droiddeck://settings/launcher`) | rotate, portrait |
| Session orientation | Settings › Launcher (`droiddeck://settings/launcher`) | rotate, portrait |
| Fullscreen | Settings › Launcher (`droiddeck://settings/launcher`) | |
| Swipe between pages | Settings › Launcher (`droiddeck://settings/launcher`) | gesture |
| Controller haptics | Settings › Launcher (`droiddeck://settings/launcher`) | vibration, rumble |
| Dual screen launcher | Settings › Launcher (`droiddeck://settings/launcher`) | thor, second screen, bottom screen |
| Warn when storage is low | Settings › Launcher (`droiddeck://settings/launcher`) | |
| SteamGridDB API key | Settings › Launcher (`droiddeck://settings/launcher`) | artwork, steamgriddb |
@@ -67,6 +65,8 @@ Links of the form `droiddeck://settings/<section>` open a Settings section direc
| --- | --- | --- |
| Storage | Tabs › Storage | sd card, space, uninstall, disk |
| Syncthing | Tabs › Syncthing | syncthing, saves |
| Decky | Tabs › Decky | plugins, plugin store, homebrew, loader |
| Boot movies | Tabs › Boot movies | startup movie, boot video, animation, steamdeckrepo |
| Download speed tier | Tabs › Downloads | download, speed, bandwidth, slow |
| Downloads at a time | Tabs › Downloads | download, parallel, queue, at once |
| Tabs | Tabs › More | tabs, hide, reorder, agent, stores, edit tabs |
@@ -79,6 +79,7 @@ Links of the form `droiddeck://settings/<section>` open a Settings section direc
| Frame generation | In-game menu › Display | lsfg, lossless, fps |
| Scaling filter | In-game menu › Display | upscale, fsr, sharpness |
| Performance HUD | In-game menu › Performance HUD | fps, counter, overlay, performance |
| Hold the GPU at its top clock | In-game menu › Performance HUD | gpu, clock, max |
| Touchscreen | In-game menu › Controller | touch, mouse, direct, touchpad, click |
| On-screen controls | In-game menu › Controller | on-screen, controls, touch controls, buttons |
| Steam touch layout | In-game menu › Controller | touch layout, edit layout, on-screen |
@@ -97,7 +98,7 @@ Links of the form `droiddeck://settings/<section>` open a Settings section direc
| Setting | Where | Also matches |
| --- | --- | --- |
| Session display | Steam or Desktop options (swipe up) › Display | resolution, scaling, hdr, refresh |
| Session display | Steam or Desktop options (swipe up) › Display | resolution, scaling, hdr, refresh, zero-copy |
| Graphics drivers | Steam or Desktop options (swipe up) › Display | turnip, driver, gpu, adreno, mali |
| Offline mode | Steam or Desktop options (swipe up) › Steam | offline, steam |
| Microphone | Steam or Desktop options (swipe up) › Audio | microphone, voice |
+3 -3
View File
@@ -6,21 +6,21 @@ DroidDeck exposes installed Steam titles and AddedGames through a canonical laun
droiddeck://game/<unsigned-decimal-game-id>
```
The ID is the value accepted by `steam://rungameid/`, including an AddedGames shortcut ID that occupies the unsigned 64-bit range. The app accepts only the exact URI form and only after a fresh library scan finds that game. The deep link does not accept paths, Steam URLs, extra parameters, leading zeroes, or IDs outside the unsigned 64-bit range. Frontends that scan files can instead pass a file or content URI for an exported `.droiddeck` launch file.
The ID is the value accepted by `steam://rungameid/`, including an AddedGames shortcut ID that occupies the unsigned 64-bit range. The app accepts only the exact URI form and only after a fresh library scan finds that game. The deep link does not accept paths, Steam URLs, extra parameters, leading zeroes, or IDs outside the unsigned 64-bit range. Frontends that scan files can instead pass a file or content URI for an exported game file. See [Launching DroidDeck games from a frontend](../frontend-integration.md) for every accepted intent and file format.
Each game page's **Shortcut** menu offers **Add to home screen** through Android's pinned-shortcut request and **Copy launch link**. When a launcher invokes `ACTION_CREATE_SHORTCUT`, DroidDeck opens the Games page and returns Android's standard shortcut result after the user chooses a game.
With the debug app installed, exercise link routing with an installed game ID from the current library:
```sh
adb shell am start -n com.droiddeck.launcher/.MainActivity \
adb shell am start -n com.droiddeck.launcher/.FrontEndActivity \
-a android.intent.action.VIEW -d 'droiddeck://game/620'
```
Open the standard shortcut picker with:
```sh
adb shell am start -n com.droiddeck.launcher/.MainActivity \
adb shell am start -n com.droiddeck.launcher/.FrontEndActivity \
-a android.intent.action.CREATE_SHORTCUT
```