Skip to content

WebGL: Fix pad preview rendering and recovery - #3

Draft
timfroh wants to merge 1 commit into
atopile/mainfrom
feature/fix-webgl-preview-context-ownership
Draft

timfroh wants to merge 1 commit into
atopile/mainfrom
feature/fix-webgl-preview-context-ownership

Conversation

@timfroh

@timfroh timfroh commented Sep 21, 2026

Copy link
Copy Markdown

Description

Opening Pad Properties creates a preview canvas alongside the main board canvas. The WASM renderer shared its font texture and fullscreen drawing geometry between them, even though each canvas has a separate WebGL context. WebGL rejected the shared texture, causing a graphics exception; rebuilding the renderer repeated the failure. The shared drawing geometry could also leave the preview black.

The renderer fix gives each canvas's renderer and compositor their own GPU resources and releases those resources in the owning context. This code lives in PCBJam's KiCad submodule, so this PR advances that submodule to include KiCad PR #2 and adds the reproduction and validation details. It also retains the display-settings lifetime fix from KiCad PR #1.

Motivation

Double-clicking a pad could trigger the remove_observer assertion, and closing Pad Properties with OK or Cancel could leave both clicking and drag selection unresponsive. The lifetime fix made renderer recovery safe, but the underlying graphics error still occurred. The WASM renderer changes address that trigger so opening a pad preview no longer requires recovery or a software-rendering fallback in the tested case.

The original binary and the lifetime-only hotfix both reproduced the graphics error. The new compiled build rendered the preview correctly on the workspace board and passed four alternating Cancel/OK close-and-reopen cycles followed by drag selection, with no captured WebGL errors or runtime exceptions in Firefox. Testing used browser-local asset overrides; the served environment was left unchanged.

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