mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
A photoreal base that fails to come back keeps the stack before it
- The map source controller waits for a base that loads as it is shown (the globe engine's tilesetReady) before it takes the stack before it down: one that fails throws there, so that stack and its imagery stay and the error is reported, as from any failed switch. The Cesium map engine has no tilesetReady, so its switches are unchanged. - A failed default renderer load is tried again by the next call, and the standalone page's early load does not report a failure nobody awaited yet. - The adapter ratchet's on-demand import rule refuses a default or an empty destructuring. - The stub boot check fails a layer whose manager answers false rather than throwing, or that is not on (or off) afterwards; a field drawn counts as drawn; the dev server is closed when the browser cannot start.
This commit is contained in:
1 parent
8a4867b1b7
commit
9a13aeab48
8 files changed
+108
-13
No files matched your search
@@ -127,6 +127,14 @@ function readDrawn() {
|
|||||||
async function main() {
|
async function main() {
|
||||||
const args = parseArgs(process.argv.slice(2));
|
const args = parseArgs(process.argv.slice(2));
|
||||||
const server = args.url ? null : await startViteServer(args.port);
|
const server = args.url ? null : await startViteServer(args.port);
|
||||||
|
try {
|
||||||
|
await run(args);
|
||||||
|
} finally {
|
||||||
|
await server?.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function run(args) {
|
||||||
const base = (args.url ?? `http://127.0.0.1:${args.port}`).replace(/\/$/, '');
|
const base = (args.url ?? `http://127.0.0.1:${args.port}`).replace(/\/$/, '');
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
headless: true,
|
headless: true,
|
||||||
@@ -220,7 +228,13 @@ async function main() {
|
|||||||
window.__godsEyeView.dataManager
|
window.__godsEyeView.dataManager
|
||||||
.setEnabled(layerId, true, { origin: 'user' })
|
.setEnabled(layerId, true, { origin: 'user' })
|
||||||
.then(
|
.then(
|
||||||
(value) => ({ ok: true, value: value ?? null }),
|
// It can answer false rather than throw: on is what it says.
|
||||||
|
(value) => ({
|
||||||
|
ok:
|
||||||
|
value !== false &&
|
||||||
|
window.__godsEyeView.dataManager.isEnabled(layerId),
|
||||||
|
value: value ?? null,
|
||||||
|
}),
|
||||||
(error) => ({ ok: false, error: String(error?.stack || error) }),
|
(error) => ({ ok: false, error: String(error?.stack || error) }),
|
||||||
),
|
),
|
||||||
id,
|
id,
|
||||||
@@ -264,7 +278,11 @@ async function main() {
|
|||||||
window.__godsEyeView.dataManager
|
window.__godsEyeView.dataManager
|
||||||
.setEnabled(layerId, false, { origin: 'user' })
|
.setEnabled(layerId, false, { origin: 'user' })
|
||||||
.then(
|
.then(
|
||||||
() => ({ ok: true }),
|
(value) => ({
|
||||||
|
ok:
|
||||||
|
value !== false &&
|
||||||
|
!window.__godsEyeView.dataManager.isEnabled(layerId),
|
||||||
|
}),
|
||||||
(error) => ({ ok: false, error: String(error?.stack || error) }),
|
(error) => ({ ok: false, error: String(error?.stack || error) }),
|
||||||
),
|
),
|
||||||
id,
|
id,
|
||||||
@@ -303,7 +321,6 @@ async function main() {
|
|||||||
report.cesiumStylesheets = cesiumStylesheets;
|
report.cesiumStylesheets = cesiumStylesheets;
|
||||||
report.errors = errors;
|
report.errors = errors;
|
||||||
await browser.close();
|
await browser.close();
|
||||||
await server?.close();
|
|
||||||
}
|
}
|
||||||
const pageErrors = errors.filter((error) => error.kind === 'page');
|
const pageErrors = errors.filter((error) => error.kind === 'page');
|
||||||
const consoleErrors = errors.filter((error) => error.kind === 'console');
|
const consoleErrors = errors.filter((error) => error.kind === 'console');
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ export function loadDefaultRenderer() {
|
|||||||
const { cesiumRenderer } = await import('../render/cesium/application.js');
|
const { cesiumRenderer } = await import('../render/cesium/application.js');
|
||||||
return cesiumRenderer;
|
return cesiumRenderer;
|
||||||
})();
|
})();
|
||||||
|
// A load that failed is tried again by the next call.
|
||||||
|
defaultLoad.catch(() => {
|
||||||
|
defaultLoad = null;
|
||||||
|
});
|
||||||
return defaultLoad;
|
return defaultLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
* fields read that record. Readers ask this module, never the renderer.
|
* fields read that record. Readers ask this module, never the renderer.
|
||||||
*
|
*
|
||||||
* Its readers (the tracked card, Cockpit, the share link's thing view,
|
* Its readers (the tracked card, Cockpit, the share link's thing view,
|
||||||
* north-up) read the target's `displayPosition`: a port target without one
|
* north-up) read where the target is shown (`followedPosition`): its
|
||||||
* is followed by the camera but not shown by them.
|
* `displayPosition`, else its own `position` at scene time.
|
||||||
*/
|
*/
|
||||||
import { findCamera, findFrame } from '../render/rendererOf.js';
|
import { findCamera, findFrame } from '../render/rendererOf.js';
|
||||||
import { readEntityRecord } from './entityRecords.js';
|
import { readEntityRecord } from './entityRecords.js';
|
||||||
|
|||||||
@@ -296,6 +296,15 @@ export class MapSourceController {
|
|||||||
this._engine.addTileset(this.viewer, tileset);
|
this._engine.addTileset(this.viewer, tileset);
|
||||||
this._ownedTilesets.add(tileset);
|
this._ownedTilesets.add(tileset);
|
||||||
}
|
}
|
||||||
|
// A base that loads as it is shown (a globe port's photoreal) is shown
|
||||||
|
// first and waited for, the stack before it still in place: one that
|
||||||
|
// fails throws here, and that stack stays.
|
||||||
|
if (this._engine.tilesetReady) {
|
||||||
|
this._showTileset(tileset);
|
||||||
|
const ready = this._engine.tilesetReady(tileset);
|
||||||
|
if (ready) await ready;
|
||||||
|
if (gen !== this._switchGen) return;
|
||||||
|
}
|
||||||
this._removeImageryLayer();
|
this._removeImageryLayer();
|
||||||
this._credits.show(source.credit || null);
|
this._credits.show(source.credit || null);
|
||||||
this._showTileset(tileset);
|
this._showTileset(tileset);
|
||||||
|
|||||||
+25
-6
@@ -42,18 +42,31 @@ function applyPhotoreal(handle, shown) {
|
|||||||
if (handle.shown === shown || released.has(handle)) return;
|
if (handle.shown === shown || released.has(handle)) return;
|
||||||
handle.shown = shown;
|
handle.shown = shown;
|
||||||
const switchId = (handle.switches = (handle.switches ?? 0) + 1);
|
const switchId = (handle.switches = (handle.switches ?? 0) + 1);
|
||||||
|
/** Whether this switch failed to show the base; false once it is off. */
|
||||||
const failed = (error) => {
|
const failed = (error) => {
|
||||||
if (handle.switches !== switchId || released.has(handle)) return;
|
if (handle.switches !== switchId || released.has(handle)) return false;
|
||||||
console.warn('[MapStack] photoreal switch failed', error);
|
console.warn('[MapStack] photoreal switch failed', error);
|
||||||
if (!shown) return;
|
if (!shown) return false;
|
||||||
handle.shown = false;
|
handle.shown = false;
|
||||||
handle.globe.setGlobeVisible(true);
|
handle.globe.setGlobeVisible(true);
|
||||||
shownGlobes.set(handle.globe, true);
|
shownGlobes.set(handle.globe, true);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
handle.globe.setPhotoreal(shown ? handle.spec : null).then((status) => {
|
handle.pending = handle.globe
|
||||||
if (shown && status?.route === 'none')
|
.setPhotoreal(shown ? handle.spec : null)
|
||||||
failed(status.error?.message ?? 'photoreal unavailable');
|
.then(
|
||||||
}, failed);
|
(status) =>
|
||||||
|
shown && status?.route === 'none'
|
||||||
|
? (status.error?.message ?? 'photoreal unavailable')
|
||||||
|
: null,
|
||||||
|
(error) => error ?? 'photoreal unavailable',
|
||||||
|
)
|
||||||
|
.then((error) => {
|
||||||
|
if (error === null || !failed(error)) return;
|
||||||
|
throw error instanceof Error ? error : new Error(String(error));
|
||||||
|
});
|
||||||
|
// A failure nobody waits for is reported above, not unhandled.
|
||||||
|
handle.pending.catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,6 +179,12 @@ export const globeMapEngine = Object.freeze({
|
|||||||
showTileset(handle, shown) {
|
showTileset(handle, shown) {
|
||||||
if (handle) applyPhotoreal(handle, shown);
|
if (handle) applyPhotoreal(handle, shown);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Settles once `handle`'s last switch has: rejects when showing it failed
|
||||||
|
* (the base is off again and the globe shown), so the map stack falls
|
||||||
|
* back as from any failed switch.
|
||||||
|
*/
|
||||||
|
tilesetReady: (handle) => handle?.pending ?? null,
|
||||||
addImageryLayer(host, handle, index) {
|
addImageryLayer(host, handle, index) {
|
||||||
const globe = findGlobe(host);
|
const globe = findGlobe(host);
|
||||||
if (!globe || released.has(handle)) return;
|
if (!globe || released.has(handle)) return;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { mapEngineFor, provideMapEngine } from './engine.js';
|
|||||||
import { bindRenderer } from '../render/rendererOf.js';
|
import { bindRenderer } from '../render/rendererOf.js';
|
||||||
import { provideApplicationHooks } from '../render/applicationHooks.js';
|
import { provideApplicationHooks } from '../render/applicationHooks.js';
|
||||||
import { createStubRenderer } from '../render/stub/index.js';
|
import { createStubRenderer } from '../render/stub/index.js';
|
||||||
|
import { MapSourceController } from './controller.js';
|
||||||
|
import { createDefaultMapSources } from './defaultSources.js';
|
||||||
|
|
||||||
function scene(capabilities) {
|
function scene(capabilities) {
|
||||||
const renderer = createStubRenderer(capabilities ? { capabilities } : {});
|
const renderer = createStubRenderer(capabilities ? { capabilities } : {});
|
||||||
@@ -105,6 +107,7 @@ test('photoreal loads through the port, hides and shows, and is released', async
|
|||||||
engine.showTileset(handle, false);
|
engine.showTileset(handle, false);
|
||||||
assert.equal(engine.tilesetShown(handle), false);
|
assert.equal(engine.tilesetShown(handle), false);
|
||||||
assert.equal(calls(renderer, 'setPhotoreal').at(-1).args[0], null);
|
assert.equal(calls(renderer, 'setPhotoreal').at(-1).args[0], null);
|
||||||
|
await engine.tilesetReady(handle);
|
||||||
engine.showTileset(handle, true);
|
engine.showTileset(handle, true);
|
||||||
assert.equal(calls(renderer, 'setPhotoreal').at(-1).args[0], spec);
|
assert.equal(calls(renderer, 'setPhotoreal').at(-1).args[0], spec);
|
||||||
engine.release(handle);
|
engine.release(handle);
|
||||||
@@ -138,7 +141,11 @@ test('photoreal that fails to come back leaves the globe shown, and is tried aga
|
|||||||
console.warn = () => {};
|
console.warn = () => {};
|
||||||
try {
|
try {
|
||||||
engine.showTileset(handle, true);
|
engine.showTileset(handle, true);
|
||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
await assert.rejects(
|
||||||
|
engine.tilesetReady(handle),
|
||||||
|
/refused/,
|
||||||
|
'the map stack hears it failed',
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
console.warn = warn;
|
console.warn = warn;
|
||||||
}
|
}
|
||||||
@@ -152,3 +159,36 @@ test('photoreal that fails to come back leaves the globe shown, and is tried aga
|
|||||||
engine.showTileset(handle, true);
|
engine.showTileset(handle, true);
|
||||||
assert.equal(tried, 1, 'a later switch tries again');
|
assert.equal(tried, 1, 'a later switch tries again');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a photoreal stack that fails to come back leaves the stack before it in place', async () => {
|
||||||
|
const { host, renderer } = scene(['photoreal']);
|
||||||
|
const loaded = await engine.loadPhotoreal(host, { googleApiKey: 'key' });
|
||||||
|
const errors = [];
|
||||||
|
const controller = new MapSourceController(host, {
|
||||||
|
registry: createDefaultMapSources({
|
||||||
|
googleTileset: loaded.tileset,
|
||||||
|
engine,
|
||||||
|
}),
|
||||||
|
engine,
|
||||||
|
googleTileset: loaded.tileset,
|
||||||
|
onError: (message) => errors.push(message),
|
||||||
|
});
|
||||||
|
await controller.setStack('esri-imagery', { silent: true });
|
||||||
|
assert.equal(renderer.globe.imagery.list().length, 1);
|
||||||
|
renderer.globe.setPhotoreal = async (spec) => ({
|
||||||
|
route: spec ? 'none' : 'google',
|
||||||
|
error: { code: 'refused', message: 'refused' },
|
||||||
|
});
|
||||||
|
const warn = console.warn;
|
||||||
|
console.warn = () => {};
|
||||||
|
try {
|
||||||
|
await controller.setStack('photoreal', { silent: true });
|
||||||
|
} finally {
|
||||||
|
console.warn = warn;
|
||||||
|
}
|
||||||
|
assert.equal(controller.getState().activeId, 'esri-imagery');
|
||||||
|
assert.equal(renderer.globe.imagery.list().length, 1, 'its imagery stays');
|
||||||
|
assert.equal(engine.globeShown(host), true, 'on the shown globe');
|
||||||
|
assert.match(errors.at(-1), /refused/);
|
||||||
|
controller.destroy();
|
||||||
|
});
|
||||||
@@ -348,8 +348,12 @@ test('the files that name the adapter by design take named exports, never Cesium
|
|||||||
parent?.type === 'AwaitExpression' &&
|
parent?.type === 'AwaitExpression' &&
|
||||||
declarator?.type === 'VariableDeclarator' &&
|
declarator?.type === 'VariableDeclarator' &&
|
||||||
declarator.id.type === 'ObjectPattern' &&
|
declarator.id.type === 'ObjectPattern' &&
|
||||||
|
declarator.id.properties.length > 0 &&
|
||||||
declarator.id.properties.every(
|
declarator.id.properties.every(
|
||||||
(p) => p.type === 'ObjectProperty' && !p.computed,
|
(p) =>
|
||||||
|
p.type === 'ObjectProperty' &&
|
||||||
|
!p.computed &&
|
||||||
|
(p.key.name ?? p.key.value) !== 'default',
|
||||||
),
|
),
|
||||||
`${file} must destructure import(${source}) by name`,
|
`${file} must destructure import(${source}) by name`,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ export function createStandaloneApplication({
|
|||||||
throw new Error('The standalone application already owns this page');
|
throw new Error('The standalone application already owns this page');
|
||||||
constructed = true;
|
constructed = true;
|
||||||
// The default renderer starts loading now, beside the page's own setup.
|
// The default renderer starts loading now, beside the page's own setup.
|
||||||
|
// A failed load is the scene's to report, when it asks for the renderer.
|
||||||
const rendererPlugin = renderer ?? loadDefaultRenderer();
|
const rendererPlugin = renderer ?? loadDefaultRenderer();
|
||||||
|
if (!renderer) Promise.resolve(rendererPlugin).catch(() => {});
|
||||||
// Locale is resolved before any UI initialization so <html lang>/<html dir>
|
// Locale is resolved before any UI initialization so <html lang>/<html dir>
|
||||||
// and every catalog lookup agree from the first painted frame. Module
|
// and every catalog lookup agree from the first painted frame. Module
|
||||||
// scripts execute after parsing, so the DOM is ready here: the views
|
// scripts execute after parsing, so the DOM is ready here: the views
|
||||||
|
|||||||
Reference in new issue
Block a user