Skip to content

Headless without EGL draws offscreen, as with EGL - #128

Merged
dmccoystephenson merged 1 commit into
mainfrom
feat/embed-offscreen
Nov 28, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feat/embed-offscreen

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Where a build has no EGL (Windows, macOS), a headless engine falls back to a hidden SDL3 window. Until now it drew into that window's own framebuffer, which caused three problems:

  • a readback after strata_resize could come back black, because the hidden window's size changes asynchronously and follows display scaling;
  • the window's RESIZED events leaked out of a surface that is documented to have no platform events;
  • depth readback was unsupported.

With this change, the hidden window natively only holds the GL context:

  • the engine draws into the offscreen target at exactly the requested size, and strata_resize sets that size;
  • poll_event returns only injected events;
  • present does nothing.

Browsers keep drawing the hidden canvas directly. The ABI is unchanged.

Changes

  • src/platform/sdl_surface.cpp: the non-EGL headless path renders offscreen, ignores the hidden window's own events and has a no-op present.
  • include/strata/strata.h, ARCHITECTURE.md: the headless surface contract is documented for both paths.
  • examples/embed-offscreen: a plain-C host that draws into its own buffer with injected input. It is registered as the strata-embed-offscreen test (--check) and exits with 77 (skipped) where no headless surface can be created.
  • CHANGELOG.md: Unreleased entry.

Testing

  • strata-embed-offscreen --check passes on EGL and on the stand-in for a non-EGL build (SDL's offscreen video driver). Before this change it failed six checks on the stand-in.
  • The goldens rendered through the stand-in match the EGL run: 36 of 37 pass on both. tex_globe_sun is the known local Mesa 21 difference.

drafted by Claude on behalf of Daniel Stephenson

🤖 Generated with Claude Code

https://claude.ai/code/session_01LYNeunMSrWW3U3RS97BYKD

Where the build has no EGL (Windows, macOS) a headless engine falls back
to a hidden SDL3 window. It drew into that window's own framebuffer, so
a readback after strata_resize could come back black (the hidden
window's size changes asynchronously and follows display scaling), the
window's RESIZED events leaked out of a surface documented to have no
platform events, and depth readback was unsupported.

Natively the hidden window now only holds the GL context: the engine
draws into the offscreen target at exactly the requested size, resize
sets that size, poll_event returns only injected events, and present
does nothing. Browsers keep drawing the hidden canvas directly. No ABI
change.

examples/embed-offscreen is a plain-C host that draws into its own
buffer with injected input; it runs as the strata-embed-offscreen test
(--check, skipped with 77 where no headless surface can be made). It
passes on EGL and on the stand-in (SDL's offscreen video driver), and
failed six checks on the stand-in before this change. Goldens through
the stand-in match the EGL run (36 of 37 pass on both; tex_globe_sun is
the known local Mesa 21 difference).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LYNeunMSrWW3U3RS97BYKD
@dmccoystephenson
dmccoystephenson merged commit c9b860e into main Nov 28, 2026
11 checks passed
@dmccoystephenson
dmccoystephenson deleted the feat/embed-offscreen branch November 28, 2026 20:52
dmccoystephenson added a commit that referenced this pull request Nov 28, 2026
* Release prep for v0.12.1

Moves the project version, CHANGELOG, README status, Python package
version and the example kit.conf to 0.12.1. The release carries the
headless offscreen fix for builds without EGL (#128); no ABI change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LYNeunMSrWW3U3RS97BYKD

* Pin the v0.12.1 libraries in the Python binding

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LYNeunMSrWW3U3RS97BYKD

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant