fix(client): render avatar preview in a single WebGL context#6
Merged
Conversation
The avatar preview created one Pixi Application — and therefore one WebGL context — per grid cell (28 cells: 14 body + 14 bubble). Browsers cap live WebGL contexts at ~16, so the excess were context-lost: their shaders failed to compile (with an empty info log) and Pixi's error logger then threw on the null program log, blanking the page behind a runtime-error overlay. Use a single shared offscreen renderer and snapshot each variant into its own static 2D canvas via renderer.extract.canvas. One context total, so the harness now scales to any number of cells. Not a product bug: the real app uses a single Pixi context per room and renders full-body avatars correctly. This only affected the preview tool. Verified in Chromium (Playwright): all 28 avatar variants render with zero shader errors and no error overlay. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
The avatar preview (
preview-entry.ts) created one PixiApplication— and one WebGL context — per grid cell (28 cells). Browsers cap live WebGL contexts at ~16, so the excess were context-lost: their shaders failed to compile (empty info log), and Pixi's error logger then threw on the null program log, blanking the page behind a runtime-error overlay.Fix: a single shared offscreen renderer snapshots each variant into its own static 2D canvas via
renderer.extract.canvas. One context total — the harness now scales to any number of cells.Not a product bug
This only affected the preview tool. The real app uses a single Pixi context per room and renders full-body avatars correctly (confirmed live).
Test plan
bun run lint✅ ·bun run typecheck✅ ·bun test✅ 250 pass🤖 Generated with Claude Code