fix: stop reconciling a scene controller disposed mid-await
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user