mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Release the shell from a candidate engine that fails after it attached
The shell's scene part detaches it too, so a candidate failing in a later part (a layer's drawing, Cockpit clouds) leaves the shell free for the working engine instead of refusing every later attach. StyleManager.attachScene releases what it built when it throws, and one detach runs at a time. The controls phase awaits its parts, and a failed attachment no longer forces handoff off for the parts it releases. scripts/qa-app-once.mjs now also rolls back from a Navara candidate whose layer attachment fails.
This commit is contained in:
1 parent
58c8a481ed
commit
d86047fe8f
12 files changed
+229
-76
No files matched your search
+64
-44
@@ -708,49 +708,61 @@ export class StyleManager extends ShellFacade {
|
||||
if (this._disposed) return;
|
||||
if (this._scene.engine)
|
||||
throw new Error('The shell is attached to a globe already');
|
||||
const previousServices = this.services;
|
||||
this.services = { ...this.services, ...services };
|
||||
this._scene = { viewer, engine, mapStackController };
|
||||
const {
|
||||
flightsLayer,
|
||||
militaryFlightsLayer,
|
||||
satellitesLayer,
|
||||
aisLiveVesselsLayer,
|
||||
militaryAwarenessLayer,
|
||||
rocketLaunchesLayer,
|
||||
} = this.services;
|
||||
this._navigation.tracking = {
|
||||
flightsLayer,
|
||||
militaryFlightsLayer,
|
||||
satellitesLayer,
|
||||
aisLiveVesselsLayer,
|
||||
militaryAwarenessLayer,
|
||||
rocketLaunchesLayer,
|
||||
};
|
||||
this._navigation.setScene({ viewer, engine });
|
||||
this._locationNavigation.attachScene({ viewer, engine });
|
||||
this.hud.attachEngine(engine, { viewer });
|
||||
this.shareLinkManager.attachEngine(engine);
|
||||
this._displayBindings.attachViewer(viewer);
|
||||
this._buildSceneControls();
|
||||
this._buildSceneCockpit();
|
||||
this._shareRestoration.attachLinks(this.shareLinkManager);
|
||||
this._initSceneOverlays();
|
||||
this._initMapStackControl();
|
||||
this._refreshLayerControls(previousServices);
|
||||
this._initCameraOrientationControls();
|
||||
this._initHudScene();
|
||||
this._initCockpitDisplayPortal();
|
||||
this._applyGlobalPostDefaults();
|
||||
this._startAnimationLoop();
|
||||
this._publishActiveStyle();
|
||||
this._shareRestoration.start({
|
||||
engineSwitch,
|
||||
retainScene: Boolean(this._layerSession?.handoffLayers),
|
||||
});
|
||||
this._layerBindings.observeCamera();
|
||||
this._layoutRightPanels();
|
||||
this._syncCctvPanelViewport();
|
||||
// An attachment that fails part-way releases what it built: the shell
|
||||
// stays detached, ready for the working engine.
|
||||
try {
|
||||
const previousServices = this.services;
|
||||
this.services = { ...this.services, ...services };
|
||||
this._scene = { viewer, engine, mapStackController };
|
||||
const {
|
||||
flightsLayer,
|
||||
militaryFlightsLayer,
|
||||
satellitesLayer,
|
||||
aisLiveVesselsLayer,
|
||||
militaryAwarenessLayer,
|
||||
rocketLaunchesLayer,
|
||||
} = this.services;
|
||||
this._navigation.tracking = {
|
||||
flightsLayer,
|
||||
militaryFlightsLayer,
|
||||
satellitesLayer,
|
||||
aisLiveVesselsLayer,
|
||||
militaryAwarenessLayer,
|
||||
rocketLaunchesLayer,
|
||||
};
|
||||
this._navigation.setScene({ viewer, engine });
|
||||
this._locationNavigation.attachScene({ viewer, engine });
|
||||
this.hud.attachEngine(engine, { viewer });
|
||||
this.shareLinkManager.attachEngine(engine);
|
||||
this._displayBindings.attachViewer(viewer);
|
||||
this._buildSceneControls();
|
||||
this._buildSceneCockpit();
|
||||
this._shareRestoration.attachLinks(this.shareLinkManager);
|
||||
this._initSceneOverlays();
|
||||
this._initMapStackControl();
|
||||
this._refreshLayerControls(previousServices);
|
||||
this._initCameraOrientationControls();
|
||||
this._initHudScene();
|
||||
this._initCockpitDisplayPortal();
|
||||
this._applyGlobalPostDefaults();
|
||||
this._startAnimationLoop();
|
||||
this._publishActiveStyle();
|
||||
this._shareRestoration.start({
|
||||
engineSwitch,
|
||||
retainScene: Boolean(this._layerSession?.handoffLayers),
|
||||
});
|
||||
this._layerBindings.observeCamera();
|
||||
this._layoutRightPanels();
|
||||
this._syncCctvPanelViewport();
|
||||
} catch (error) {
|
||||
void this.detachScene().catch((cleanupError) =>
|
||||
console.error(
|
||||
'The shell could not leave a failed globe:',
|
||||
cleanupError,
|
||||
),
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -759,7 +771,15 @@ export class StyleManager extends ShellFacade {
|
||||
* the open panels stay. `handoff` keeps the selection and a retainable
|
||||
* Context mode for the next globe.
|
||||
*/
|
||||
async detachScene({
|
||||
detachScene(options = {}) {
|
||||
// One detach at a time: a second request joins the one under way.
|
||||
this._sceneDetach ??= this._detachScene(options).finally(() => {
|
||||
this._sceneDetach = null;
|
||||
});
|
||||
return this._sceneDetach;
|
||||
}
|
||||
|
||||
async _detachScene({
|
||||
handoff = Boolean(this._layerSession?.handoffLayers),
|
||||
} = {}) {
|
||||
if (!this._scene.engine && !this._scene.viewer) return;
|
||||
|
||||
@@ -195,3 +195,24 @@ test('a Context transition in flight is restored before the globe goes', async (
|
||||
assert.equal(session.context._contextModeGeneration, 5);
|
||||
assert.equal(session.context._contextModeChanging, false);
|
||||
});
|
||||
|
||||
test('an attachment that throws part-way leaves the shell detached and attachable', async () => {
|
||||
const { shell, log } = fakeShell();
|
||||
await shell.detachScene({ handoff: true });
|
||||
shell._initSceneOverlays = () => {
|
||||
throw new Error('overlay host failed');
|
||||
};
|
||||
assert.throws(
|
||||
() => shell.attachScene({ engine: { kind: 'navara' } }),
|
||||
/overlay host failed/,
|
||||
);
|
||||
// The shell releases what it built and is detached when that settles.
|
||||
await shell.detachScene();
|
||||
assert.equal(shell.engine, null);
|
||||
log.length = 0;
|
||||
shell._initSceneOverlays = () => log.push('_initSceneOverlays');
|
||||
const engine = { kind: 'cesium' };
|
||||
shell.attachScene({ engine });
|
||||
assert.equal(shell.engine, engine);
|
||||
assert.ok(log.includes('shareRestoration.start'));
|
||||
});
|
||||
Reference in new issue
Block a user