Create the application once per page and switch engines through the scene host

createStandaloneApplication opens its first globe, attaches the scene host and returns attachScene/detachScene: a switch hands the session off, parks the outgoing renderer and attaches the incoming one with its catalog to the parts the phases registered once. A failed candidate releases what it attached; the working engine attaches again on the same shell, voice, tools and stores. ?switch=legacy keeps the route that builds an application per engine for one release. scripts/qa-app-once.mjs now asserts identity, UI, tool and listener continuity, the rollback and the legacy route.
This commit is contained in:
German Khokhlov committed 2026-11-03 18:19:51 +04:00
1 parent 2bac200c01
commit a99b862580
6 files changed
+533 -81

No files matched your search

+13 -2
View File
@@ -1,6 +1,8 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { createSceneHost } from './app/sceneHost.js';
import { attachScenePart } from './app/sceneParts.js';
import vm from 'node:vm';
import { createGoogleTokenSource } from './maps/googleTokens.js';
import {
@@ -85,11 +87,20 @@ async function standaloneStartup(Cesium, credentials, fetchImpl) {
...(await loadPhotorealisticTileset(Cesium, options)),
operations: {},
}),
createSceneHost,
attachScenePart,
AbortController,
AbortSignal,
});
vm.runInContext(source, context);
const app = context.createStandaloneApplication(credentials);
// The application passes each constructor its signal and defer(cleanup).
return app.createScene({ signal: new AbortController().signal, defer() {} });
// The application passes each constructor its signal and defer(cleanup);
// the scene it returns reads the attached globe.
const scene = await app.createScene({
signal: new AbortController().signal,
defer() {},
});
return scene.current();
}
test('standalone falls back to ion when the server token route is unavailable', async () => {