Repository navigation
Fix fenced Present freezes without disabling asynchronous rendering - #2
Merged
lfdevs merged 3 commits intoOct 8, 2026
Merged
Conversation
Re-execution can queue a Present request for a later MSC and leave its fence alive. Clear the one-shot callback before retrying so a restarted Sync trigger scan cannot repeatedly fire the same request. A genuine new wait installs its own callback. Port the independently tested Termux:X11 callback correction through the existing Debian quilt series. The protocol-only divisor/requeue test passes five times with the final series; omitting this correction from the restart-scan build reproduces a busy loop and missing completion.
Backport upstream f19ab94ba9c891d801231654267556dc7f32b5e0 through the Debian quilt series, preserving Olivier Fourdan attribution. A fired callback can remove other triggers, so restart from the live list head rather than dereference a saved next pointer. Apply after the Present one-shot callback correction to avoid a restart-scan livelock when re-execution queues the request for a future MSC. The combined ARM64 build passes the protocol controls and completes the full 33-scene glmark2 suite with unchanged baseline Mesa.
After Idle, the client can reuse the pixmap and reset its wait fence for another frame. The old copied request must not acquire that source again when delivering its delayed Complete notification. A second wait can overwrite blocking_event with the copied request and leave subsequent ready frames stranded. Guard the acquisition stage with !event->copy_executed. Keep the original acquisition, asynchronous rendering fences and completion scheduling unchanged. Do not add tracing, extra waits or timer workarounds. On Adreno 710 Anland/KDE, the Mesa-independent Idle/reset/Complete regression test passes five times. The exact combined quilt series completes all 33 glmark2 scenes: unchanged merged-PR96 Mesa scores 418 versus 286 with PR105 on the same server. Original packaged and rebuilt reference servers stall in the first uncapped scene.
Owner
|
Thanks for your PR. It successfully fixed the issue encountered on my device. Therefore, I changed PR lfdevs/mesa-for-android-container#105 to only retain the environment variable |
This was referenced Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was able to reproduce the freeze discussed in Mesa PR #105 on an unrooted Redmi Pad Pro 5G with an Adreno 710, using Anland and KDE Plasma Wayland. The problem was in XWayland's handling of presentation fences. Fixing it there allows unchanged Mesa with merged PR #96 to keep its asynchronous rendering path and its higher throughput.
What went wrong
A fence tells XWayland when an application's rendered frame is ready to use. In the COPY path, XWayland copies that frame into the window and tells the application that its source buffer is idle. The application is then allowed to reuse the buffer for another frame.
However, XWayland can still owe a completion notification for the old frame. When it returns to send that notification, it was checking the source fence again. By then, the application may have reset that fence for its next frame. XWayland therefore starts waiting for the wrong frame and can leave subsequent presentation requests blocked indefinitely.
There is also a separate callback-lifetime problem: a fence callback must be disarmed before retrying a Present request. Retrying can schedule the request for a later display tick rather than destroy it immediately. Leaving the callback armed allows it to run again for the same request.
Changes
The fixes are separate commits and follow the repository's existing Debian quilt packaging:
xwl_present_execute(), skip acquisition whenevent->copy_executedis already true. Acquisition still happens before the original copy; the later completion notification keeps its existing scheduling.The callback fixes alone did not resolve the original benchmark stall. The COPY correction is also needed. Conversely, a negative-control build with the COPY fix and the upstream restart scan, but without the callback correction, reproduced the callback loop.
These changes do not disable render fences, force a CPU-side wait, change Mesa's presentation worker, increase buffer limits, or introduce a timer workaround. No temporary profiling code is included. The Present protocol already permits Idle before Complete: https://gitlab.freedesktop.org/xorg/proto/presentproto/-/raw/master/presentproto.txt
Validation
The test setup was Android 14 / kernel 5.10.209, Anland 5.13.3, Plasma 6.3.6, KWin 6.3.6-95, and XWayland 24.1.6-91. Benchmark windows were 800x600 on the tablet's approximately 60 Hz display. KWin's Mesa was kept unchanged while switching the client's private Mesa libraries. No screen recording or profiler ran during the performance comparisons.
Both protocol cases passed five times with the submitted series, and both full benchmark runs completed with exit code 0. Results below use the same patched XWayland for both Mesa variants:
The short glmark2 suite contains build without VBO, build with VBO, and texture. It is not a full-suite score. Full-suite throughput with the submitted series was about 46% higher than the PR #105 comparison, and matched the separately tested COPY-only fix's score of 418.
A separate diagnostic run recorded 1,227 Present requests on the final build. All 1,227 used
ASYNC | COPYand nonzero wait fences. That run is excluded from the performance table; its purpose was to verify that the fix really retains fenced asynchronous presentation.To reproduce the benchmark failure on the original server, use merged-PR-96 Mesa with uncapped presentation:
Run the same command with the patched server and the same Mesa. It should complete rather than stall in the first scene. For the uncapped gears comparison:
Synchronized glmark2 also completed with the final series, but its scene rates varied around 40-59 FPS.