fix: stop reconciling a scene controller disposed mid-await

This commit is contained in:
2026-10-11 01:22:52 +03:00
parent 077106274c
commit 1bccb7548f

View File

@@ -90,10 +90,16 @@ export function useSceneController(sources: SceneControllerSources): SceneContro
} }
if (controller !== null) { if (controller !== null) {
controller.update(sources.journey.value); // The controller can be disposed (context loss, policy change, pagehide)
await controller.setQuality(sources.quality.value); // while setQuality or resume is pending; only touch the one we started
if (controller.snapshot().state.kind === 'paused') { // with, and stop if it is no longer current.
await controller.resume(); const active = controller;
active.update(sources.journey.value);
await active.setQuality(sources.quality.value);
if (controller !== active) return;
if (active.snapshot().state.kind === 'paused') {
await active.resume();
if (controller !== active) return;
} }
publish(); publish();
return; return;