mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-02 13:30:26 +01:00
f816e1f926
`MetalRenderer::render_to_image` rendered a window's screenshot into the layer's next drawable. Since macOS windows began presenting through a `CAMetalDisplayLink`, the display link owns the layer's drawables, and calling `nextDrawable` raises `CAMetalLayerInvalidOperation: -nextDrawable should not be called when using CAMetalDisplayLink`, which aborts the process. Every caller of `Window::render_to_image` on a live macOS window crashed on its first screenshot, which broke automated UI testing in apps built on GPUI. This renders the screenshot into a texture of its own instead. It moves the offscreen path that `render_scene_to_image` already used for headless rendering into a shared `render_offscreen` helper, including the blit that managed textures need on Intel Macs, and has `render_to_image` call it at the layer's drawable size. Nothing is presented, so taking a screenshot no longer touches what the display link draws. Tested by taking automation screenshots of a running GPUI app on macOS, which aborted before this change and succeed with it. Release Notes: - [GPUI] Fixed a crash when capturing a macOS window with `Window::render_to_image` while a display link drives its layer --------- Co-authored-by: Anthony Eid <hello@anthonyeid.me>