Repository navigation
android: A61, while the guest presents on its override surface, its window's X commits wait - #37
Closed
utkarshdalal wants to merge 1 commit into
Closed
utkarshdalal wants to merge 1 commit into
utkarshdalal wants to merge 1 commit into
Conversation
…'s X commits wait (A61) Wine copies an offscreen Vulkan child window into the virtual desktop's top-level after every present. On the override route that copy is black and lands on the window's own surface right after the guest's frame, so last-done-wins showed the black desktop most of the time (OMORI ~95 %, Portal 2 on Wine 9 ~83 %). While the override surface has committed within surface_update_override_hold_ms (default 500), damaged main-surface commits are held instead of shown, the newest one kept with its buffer locked. Once the override is quiet that long the held commit is shown without new X damage, so a dialog the game blocks on still appears. The README documents the two surfaces and the hold.
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.
What happens today
Every game runs inside Wine's virtual desktop, so the desktop window is the only top-level gamescope manages, and the gamenative-drm shim binds its override surface (
gamescope_swapchain.override_window_content) to it. For a Vulkan surface Wine considers offscreen (Wine 11: a swapchain on a child HWND, always; Wine 9 without XComposite: once a child window exists), Wine copies the X client window into the top-level after every present. On our route that X window never gets the guest's pixels, so the copy is black, damages the whole window, and Xwayland commits it on the main surface right after the override commit.get_window_last_done_commit()is last-done-wins across both surfaces, so the panel shows whichever finished last.Measured on a Retroid Pocket 6: OMORI (NW.js, D3D11 on a child window, Wine 11) about 95 % of displayed frames were the black desktop, Portal 2 on Wine 9 about 83 %. Setting
gamescope_surface_update_force_only_current_surface=trueon OMORI gave 476 of 476 game frames, full-screen, 60 fps. That proves the cause, but as a default it hides X content forever, for example a Wine message box the game blocks on (the game stops presenting, so nothing else would ever be shown).Upstream's WSI layer sidesteps this by not bypassing Xwayland for such windows (
canBypassXWayland), which here would put the game in its small Wine window on the virtual desktop instead of full-screen, so this keeps the direct route.What the patch does
android/patches/gamescope/0054-A61-override-commits-beat-x-commits.patch, inupdate_wayland_res()/check_new_xwayland_res():surface_update_override_hold_ms(new convar, default 500, 0 = off; envgamescope_surface_update_override_hold_ms), a damaged main-surface commit that the existing rule would have accepted is held: its presentation feedback is discarded andreceivedDoneCommitis set right away (as the existing drop path does, so frame callbacks keep flowing), but thewlr_bufferlock is kept and the entry is parked per window. Only the newest is kept; the older one's buffer is unlocked when it is replaced.update_wayland_res()at the start of the nextcheck_new_xwayland_res()(every main-loop pass, so at worst a vblank late), before that round's new commits, so X content comes back without new X damage and anything newer still lands after it. When the override commits again its frames are newer and take over.finish_destroy_win), when its surface is no longer the window's main surface, or when the existing current-surface rule would never show it (non-sRGB colour space seen, or the force convar set).surface_update_force_only_current_surfacekeeps its meaning.Why 500 ms: a game that is presenting delivers a frame every 8-50 ms and a compile/streaming hitch rarely blocks for more than a few hundred ms; longer than that is the game not presenting (dialog, pause, crash, exit), and a dialog half a second late is fine. A hitch longer than that shows the latest X content (on these titles the black copy) until the next game frame.
Two one-shot info lines per window prove the patch is live:
override-hold: window 0x... holds back main-surface commits while its override surface presentsandoverride-hold: window 0x... override quiet for 500 ms, showing the held main-surface commit.android/README.mdgets a short section on the two surfaces and the hold.Interactions checked
session-blank:): the startup blind lifts on the first commit newer than the binding; override commits are never held, so that is unchanged, and Wine's black copies can no longer lift it early. A GL guest with a dormant Vulkan swapchain (the Tomb Raider case) never commits on the override, so its X commits are never held. Exit: when the shim destroys the override, main commits are no longer "not for the current surface" and go through as before (releasing anything parked); if no new X commit comes, the parked one is shown once the hold time has passed since the last override commit, which counts as "painted after the gap" for A33's exit arm, i.e. the blind is raised, which is what exit wants. A short recreate gap (device loss, new surface) under 500 ms shows nothing held.finish_destroy_winfor the reaper kick; the release is added after the commit queue clear, independent of it.bHasHadNonSRGBColorSpace: still drops main commits outright, and a parked commit is not shown after it became set.Verified
git apply --checkonto a clean export ofgamenative(34 patches incl. this one), the same waybuild-gamescope.shapplies it, and the patched files match the tree the diff was generated from.gamescopemd5fb11fb7e4439d30d0278f1a3f8d041db) dropped into the installed payload: OMORI on Wine 11 runs full-screen with no flashing. An 8 s recording at the title screen has 0 of 460 frames showing the black desktop (before: about 95 %), 60 fps on the HUD, and the daemon publishes about 589 frames per 600 vsyncs. The log has the hold line once (override-hold: window 0x600004 holds back main-surface commits while its override surface presents) and the release line once, 510 ms later, in the gap between OMORI's first and second swapchain at startup; none after that.Note:
android/patches/diagnostics/0023-A23-present-path-diagnostics.patchalready fails to apply ongamenativewithout this change.