Compare commits

...
@@ -0,0 +1,118 @@
# Adreno 740 frame loss when acquire fences are unavailable
**Experimental recovery on one Thor workload, not a shipping fix.** The December 3, 2026, matched test improved actual display presents from 21.08 to 37.42 FPS. The safety fallback stays in place.
## Reproduction and controls
- AYN Thor, Adreno 740, Android 13, Linux 5.15; rc6 runtime. Official Bright Family House demo, same house scene. Game target 120 FPS, VSync off, Steam limiter off, display at 60 Hz.
- [DD-Turnip v1.1.0](https://github.com/Droid-Deck/Drivers/releases/tag/DD-Turnip-v1.1.0), Linux Mesa `15c6fd6181711ab13fe71fe711085287027f80df`, Drivers recipe `27d6917cf4243f04775b243769bd3e0cf09b3bdc`. Stock Linux library SHA-256: `417e0d92d804c20f05b1d882f18508e6f2dd42da02a397a14ebd79f02ba22e54`.
- Android's process guard was off only for the early historical A/B and restored afterward. The modern tests use normal OS protection. Keep that state for further tests.
## Measurements
**Controlled build comparison.** Source and DroidDeck compositor rates are separate counters. Neither independently confirms display presents.
| Tested build | Path under test | Source FPS | Compositor FPS |
| --- | --- | ---: | ---: |
| [`11af78340a536bc1566c1577238204fafbdee69f`](https://github.com/Droid-Deck/DroidDeck/commit/11af78340a536bc1566c1577238204fafbdee69f), #3560 | Before the missing-fence guard | ~42 | ~42 |
| [`aab15f31462c7031a3d73647713a7401c4079271`](https://github.com/Droid-Deck/DroidDeck/commit/aab15f31462c7031a3d73647713a7401c4079271), #3427 | Safe copy when no acquire fence arrives | ~42 | ~21 |
| [`affb0da37fa73bac99063e590d9eb630d6dc2d98`](https://github.com/Droid-Deck/DroidDeck/commit/affb0da37fa73bac99063e590d9eb630d6dc2d98), #3623 | Modern reference; drop persists | ~42 | ~21 |
**Independent display-present samples.** These were separate runs from the counters above. Bars show about two actual presents/s per block.
```text
Pre-guard reference (direct eligible) 38.19 ███████████████████
Modern missing-fence copy fallback 21.09 ███████████
Modern native zero-copy explicitly OFF 21.02 ███████████
```
The native zero-copy OFF run also had HDR off. The observed copy-wait measure was about 46 ms. This is consistent with the copy/wait path pacing display updates, but does not establish that the wait is the only cost. The pre-guard rate is a performance reference, not evidence that unfenced direct scanout is safe.
**Direct-route evidence.** In a separate capped sample of the same house, native Wayland FROG reported `flip:true` and Gamescope forwarded 480 additional frames while compositing zero. These are Gamescope events, not display presents or proof of host direct scanout. A neutral probe using the same stock Linux library digest as the game exported a real, pending Vulkan `SYNC_FD`. That shows export capability on this device, not that the game exported a present fence or that the host accepted one.
## Opt-in prototype checkpoints
| Layer | Experimental artifact | Verified so far |
| --- | --- | --- |
| Linux Turnip producer | [Build](https://github.com/Droid-Deck/Drivers/actions/runs/47141995501), [artifact](https://github.com/Droid-Deck/Drivers/actions/runs/47141995501/artifacts/15745379965), recipe `6c85b9ace776078ed70f68f2b91394dbdb1e47e9` | Linux-only v1.1.0 diagnostic. Archive SHA-256 `c4663695ba1a8ec40d6f7ea92d469cf415af731c0aabddbc5fbe4afa5ce2b7c3`; library SHA-256 `df658d5298b991cd2717dabd91199707f1602b1ce1851b2b3ce38258418fcb37`. WSI compilation and focused protocol/semaphore tests passed. |
| Gamescope receiver and relay | [Build](https://github.com/Droid-Deck/DroidDeck/actions/runs/47141802134), [artifact](https://github.com/Droid-Deck/DroidDeck/actions/runs/47141802134/artifacts/15743359314), source `666d86b4851d7f8777575b64ef0b125f45467181` | Test-only relay build passed. |
| Android host | [Build](https://github.com/Droid-Deck/DroidDeck/actions/runs/47143273178), [artifact](https://github.com/Droid-Deck/DroidDeck/actions/runs/47143273178/artifacts/15746510922), source `3b274746fbad6061c9182338908f7115f43d0ab3` | Paired host build and probe fixture passed in CI. |
The paired capped **OFF** control recorded **730 actual presents over 24.337 s (30.00 FPS)**; a separate 10 s counter window recorded **301 layer copies and no host direct admissions**. Do not compare this capped control directly with the uncapped measurements above.
Two **ON** attempts failed closed before the host could bind the peer to the actual Gamescope process. The guest marker was missing or unusable; a second marker was not observed before cutoff. A wrapper marker can correspond to an early `gamescope --version` invocation, not the real Wayland backend. **No gate was armed, no native acquire fence was accepted, and no ON FPS result is available.**
**16:23 UTC, read-only identity follow-up.** The compositor's direct socket peer credentials (`SO_PEERCRED`) identified one actual Gamescope client. The first read missed the live sample because the timestamp parser did not handle a padded epoch field; the correction passed an offline check. A later read, from an app-run native helper under the same UID, showed that the live peer's `/proc/<peer>/exe` was the packaged guest loader, `libddexec.so`. Its executable inode did not match the SHA-verified staged Gamescope binary. The sampled process reported no tracer and did not have the obvious session root as its parent. The probe tool did not capture mappings or process start time; that is a tooling gap, not evidence that access was denied. The device was restored to official idle with the gate clear. No FPS outcome changed.
**16:31 UTC, launcher identity prototype.** Source tracing shows that the broker receives the dedicated worker PID before it releases the worker to run, and that the PID survives the loader's exec. That alone is not attestation: general guest-supplied broker arguments cannot identify an approved Gamescope launch. The experimental host grant binds the same-process broker and compositor to a launch epoch, PID and process start time. It checks the exact staged executable checksum and approved launch arguments (rejecting `--version`), then requires a live pidfd and the exact executable mapping's inode and path. The grant expires after ten minutes and can be revoked. This is a narrow test gate, not a claim about security between arbitrary processes with the same UID.
The Android ARM64 gate compiled with the experiment enabled and disabled. The actual Kotlin/Java launch helper compiled against the Android SDK and a stub; targeted argument checks and native identity tests under sanitizers passed. Exact peer mapping and pidfd compatibility on the Thor remain unproven. The next step is the authorized artifact-only full host build. There is no new hardware, fence-acceptance, or FPS result.
**About 16:39 UTC, full host build started.** The [artifact-only host run](https://github.com/Droid-Deck/DroidDeck/actions/runs/47152083922) pins `dda7301a4cc50c89532c80751169d4bb95b0cafe`. The app negotiates and issues the test grant for one session, without a manual property. The production workflow is unchanged and the run has no release credentials. A Linux fixture using real proc data and pidfds checked executable mapping and start time, revocation before GO, unmapping, and process exit. Native sanitizer checks passed with leak detection disabled only in the test sandbox. The hosted APK build and Thor acceptance and performance measurements are still pending.
**16:51 UTC, signed Thor run.** The [host build](https://github.com/Droid-Deck/DroidDeck/actions/runs/47152083922) for `dda7301a4cc50c89532c80751169d4bb95b0cafe` passed. The test APK was signed locally and its certificate verified against the official build. There was no public release. The Thor consumed both one-shot flags and all four exact overrides, and Steam reached READY. The app broker's dedicated worker PID matched both Gamescope connections reported by the compositor's socket peer credentials. The earlier, short-lived `gamescope --version` process had a different PID. This confirms PID continuity on the real launcher path, not full launch or artifact admission.
No experimental worker reservation, bind, or pidfd-denial marker appeared. The test failed closed before the demo, so the missing marker does not identify the denial stage or establish mapping or fence behavior. No fence was accepted and no uncapped comparison ran. The official `11af783` build was restored to idle with all test gates clear and the Android process monitor on. Next, add bounded stage/reason labels for setup admission without changing gate behavior.
**Signed diagnostic run: first rejection identified.** The [host build](https://github.com/Droid-Deck/DroidDeck/actions/runs/47156328556) and [artifact](https://github.com/Droid-Deck/DroidDeck/actions/runs/47156328556/artifacts/15752691568) for `925e40c5ab0422bc143e6289936442dbd82e9a85` passed CI; the locally signed APK's certificate matched the official build. On the Thor, admission logged `ENABLED` then `MATCH_ARGV`. The expected broker acknowledgment, owner, expiry, exact guest executable, and canonical guest root checks passed. Strict argument matching was the first rejection, before native worker reservation or mapping checks. The earlier signed run already established that the real worker PID survives into the compositor connection; this diagnostic isolates a different check.
The game and cap settings were not changed. No native fence or performance result was produced. The official `11af783` build was restored to idle with all test gates clear and the Android process monitor on. Next, identify which allowed argument differs before changing any guard.
**Live argument classification, update at about 17:16 UTC.** In a bounded read-only observation of the same signed diagnostic setup, a fresh real broker worker under the app UID matched both Wayland peer connections. The Wayland backend, HDR and ordinary options, single argument delimiter, and final `steam` argument were as expected. The live child-script token referred to `droiddeck-session` but did not match either literal spelling currently allowed. The kernel's command-line representation can differ from the broker input, so this is a candidate explanation for the rejection, not proof of the exact input mismatch.
Next, compare the pinned launcher resolver with the broker matcher. Only if the identity is established, require that exact canonical app-owned child script; do not accept a basename match. Wrong inode, path escapes, and trailing options must still be rejected. No game settings or FPS data changed. Official `11af783` was restored and the gate remained clear.
**Launcher source trace and narrow follow-up build.** The loader compacts post-exec arguments and zero-fills the unused tail, while the handoff serializes the original arguments. Bash receives the translated shebang script path, and the pinned launcher passes its `$0` after the delimiter. The test gate now accepts only the literal guest script path or its exact suffix under the app-issued configured or canonical root. The script must still be the expected regular, non-symlink file at its canonical identity. The final `steam` argument remains exact, with no extra arguments, generic path match, or basename fallback.
The Kotlin JUnit path and argument cases passed. The dedicated [artifact build](https://github.com/Droid-Deck/DroidDeck/actions/runs/47160918459) at `773042fe0806e8b7bdde712d99fe56bdaa557239` is in progress. The production workflow and fence safety checks are unchanged. The alternative spelling at the broker was not independently captured, so the gate may still refuse the launch. There is no new fence acceptance or FPS result.
**Signed follow-up: script and launch arguments now pass.** The full [host build](https://github.com/Droid-Deck/DroidDeck/actions/runs/47160918459) and [artifact](https://github.com/Droid-Deck/DroidDeck/actions/runs/47160918459/artifacts/15755770380) for `773042fe0806e8b7bdde712d99fe56bdaa557239` passed CI, and the locally signed APK's certificate matched the official build. The Thor recorded `ENABLED → QUALIFIED → NATIVE_STARTTIME → PUBLISH_NATIVE`. The last label means publish failed after the native rejection; it does not mark success. The trusted child script and Gamescope launch arguments passed, and the pinned native file checks and `pidfd_open` did not reject. Reading or parsing the worker's start time returned zero before reservation, mapping, or binding.
The game was not run, cap settings were unchanged, and no fence or FPS result was produced. Restoration was started but had not yet been verified at this checkpoint. Next, distinguish opening and reading the process stat record from parsing it, without bypassing the lifecycle guard.
**Start-time follow-up and verified restoration.** The same dedicated worker connected to the compositor 91 ms after the rejection. That rules out the simple explanation that it had already died, but does not distinguish read access from parsing. Source review found that Android common 5.15 emits the normal start-time field (field 22), and Bionic supports the `e` flag in the file-open mode. The current diagnostic still groups open, read, parse, and zero-field failures together. A raw pre-GO read has not yet been verified. The official `11af783` build was verified idle with the process monitor on and the test flags and inbox restored.
One design to evaluate is recording the trusted app-owned worker's self-reported start time via Binder as a candidate only. It must still match a raw live post-exec read, a live pidfd, and the exact executable mapping before the host advertises the test protocol or admits a fence. This alternate source has not been implemented or accepted.
**Worker receipt prototype implemented.** The [host artifact run](https://github.com/Droid-Deck/DroidDeck/actions/runs/47165208888) pins `2feb35aa5ecee615c642bcd2e6dbb9e29c8291c1`. The non-exported worker Binder endpoint authenticates the same-UID caller and returns a fixed-size record of the worker's own PID and start-time ticks. It allows provisional registration only for pre-exec proc visibility or access errors; mismatches, read or parse errors, a zero start time, and worker death still fail closed. Before advertising or admitting fences, native code must still match the raw post-exec start time, a live pidfd, and the exact executable mapping's inode.
Android C and Kotlin test builds, the receipt payload cases, and the live Linux pidfd/proc fixture passed. The ordinary service bytecode has no receipt method. The hosted artifact and Thor validation are pending. This does not establish why the earlier pre-exec read returned zero or show any fence or FPS change.
**Signed Thor smoke test: a producer fence reached SurfaceControl.** The full [host run, attempt 2](https://github.com/Droid-Deck/DroidDeck/actions/runs/47165208888/attempts/2) passed at `2feb35aa5ecee615c642bcd2e6dbb9e29c8291c1`; the locally signed [artifact](https://github.com/Droid-Deck/DroidDeck/actions/runs/47165208888/artifacts/15756657790) matched the official certificate. Attempt 1 compiled at the same head but failed an unchanged dircache test (expected 4, saw 8). One same-head rerun passed; that does not explain the failure.
On the Thor, identity advanced `ENABLED → QUALIFIED → NATIVE_STAT_OPEN_HIDDEN → RESERVED`. The failure was in opening the pre-exec stat record in the not-visible class (ENOENT/ESRCH), not parsing it on this attempt. The live post-exec check matched start time, UID, pidfd and executable mapping, and the worker bound successfully. With the original game cap still in place, the host logged that SurfaceControl accepted a verified producer acquire fence. The following 10 s recorded **152 direct frames and 151 copied/overlay frames**. The earlier capped OFF control had zero direct admissions. These are path counters, not an uncapped FPS comparison. A matched benchmark is underway, and restoration is pending until it completes.
## Matched benchmark: measured recovery on Thor
The same privately signed `2feb35a` host and matching Gamescope and Turnip artifacts were used for both conditions. The benchmark used the same test-owned Trails: Bright Family House save and camera, 120 FPS game target, VSync off, QAM limiter flag 0, and a 60 Hz display. Android process protection remained on.
| Condition | Actual display presents (FrameTracker) | Present FPS | Frame intervals p50 / p95 |
| --- | ---: | ---: | ---: |
| Producer fence path OFF | 747 / 35.430 s | **21.08** | 49.92 / 66.58 ms |
| Producer fence path ON | 1,316 / 35.167 s | **37.42** | 16.65 / 49.93 ms |
That is **+77.5% actual display FPS** in this comparison. The earlier published good build measured about 38.19 actual FPS in the matching scene, but the binaries were different. This is not evidence of exact full recovery.
- **OFF:** Per 10 s, 421–426 source frames reached 213 compositor submits, all layer copies. Average copy waits were 45.20–45.39 ms.
- **ON:** Across three 10 s windows, source and direct counters both read 426, 425, and 426. Layer copies, full-frame copies, and copy-fence waits were all zero. SurfaceControl logged acceptance of a verified producer acquire fence.
The ON compositor counters show frame availability, not 42.6 displayed FPS; the independent present sample measured 37.42 FPS. This result does not establish absence of panel tearing, behavior with overlays, rotation, HDR, or other titles, or that the prototype is safe to ship. Production synchronization still needs negotiated support and validated acquire and release lifecycles. Both benchmark conditions reported thermal status 0 (no reported throttling).
**Rollback verified:** The official `11af783` build was idle, the original Steam 30 FPS limit at 60 Hz was restored on the default profile (limiter flag 1), and the demo configuration matched the original byte-for-byte. The Android process monitor remained on. All temporary environment values, overrides, and gates were clear. No public release was made.
## Hypotheses and next test
1. The adjacent-build drop is consistent with the missing-fence guard routing a previously fast path to copy. Explicitly disabling native zero-copy reproduces the same rate, but does not establish why the copy wait is about 46 ms.
2. A fence from the final writer, preserved through Gamescope and accepted by the host, could allow safe direct scanout. The neutral probe establishes that export is possible; the real game's present path has not been verified.
3. The immediate blocker is identity, not measured fence throughput. Test whether the launcher can report the exact Gamescope worker identity immediately before its real Wayland backend launch, then independently match it to the connected socket peer. Check live process start time and loaded mapping against the expected artifact where the tooling can capture them. Confirm the game's loaded Linux ICD separately. An early `--version` process, generic wrapper marker, process name, or command line is not sufficient. If identity remains unresolved, leave the gate clear.
Run OFF/ON/OFF with the same test binaries, shot and camera, runtime, resolution, refresh, caps and protection state. Record exact hashes and route per run. Keep the capped route check separate from uncapped performance. Fix the warm-up and sampling windows, run at least three repetitions per condition, and record actual presents and frame-time distribution separately from source and compositor rates. In each window count producer fence emits, matching Gamescope relays, host fence accepts, direct admissions, and reasons for fallback.
## Acceptance and rollback
- [ ] Verify live game renderer, Gamescope and host identities before any ON run.
- [ ] Correlate real fences with their matching attach and commit. Missing, stale, mismatched or invalid fences must still take the safe fallback.
- [ ] Show that accepted fences increase safe direct admissions and improve actual display presents or frame times against both OFF controls. Compositor counters alone do not qualify.
- [ ] Before shipping, harden trusted launch identity and session scope, verify protocol negotiation compatibility, and retain safe fallback on unsupported kernels or drivers.
- [ ] Validate motion, resize or rotation, overlays, HDR, pause/resume, swapchain recreation, and app exit for stale frames, flicker, hangs, and premature releases. Check the physical display for tearing; screenshots alone cannot rule it out. Keep current behavior if frame safety or the gain remains unproven.
- [ ] Disable the opt-in and restore stock session components afterward. No default change, release, or catalog promotion is part of this investigation.