Repository navigation
fix(room): fix WebGL leaks and context loss, avatar fallbacks, and spatial physics - #46
Merged
Merged
Conversation
Quest-Claim: 866dd43e79628f90
…s per frame Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the Remote Control follow-up quest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sher, and keep the fallback avatar Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ves as it leaves Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Maintainer decision (2026-11-25, /quest-run):
(Written by Claude Opus 5.5 with high) |
… a dead link Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 26, 2026 04:44
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 29 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Finishes
quest/m1/webgl-physics.md(deleted here).Problem
From the 2026-11-25 audit, re-checked against
mainafter the MoQ bump (#42). All of these were still present:MeshBuffer, and each of the three renderers cached a VAO per mesh in a map that was never evicted. That leaked 3 VAOs (plus 3 buffers) per join/leave and re-ranbufferDatawhenever a drag or zoom crossed the subdivision threshold.Canvas.close()also left contexts for GC to collect, even though browsers cap live contexts.AudioContextand fetched all 7 notification.opusfiles, even on the lobby page, which already has aSound.u_avatarActivetested theSignalobject, so it was always1. The deadavatar = new Image()field stopped#runAvatarfrom ever falling back toApi.randomAvatar().Vector.normalize()returnedNaNfor a zero vector, so a tile leaving from exactly(0, 0)got NaN bounds. Tiles with identical centers never separated.Broadcast.tickdecayeddeformVelocityandzoomDeformtwice per tick.setInterval(1000/60)even in hidden tabs, and its step count was tied to timer delivery rather than elapsed time.peers.positionsrecord, which dropped requests to other peers. Requests were also never removed, so a resubscribe replayed stale moves.Approach
gl/mesh.ts,gl/context.ts):GLContextowns one static unit quad and one 20×20 grid. Each renderer binds both once throughMeshesand draws the grid only whileDeform.activeis true. The duplicatea_texCoordattribute is dropped because it always equaleda_position.canvas.ts,video.ts,space.ts):Canvas.contextis aSignal<GLContext | undefined>. It is cleared onwebglcontextlost(withpreventDefault) and rebuilt onwebglcontextrestored. The background renderer, the Space renderers, and each tile'sTexturesare effects on that signal, and the upload effects re-fill textures from the current frame, avatar, and meme.Canvas.close()frees its context throughWEBGL_lose_context.Canvas.scenereplacesonRender. Without a scene (non-room pages), the background is drawn once and then redrawn only on resize or visibility change; a Space sets the scene to animate. Rendering already stopped while the document was hidden.Profiletakes the page'ssoundwhen it has one (the lobby passes the room's) and creates a muted one only where none exists.Soundnow loads notification sounds on first use.u_avatarActivereadsavatarSize.peek(), and the dead field is removed, so the random-avatar fallback works. The loader keeps the last URL (real or random) while user details are missing or empty, loads each URL once (SVGs at a fixed 512px), and re-uploads it on resize or context restore, so a tile's fallback face never changes and never flashes black.physics.ts):Steppercounts fixed 60Hz steps from@moq/clocktime on each rendered frame. Physics therefore pauses whenever rendering does and runs at the same speed at any frame rate; a stall drops the backlog past 4 steps.Broadcast.step()(physics) is now separate fromtick(now)(time-based fades).Deformkeeps one decay pass at the product of the old two (0.8 drag, 0.76 zoom), so the feel is unchanged.repel()breaks identical-center ties horizontally.normalize()returns zero for a zero vector, and a tile at the exact center leaves downward.peers.ts):requestmerges into the record (copying the dragged position) and skips a move the peer already made unless it reverses one in flight.settledrops a request once the peer publishes that x/y/s, anddropremoves it when the peer's handle goes away. A local publisher's moves are cleared as soon as it leaves the space, so a reused publisher (a new screen share) can't replay them.Space.addandBroadcast.#runTargetare registered only for their role, which removes the "Effect did not subscribe" warnings. Aremove()that finishes afterSpace.close()no longer splices index-1out of the rip list.Impact
Canvas.onRender,Canvas.gl, andCanvas.glContextare replaced byCanvas.sceneandCanvas.context.Broadcast.mesh,deformVelocity, andzoomDeformare replaced byBroadcast.deform.Video's texture fields move toVideo.textures.peers.positionskeeps its shape; it now holds every pending move and drops settled ones.Alternatives
dtinstead of using fixed steps. Rejected: the spring/damping constants were tuned per 60Hz step, and fixed steps keep them exact.Caused by
No single PR. The bugs date from the WebGL renderer and deform-mesh work ported in before this repository's history, and the 2026-11-25 audit (found by check) surfaced them.
Follow-ups
room/index.tsapplies incoming moves unconditionally, andlocked()keys on a handle that is always published. Its Plan now also carries the per-move confirmation ID decided below. No open decisions.Relatedlink to this quest fromquest/m1/peer-avatars.md(merged from main), since this PR deletes the quest.Overlap
app/src/room/sound.ts(the lines next to the notification loader this PR makes lazy) andapp/src/sup.tsx(separate hunks). Whichever PR lands second resolves a small textual conflict.Decisions
Maintainer, 2026-11-25 via /quest-run (comment):
quest review --accepton e108e35. The per-move confirmation-ID fix changes thehang/location.jsonwire format and must work with older clients, so it is folded intoquest/m1/remote-control.md's Plan.quest/m1/remote-control.mdfollow-up: ✅ keep it (rejected: drop it).Validation
quest gate just check: Quest validation, tsc, Biome (one pre-existing warning incomponents/updater.tsx), API and app tests (all pass, including the newphysics.test.tsandpeers.test.ts, which useClock.Manual).bun run buildsucceeds. Re-run on the head merged with main (fix: recover camera and microphone input toggles #33, fix: preserve speaker gain across reload and mute #35, fix(auth)!: harden OAuth, JWT auth, avatar uploads, and chat sanitization #44): all pass (26 API, 41 app, 2 browser media tests). Main's new changes touch none of this PR's files, so the browser checks below still apply.vite preview, Chrome via agent-browser) on/about, whose demo runs a fullSpace:VITE_APP_URL, which only the.env.*modes define and the plain preview build lacked.WEBGL_lose_context.loseContext()thenrestoreContext()on the demo canvas: after restore, the background, tiles, and avatar textures all render again, with no GL errors.Stepperunit tests cover frame-rate independence instead.Profilepreview:/accountand the lobby need the API and sign-in.peers.test.tscovers merge, settle, and drop.Models
Size: M
Implementer: Claude Code, claude-opus-5-5, high
Implementer: Claude Code, claude-opus-5-5, unknown (iterate, M)
🤖 Generated with Claude Code
(Written by Claude Opus 5.5)
Review
Rewritten by
quest reviewafter each round.Head: fff7142
Base: origin/main at 048c95a
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.2-sol, high effort
Session:
01a215f0-0dbe-7f40-97ff-e1cfd732db38, round 4Score: 10/10,
The branch can land as is because the maintainer accepted the remaining peer-move issue for follow-up and the new branch changes introduce no findings.Rounds: 4; first round 3 (medium 3); findings 5 (medium 5): fixed 4, refuted 1, open 0
Findings: none
The last round's findings, at e108e35:
app/src/room/peers.ts:17:Acknowledge reversals even when the peer is already there;The maintainer accepted the existing behavior for this branch and recorded the deferred wire-format fix in `quest/m1/remote-control.md:26`.