Skip to content

[Skia][Win32] OpenGL backend renders a blank window that freezes after a resize (Skia GL state cache not reset around the host's blit) #24795

Closed

Description

@ramezgerges

Current behavior 🐛

On Win32 with the OpenGL rendering backend, the window shows a blank (flat) client area from startup and never updates. A resize paints one correct frame, after which the image freezes again on that frame. The app itself is healthy the whole time: the message pump stays responsive (IsHungAppWindow is false), CPU keeps being spent, SwapBuffers never fails, and the frame loop keeps running and completing work.

Root cause: GLRetainedFramebuffer.BlitToDefault() performs the present with raw GL calls that rebind the framebuffer:

_bindFramebuffer(GL_READ_FRAMEBUFFER, _framebuffer);
_bindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
_blitFramebuffer(...);
_bindFramebuffer(GL_FRAMEBUFFER, 0);

Skia's GrDirectContext caches GL state, and nothing invalidates that cache. From the next frame on, Skia believes the host's retained framebuffer is still bound and draws into the default framebuffer, while BlitToDefault keeps copying the retained one over the top. The window therefore shows whatever the retained framebuffer last legitimately received — blank at startup, or frozen on the frame a resize produced.

Measured in-process with glReadPixels on the default framebuffer immediately before SwapBuffers (an external capture cannot be used: PrintWindow returns stale frames for this window, so it reports a frozen window as live and vice versa). Sampling a full row across the middle of the frame, flat meaning max-min <= 2:

before fix after fix
windowed 577/577 frames flat (blank) 531 frames with content
after maximize 2 distinct rows across 93 frames (frozen) 96/96 with content, 11 distinct rows

Vulkan and Metal are unaffected because they present their own image and never issue raw GL calls around Skia. Software is unaffected. 6.5 and 6.8 do not have this retained-framebuffer composition path.

Expected behavior 🎯

The window renders normally on the OpenGL backend, and keeps updating after a resize.

How to reproduce it (as minimally and precisely as possible) 🔬

  1. Skia desktop app on Win32 with the OpenGL backend (Win32HostBuilder.ForceRenderingBackend(Win32RenderingBackend.OpenGL); Win32 defaults to Vulkan on 7.0, which does not show the bug).
  2. Run any page with continuously changing content (a scrolling ItemsRepeater, or a TextBlock updated on a DispatcherTimer).
  3. The client area is blank. Resize the window: one frame paints, then the image is frozen again while the app keeps running.

Workaround 🛠️

Use the Vulkan backend (the Win32 default on 7.0), or the software backend.

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

Windows (Skia/Win32, OpenGL backend). The same PresentForGL path is shared by X11, Android GLES and WebAssembly/WebGL, so any host that touches GL state around present is exposed; only Win32 was verified.

Anything else we need to know? 💬

Found while investigating #24791.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions