Skip to content

Release the WebGL context in ChartView.destroy()#123

Merged
Alek99 merged 1 commit into
mainfrom
claude/webgl-context-release
Jul 21, 2026
Merged

Release the WebGL context in ChartView.destroy()#123
Alek99 merged 1 commit into
mainfrom
claude/webgl-context-release

Conversation

@masenf

@masenf masenf commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

A full-payload republish rebuilds the view (destroy + new ChartView, hence a new GL context), and browsers cap live contexts (~16 in Chrome). destroy() freed GPU resources but never released the context itself, so destroyed contexts lingered until GC and — under repeated republishes, e.g. an on_view_change-driven figure refresh — tripped the browser's "too many active WebGL contexts" eviction.

destroy() now releases the context via WEBGL_lose_context after freeing resources; the context-lost listeners are already removed and _destroyed is set, so the resulting event starts no recovery. Rebuild the committed static bundles and record the behavior in the dossier (§18) and renderer-architecture (R8).

A full-payload republish rebuilds the view (destroy + new ChartView, hence a
new GL context), and browsers cap live contexts (~16 in Chrome). destroy()
freed GPU resources but never released the context itself, so destroyed
contexts lingered until GC and — under repeated republishes, e.g. an
on_view_change-driven figure refresh — tripped the browser's "too many active
WebGL contexts" eviction.

destroy() now releases the context via WEBGL_lose_context after freeing
resources; the context-lost listeners are already removed and _destroyed is
set, so the resulting event starts no recovery. Rebuild the committed static
bundles and record the behavior in the dossier (§18) and renderer-architecture
(R8).
@codspeed-hq

codspeed-hq Bot commented Jul 21, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 94 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing claude/webgl-context-release (efdf4f0) with main (c2a61d8)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown

Greptile Summary

This PR releases each WebGL context when its chart view is destroyed. The main changes are:

  • Calls WEBGL_lose_context after deleting GPU resources.
  • Rebuilds the browser and standalone static bundles.
  • Documents context release in the renderer design notes.

Confidence Score: 5/5

This looks safe to merge.

No blocking issues found in the changed code.

No files need additional attention.

T-Rex T-Rex Logs

What T-Rex did

  • The team compared pre-change and post-change Chromium recordings to verify that the ChartView flow remained the same.
  • In the post-change recording, all 20 contexts were lost immediately and the final replacement remained connected with context state ready while destroyed views did not recover.
  • The image evidence shows the replacement ChartView was successfully rendered after 20 changed-bundle lifecycle cycles and stayed connected with context state ready.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
js/src/50_chartview.js Adds guarded WebGL context release after listeners, asynchronous work, and GPU resources are cleaned up.
python/xy/static/index.js Includes the source lifecycle change in the generated browser bundle.
python/xy/static/standalone.js Includes the source lifecycle change in the generated standalone bundle.
spec/design-dossier.md Documents immediate context release during chart teardown and rebuild.
spec/design/renderer-architecture.md Updates the lifecycle cleanup design record to include context release.

Reviews (1): Last reviewed commit: "Release the WebGL context in ChartView.d..." | Re-trigger Greptile

@Alek99
Alek99 merged commit 37803c9 into main Jul 21, 2026
44 checks passed
Alek99 added a commit that referenced this pull request Jul 21, 2026
)

Semantic resolutions:
- widget.py: keep this branch's _configure_transport (callback-gated view
  transport) and adopt #98's expanded append() style-channel signature; the
  transport hook now runs on the expanded message.
- render_smoke_nonumpy.py: the probe string keeps this branch's xonly flag
  and gains #98's vstyle via baseWithStyle.
- Bundles and example assets regenerated from the merged js/src (contains
  containment + style channels + context release); the plotly comparison
  baseline stays at main's exact bytes.
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.

2 participants