Engine pool with eager registration + (home, mode) key + owner handshake
Definitive fix for the per-commit WebGL respawn (#162). Investigated by reading the Home Assistant frontend source directly (hui-card.ts on the dev branch).
Why the previous attempts failed
hui-card._loadElement (lines 121-166) executes the rebuild in this order:
tryCreateCardElement(newConfig)constructs the NEW helios-card and callssetConfigon it.this.removeChild(oldElement)removes the old child, firing the OLD card'sdisconnectedCallback.this.appendChild(newElement)attaches the new child, firing itsconnectedCallback.
The previous attempts pushed the engine into the pool from step 2. By that point the NEW card had already been constructed in step 1 and was about to run its updated() lifecycle, which would allocate a fresh WebGL context before the pool was even populated.
Fix
- Eager registration. Every engine pushes itself into the pool the moment it is created in
initEngineNow, not atdisconnectedCallback. When the slider commit triggers the rebuild, the NEW card'supdated()finds the OLD card's engine waiting in the pool. - (home, mode) key. HA sets
element.preview = trueon the editor preview pane (hui-card.ts:136-138). The pool key now includes that flag so a preview card never claims the live dashboard tile's engine, and the live dashboard never claims a preview's engine. - Owner handshake. Each pool entry tracks
lastOwner. Claiming reassigns the owner and cancels any pending dispose. Releasing is a no-op when the releaser is no longer the registered owner (the OLD card calling release AFTER the NEW card has already claimed). When the releaser IS still the owner (real navigation away), release schedules a dispose after the grace window.
Internals
pushEngineToPool/tryClaimPooledEngineremoved.registerEngineInPool/claimEngineFromPool/releaseEngineFromPool/isCurrentPoolOwneradded.- Pool grace widened from 1.5 s to 2.5 s to absorb the 1 s mount-debounce a fresh card incurs before its first
initEngine.
Validation
window.heliosStats(), before and after a slider drag in the editor, should now show enginesCreated unchanged. The basemap should render normally in the editor preview pane. The dashboard tile should be untouched.
Installation
Pick v1.8.2-alpha.11 in HACS (show beta versions toggle), or download helios.js from this release and drop it under config/www/community/helios/ replacing the existing bundle. Refresh the dashboard.