Skip to content

WGLMakie: fix a DOM-mount race in three_display, add AwaitedNode - #5716

Draft
bjarthur wants to merge 2 commits into
MakieOrg:masterfrom
bjarthur:bja/wglmakie-dom-mount-race
Draft

WGLMakie: fix a DOM-mount race in three_display, add AwaitedNode#5716
bjarthur wants to merge 2 commits into
MakieOrg:masterfrom
bjarthur:bja/wglmakie-dom-mount-race

Conversation

@bjarthur

@bjarthur bjarthur commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

  • Interpolating a DOM Node into js"..." (used for three_display's wrapper/canvas) compiled to a one-shot document.querySelector(...) with no retry — unlike Scene interpolation, which already retries via a configurable window (WGLMakie: make scene lookup retry window configurable #5693). On a slow/cold first page load (fresh browser tab, first WGLMakie display in a process), the JS module could finish loading before Bonito had actually mounted that specific node, silently querying null and failing scene initialization inside setup_scene_init's own try/catch — with no error surfacing on the Julia side.
  • Adds AwaitedNode, wrapping a node so its lookup retries until the node is mounted, reusing the same WGLMAKIE_SCENE_RETRY_DELAY_MS/WGLMAKIE_SCENE_RETRY_TOTAL_MS env vars already used for Scene lookups. three_display now awaits wrapper/canvas alongside the JS module, instead of interpolating them directly.

Type of change

Delete options that do not apply:

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Added an entry in CHANGELOG.md (for new features and breaking changes)
  • Added unit tests for new algorithms, conversion methods, etc.

Interpolating a DOM node into `js"..."` compiled to a one-shot
`document.querySelector(...)` with no retry, unlike `Scene` interpolation
which already retries. On a slow/cold first page load, the JS module could
finish loading before Bonito had actually mounted `wrapper`/`canvas`,
silently returning null and failing scene initialization with no error on
the Julia side.

AwaitedNode wraps a node and retries the lookup with the same
WGLMAKIE_SCENE_RETRY_* configuration already used for Scene lookups.
three_display now awaits wrapper/canvas the same way it awaits the scene.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-project-automation github-project-automation Bot moved this to Work in progress in PR review Jul 27, 2026
@bjarthur

Copy link
Copy Markdown
Contributor Author

this actually didn't fix the race condition problem in #5715, but claude thinks it's a good hardening measure anyway. i'll leave it as a draft for the maintainers to consider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Work in progress

Development

Successfully merging this pull request may close these issues.

1 participant