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) {
controller.update(sources.journey.value);
await controller.setQuality(sources.quality.value);
if (controller.snapshot().state.kind === 'paused') {
await controller.resume();
// The controller can be disposed (context loss, policy change, pagehide)
// while setQuality or resume is pending; only touch the one we started
// with, and stop if it is no longer current.
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();
return;