fix(core): manage device canvas context lifecycle#2742
Open
ibgreen-openai wants to merge 3 commits into
Open
Conversation
24 tasks
ibgreen-openai
marked this pull request as ready for review
July 17, 2026 13:22
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f290f10712
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deviceown and tear down everyCanvasContextandPresentationContextwrapper created through itdevice.detach()for exclusive owners that need to preserve and recover the backend handleMotivation
This started from deck.gl #10355 and the proposed deck-side cleanup in deck.gl #10356, where dropping a
CanvasContextwithout destroying it leaves resize, visibility, DPR, and position observers rooted after Deck finalization.That leak is another instance in the long-running stream of canvas-related sync/async initialization, teardown, reuse, and attachment fixes across deck.gl and luma.gl. Rather than add another cleanup layer on top of the others, this PR moves as much of the lifecycle contract as possible to the root in luma.gl: the
Devicethat creates context wrappers now owns their final teardown.Changes
Devicetracks managed canvas and presentation wrappers, destroys them in reverse creation order, and rejects new wrappers after final teardown.CanvasSurface.destroy()unregisters itself while preserving idempotent observer shutdown.destroy()performs wrapper teardown and clears the WebGL context's luma metadata.webgl2Adapter.attach()calls also retain references, and attached handles are marked borrowed.device.detach()requires exclusive ownership, destroys luma wrappers, clears backend association state, preserves the native handle, and returns it.destroy();detach()preserves them. WebGPU handle attachment remains intentionally unimplemented, but the ownership model is now defined for it.Verification
nvm useyarn installyarn lint fixyarn buildyarn testyarn website:build(cd website && yarn build)test-fast: 51 test files passed, 178 tests passed