Skip to content

fix: panes keep their WebGL renderer, and give the context back when they lose it - #39

Merged
ba2slk merged 3 commits into
mainfrom
fix/webgl-context-release
Aug 18, 2026
Merged

fix: panes keep their WebGL renderer, and give the context back when they lose it#39
ba2slk merged 3 commits into
mainfrom
fix/webgl-context-release

Conversation

@ba2slk

@ba2slk ba2slk commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Two things a scroll or a switch could leave on screen. First, a pane already in view turned white with a sad-face icon in its corner: Chromium's drawing for a canvas whose WebGL context is lost. WebglAddon.dispose() removes the canvas but leaves the context alive until garbage collection, and Chromium counts it against its per-page cap until then, so panes leaving the screen left dead contexts behind, the browser saw more than sixteen, and it force-lost the oldest live one until the garbage was collected. Detaching now loses the context explicitly through WEBGL_lose_context; eight switches between a fourteen-pane and a nine-pane session, screencast at device pixels, went from 13 white frames of 87 to 0 of 83. Second, a long scroll or a held Alt+→ across a wide canvas ended on one blank frame in the panes that arrived: they had given their renderer back on leaving the visible band and took a fresh one on return, which paints a frame late. The budget now keeps the renderer of a pane out of view while there is room under the cap and gives idle ones up least recently seen first only when a visible pane needs the slot; four end-to-end round trips over a 5600px canvas went from 40 renderer attaches to 0 after first sight. The self-check counts WebGL canvases specifically and asserts that no canvas still in the document loses its context during the held-key burst. Details are in docs/engineering-notes.md.

Generated with Claude Code

@ba2slk
ba2slk force-pushed the fix/webgl-context-release branch from 932bdad to 29da362 Compare August 18, 2026 08:03
@ba2slk
ba2slk merged commit 57f06fb into main Aug 18, 2026
2 checks passed
@ba2slk
ba2slk deleted the fix/webgl-context-release branch August 18, 2026 08:07
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