feat(egfx): handle mid-session CapsAdvertise as decoder-recovery - #1833
Open
Greg Lamberson (glamberson) wants to merge 1 commit into
Open
Conversation
Real-world clients (mstsc on Windows 11 under load, macOS Microsoft Remote Desktop) re-emit RDPGFX_CAPSADVERTISE mid-session as a decoder-recovery sequence when their decoder loses sync. The previous handler treated every CapsAdvertise as initial setup, leaving reset_graphics_sent=true so the application's follow-up create_surface wouldn't auto-emit ResetGraphics, breaking recovery. Detect re-advertise via state == Ready at entry, silently clear surfaces + frames + re-arm reset_graphics_sent. No DeleteSurface PDU is emitted: the client has already cleared its surface state on its end and treats a stray DeleteSurface as a protocol violation, closing the connection within milliseconds. Surfaces gains reset_for_reinit(), distinct from clear(): it also resets next_surface_id to 0 so the client's subsequent CreateSurface yields ID 0, matching its fresh-state expectation. Validated against mstsc on Windows 11 and openSUSE Tumbleweed (KDE Plasma 6.6.4).
Greg Lamberson (glamberson)
deployed
to
llm-providers
August 29, 2026 01:56 — with
GitHub Actions
Active
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.
Real-world clients (mstsc on Windows 11 under load, macOS Microsoft Remote Desktop) re-emit RDPGFX_CAPSADVERTISE mid-session as a decoder-recovery sequence when their decoder loses sync. The previous handler treated every CapsAdvertise as initial setup, leaving reset_graphics_sent=true so the application's follow-up create_surface wouldn't auto-emit ResetGraphics, breaking recovery.
I detect the re-advertise via state == Ready at entry, then silently clear surfaces + frames and re-arm reset_graphics_sent. I don't emit a DeleteSurface PDU for this: the client has already cleared its surface state on its end, and treats a stray DeleteSurface as a protocol violation, closing the connection within milliseconds.
Surfaces gains reset_for_reinit(), distinct from clear(): it also resets next_surface_id to 0 so the client's subsequent CreateSurface yields ID 0, matching its fresh-state expectation.
MS-RDPEGFX does not document this recovery flow explicitly, but the empirical pattern is CapsAdvertise -> CacheImportOffer -> the server is expected to emit CapsConfirm + ResetGraphics + CreateSurface(id=0) + MapSurfaceToOutput + IDR.
I validated this against mstsc on Windows 11 and openSUSE Tumbleweed (KDE Plasma 6.6.4).