[BUG FIX] Prevent pyglet's headless display from terminating the offscreen EGL context.#2953
Conversation
a526fdd to
1ca93db
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a526fdd7eb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
1ca93db to
1816be1
Compare
… the headless one
1816be1 to
cddfa03
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cddfa03e2e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
Description
try_get_display_sizequeried pyglet's display viaget_display(), which in a headless process creates pyglet'splaceholder
HeadlessDisplay. That object is only weakly referenced, so it is garbage-collected, and its__del__calls
eglTerminateon the shared EGL display - invalidating the live contexts of genesis's offscreen renderers(seen as
EGL_BAD_CONTEXTmid-render). It now resolves pyglet's native display backend directly, so a headlessprocess reports no display rather than spawning the headless one whose finalizer does the damage.
Separately, offscreen renderer teardown (
Rasterizer.destroy) now saves and restores the current GL context. Thecurrent context is process/thread-global; freeing one renderer makes its own context current, which previously left
another renderer mid-render stranded.
Motivation and Context
Root cause of intermittent offscreen-render failures (the flaky CI that #2951 worked around). Reproduced under EGL
(Mesa llvmpipe and NVIDIA GPU) and on Metal.
How Has This Been / Can This Be Tested?
New regression test
tests/test_render.py::test_offscreen_context_isolation: destroys one offscreen scene mid-renderof another and asserts the survivor's output is unchanged. Verified on Metal, EGL (NVIDIA GPU + Mesa llvmpipe), with
both pyglet 1.5 and 2.1.
Checklist:
Submitting Code Changessection of CONTRIBUTING document.