mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +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
@@ -32,6 +32,10 @@ export function loadDefaultRenderer() {
|
||||
const { cesiumRenderer } = await import('../render/cesium/application.js');
|
||||
return cesiumRenderer;
|
||||
})();
|
||||
// A load that failed is tried again by the next call.
|
||||
defaultLoad.catch(() => {
|
||||
defaultLoad = null;
|
||||
});
|
||||
return defaultLoad;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
* fields read that record. Readers ask this module, never the renderer.
|
||||
*
|
||||
* Its readers (the tracked card, Cockpit, the share link's thing view,
|
||||
* north-up) read the target's `displayPosition`: a port target without one
|
||||
* is followed by the camera but not shown by them.
|
||||
* north-up) read where the target is shown (`followedPosition`): its
|
||||
* `displayPosition`, else its own `position` at scene time.
|
||||
*/
|
||||
import { findCamera, findFrame } from '../render/rendererOf.js';
|
||||
import { readEntityRecord } from './entityRecords.js';
|
||||
|
||||
@@ -296,6 +296,15 @@ export class MapSourceController {
|
||||
this._engine.addTileset(this.viewer, 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._credits.show(source.credit || null);
|
||||
this._showTileset(tileset);
|
||||
|
||||
+25
-6
@@ -42,18 +42,31 @@ function applyPhotoreal(handle, shown) {
|
||||
if (handle.shown === shown || released.has(handle)) return;
|
||||
handle.shown = shown;
|
||||
const switchId = (handle.switches = (handle.switches ?? 0) + 1);
|
||||
/** Whether this switch failed to show the base; false once it is off. */
|
||||
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);
|
||||
if (!shown) return;
|
||||
if (!shown) return false;
|
||||
handle.shown = false;
|
||||
handle.globe.setGlobeVisible(true);
|
||||
shownGlobes.set(handle.globe, true);
|
||||
return true;
|
||||
};
|
||||
handle.globe.setPhotoreal(shown ? handle.spec : null).then((status) => {
|
||||
if (shown && status?.route === 'none')
|
||||
failed(status.error?.message ?? 'photoreal unavailable');
|
||||
}, failed);
|
||||
handle.pending = handle.globe
|
||||
.setPhotoreal(shown ? handle.spec : null)
|
||||
.then(
|
||||
(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) {
|
||||
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) {
|
||||
const globe = findGlobe(host);
|
||||
if (!globe || released.has(handle)) return;
|
||||
|
||||
@@ -5,6 +5,8 @@ import { mapEngineFor, provideMapEngine } from './engine.js';
|
||||
import { bindRenderer } from '../render/rendererOf.js';
|
||||
import { provideApplicationHooks } from '../render/applicationHooks.js';
|
||||
import { createStubRenderer } from '../render/stub/index.js';
|
||||
import { MapSourceController } from './controller.js';
|
||||
import { createDefaultMapSources } from './defaultSources.js';
|
||||
|
||||
function scene(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);
|
||||
assert.equal(engine.tilesetShown(handle), false);
|
||||
assert.equal(calls(renderer, 'setPhotoreal').at(-1).args[0], null);
|
||||
await engine.tilesetReady(handle);
|
||||
engine.showTileset(handle, true);
|
||||
assert.equal(calls(renderer, 'setPhotoreal').at(-1).args[0], spec);
|
||||
engine.release(handle);
|
||||
@@ -138,7 +141,11 @@ test('photoreal that fails to come back leaves the globe shown, and is tried aga
|
||||
console.warn = () => {};
|
||||
try {
|
||||
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 {
|
||||
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);
|
||||
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' &&
|
||||
declarator?.type === 'VariableDeclarator' &&
|
||||
declarator.id.type === 'ObjectPattern' &&
|
||||
declarator.id.properties.length > 0 &&
|
||||
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`,
|
||||
);
|
||||
|
||||
@@ -37,7 +37,9 @@ export function createStandaloneApplication({
|
||||
throw new Error('The standalone application already owns this page');
|
||||
constructed = true;
|
||||
// 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();
|
||||
if (!renderer) Promise.resolve(rendererPlugin).catch(() => {});
|
||||
// Locale is resolved before any UI initialization so <html lang>/<html dir>
|
||||
// and every catalog lookup agree from the first painted frame. Module
|
||||
// scripts execute after parsing, so the DOM is ready here: the views
|
||||
|
||||
Reference in new issue
Block a user