mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-22 19:22:18 +00:00
Merge upstream main into feat/iss-3d-model
Translation files: kept both sides' new keys. DATA_SOURCES.md and public/models/README.md are back to main's layout (the previous merge had reflowed their tables, which put the generated Data Library section out of date) with only the ISS lines added. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
31fbd8f177
36 files changed
+1505
-59
No files matched your search
+7
-6
@@ -14,7 +14,7 @@ How to read this:
|
||||
## Live sources (fetched at runtime — not stored in this repo)
|
||||
|
||||
| Source | Used for | License / terms | Attribution |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **NOAA GFS (wind)** (`noaa-gfs-bdp-pds.s3.amazonaws.com`) | Global 10 m wind, optional 2 m temperature and mean sea-level pressure for Wind. Keyless; latest 6-hourly 0.25° cycle, byte-range GRIB2 reads, cached for an hour | U.S. public domain (NOAA); keyless via NOAA Open Data on AWS | "NOAA Global Forecast System (GFS)" (courtesy; not an endorsement) |
|
||||
| **ECMWF IFS (wind)** (`data.ecmwf.int/forecasts`, ECMWF Open Data) | The alternative Wind model: 10 m wind, optional 2 m temperature and mean sea-level pressure. Keyless; latest 6-hourly 0.25° run, byte-range GRIB2 reads, cached for an hour | [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) plus the [ECMWF Terms of Use](https://apps.ecmwf.int/datasets/licences/general/) | "This service is based on data and products of the European Centre for Medium-Range Weather Forecasts (ECMWF)", with the CC BY 4.0 link, the modification notice and ECMWF's liability disclaimer — shown in-app |
|
||||
| **NOAA nowCOAST observed weather** (`nowcoast.noaa.gov/geoserver/observations/{weather_radar,satellite}/ows`, WMS 1.1.1) | Rain radar (MRMS base reflectivity, contiguous US, about 4-minute updates) and Satellite clouds (GOES-19/18 Band 14 regional infrared, about 5-minute updates; global infrared mosaic, hourly). Keyless; layer metadata refreshed every 2 minutes, exact-time images cached for up to 24 hours | [NOAA disclaimer](https://oceanservice.noaa.gov/disclaimer.html) | "NOAA nowCOAST · NWS/OAR MRMS radar; NESDIS GOES and global satellite partners" |
|
||||
@@ -35,7 +35,6 @@ How to read this:
|
||||
| **AISStream.io** | Live vessels (AIS) | Free, beta, no formal ToS; AIS is a public broadcast | "AISStream.io" (courtesy) |
|
||||
| **CelesTrak** | Satellite TLEs (SGP4) and SATCAT records (object type, operational status, owner) that file each satellite under a class | US-government-origin data, no license; citation requested | "CelesTrak (celestrak.org), Dr. T.S. Kelso" |
|
||||
| **NASA 3D Resources** (`public/models/iss.glb`) | The ISS drawn as a 3D model when the camera is near it (satellites layer): NASA/JSC IGOAL's "International Space Station (ISS) (D)" (https://science.nasa.gov/3d-resources/international-space-station-iss-d-igoal/), reduced and re-rigged as `public/models/README.md` records. Its moving parts are computed by the app, not read from telemetry: arrays and radiators from the Sun's position, the Ku-band dishes toward the TDRS fleet's nominal slots (41°W, 171°W, 85°E), the robotic arms as an illustrative sway | NASA media, not subject to copyright in the United States; NASA's Images and Media Usage Guidelines (https://www.nasa.gov/nasa-brand-center/images-and-media) ask that use not imply endorsement and that the insignia not be used | "ISS model: NASA 3D Resources" |
|
||||
| **NASA ISS live stream on YouTube** (`youtube-nocookie.com/embed/ROboUHfPUrU`) | NASA's official live video from the ISS ("Live High-Definition Views from the International Space Station"), embedded with YouTube's player while the ISS is selected; the app stores nothing from it | NASA video, not subject to copyright in the United States (same guidelines); played through YouTube's embedded player under YouTube's Terms of Service | "ISS live video: NASA, via YouTube" |
|
||||
| **The Space Devs — Launch Library 2 v2.3** | Recent launch, payload, stage, and recovery metadata for Space Missions (30d) | [The Space Devs terms of use](https://github.com/TheSpaceDevs/Tutorials/blob/main/faqs/faq_TSD.md#terms-of-use): data may be used and shared in any form; avoid forwarding it without added value; attribution is encouraged (not mandatory). [Official API limits](https://ll.thespacedevs.com/docs/): 15 unauthenticated calls/hour; optional token | "Launch Library 2 — The Space Devs" (courtesy attribution) |
|
||||
| **Esri World Imagery** (ArcGIS Online tile service) | The keyless satellite basemap — the default landing when no Google/ion credential is configured, and the "Esri Satellite" map stack | [Esri Master Agreement](https://www.esri.com/en-us/legal/terms/full-master-agreement): the public World Imagery service is usable in public-facing apps with attribution; no key is required for this classic endpoint, but Esri governs and can change access — an app at scale should review current ArcGIS Location Platform terms | "Powered by Esri — Source: Esri, Maxar, Earthstar Geographics, and the GIS User Community" (provider carries the service's own credit line) |
|
||||
| **USGS** | Earthquakes | U.S. public domain | "Data courtesy of the U.S. Geological Survey" |
|
||||
@@ -205,7 +204,7 @@ The optional Local ADS-B layer and the broadcast-FM receiver use radio you recei
|
||||
- **Sea Marks and Ski Pistes (#10).** Two keyless raster overlay layers under Infrastructure, OpenSeaMap sea marks and OpenSnowMap ski pistes, requested tile by tile as the camera views them, with no prefetch, bulk download or caching on our side (OpenSnowMap forbids bulk tile download without prior agreement). They drape on the globe on the OSM and Bing stacks and on the Google Photorealistic tileset on Google 3D (see `src/maps/imageryHost.js`). OpenRailwayMap and OpenInfraMap, also requested in #10, are not included: OpenRailwayMap's tile server only answers requests whose Referer is its own site, and OpenInfraMap serves vector tiles that need a vector rendering pipeline.
|
||||
- **OpenSky Network.** Its license is **non-commercial**, and operational use of the REST API in a live product can require a prior written agreement with OpenSky — even for non-profit/government use. If you deploy this commercially, contact OpenSky for your own terms. The flights layer is a toggle and runs anonymously by default.
|
||||
- **adsb.lol flight fallback.** When OpenSky is unavailable and no last-good OpenSky response exists, the server requests a cached, capped 250 nm adsb.lol point snapshot around the current camera subpoint. This is regional observed context, not worldwide completeness; provenance is exposed in the Flights stats/context row. Military ICAOs remain reconciled through the existing dedicated military registry rather than duplicated.
|
||||
<a id="gnss-integrity"></a>
|
||||
<a id="gnss-integrity"></a>
|
||||
|
||||
- **GNSS integrity (adsb.lol).** A separate keyless point request samples a 250 nm
|
||||
circle around the screen centre, snapped once to whole degrees. This does not
|
||||
@@ -239,6 +238,7 @@ The optional Local ADS-B layer and the broadcast-FM receiver use radio you recei
|
||||
can be outside coverage or lack enough observations. Attribution: adsb.lol
|
||||
contributors, ODbL 1.0; GPSJAM for aggregation only.
|
||||
|
||||
|
||||
- **adsbdb enrichment.** `/api/adsbdb` resolves an ICAO hex to aircraft type, model name and registration, and the tracked flight's callsign to an airline and an origin/destination pair. Fan-out is deliberately small because adsbdb is a free community API that publishes no quota: at most 4 requests in flight, dispatches dripped to roughly 5/s, and each key asked for at most once per session (for the flights layer's enrichment, a lookup that failed temporarily, such as an outage, a timeout, a rate limit or an authorization refusal that may clear, may be asked again after a 60-second cool-down; an answer, found or not, and a permanent refusal such as a 404 are final; Local ADS-B lookups are asked once), with route lookups reserved for the tracked aircraft. The dev-server proxy caches each key for 24 hours in `.gev-cache/adsbdb.json`, negative answers included, so fresh entries survive server restarts. That gitignored cache remains local to the deployment and is not bundled with this repo. adsbdb publishes no general service license; its README says the route data may not be copied, published, or incorporated into other databases without the explicit permission of David J Taylor, Edinburgh. Deployers are responsible for obtaining any permission their use requires. Enrichment is best-effort and fail-silent — a flight that gets no answer keeps what the flight feed already gave it.
|
||||
- **Planespotters photos.** When you track an aircraft, the browser asks `https://api.planespotters.net/pub/photos/hex/{hex}` directly (the API answers cross-origin, so no key and no server proxy are involved) for that aircraft only, once per hex per session, through the same enrichment queue as adsbdb, with an 8-second timeout. A miss is remembered for the session; a request that failed temporarily (an outage, the timeout or a rate limit) may be asked again after a 60-second cool-down while the aircraft stays tracked, as for the flights layer's other enrichment. Either way no photo shows meanwhile. The first photo whose image is an `https://` URL on `*.plnspttrs.net`, and whose page is an `https://www.planespotters.net` URL is shown in the CONTEXT panel's CONTACTS view, under the tracked flight's name (`src/ui/views/panels/AwarenessPanel.vue`), and nowhere else; a vessel (see Open Vessel Photos below), an installation, a military aircraft or a converted TR-3B has none, and a military aircraft or TR-3B is never looked up. Anything else is dropped, so the app never shows or links outside Planespotters (`src/data/planespottersPhoto.js`, also exported as `gods-eye-view/sources/planespotters` for servers that cache the lookup). The photo follows the attribution rules: the thumbnail is hotlinked from the URL the API gives (never copied or re-hosted), the photographer's name, when the answer gives one, is visible text next to it ("Photo © {photographer}"; a photo whose answer names no one shows no credit line), and the photo and credit are a plain link to the photo's Planespotters page with `target="_blank" rel="noopener"` and never `rel="nofollow"`. If the image fails to load, the photo and its credit are hidden.
|
||||
- **Open Vessel Photos.** When you select a vessel with a nine-digit MMSI, the browser asks `https://openvesselphotos.org/v1/mmsi/{mmsi}` directly (the API is keyless and answers cross-origin, so no key and no server proxy are involved; account credentials are never sent) for that vessel only, once per MMSI per session, with an 8-second timeout. A miss (a 404 or a vessel without photos) is remembered for the session; a failed request may be asked again after five minutes. The first photo whose image is an `https://openvesselphotos.org` URL and which names a licence is shown, at the 800 px size, in the CONTEXT panel's CONTACTS view under the vessel's name and MMSI (`src/ui/views/panels/AwarenessPanel.vue`), and nowhere else (`src/data/openVesselPhoto.js`, `src/layers/vessels/photos.js`). The image is hotlinked from the URL the API gives (never copied or re-hosted); the photographer and licence are visible text next to it ("Photo: {photographer} · {licence}", or "Photo · {licence}" when the answer names no one), and the photo and credit link to the vessel's Open Vessel Photos page with `target="_blank" rel="noopener"`. If the image fails to load, the photo and its credit are hidden.
|
||||
@@ -265,7 +265,7 @@ The optional Local ADS-B layer and the broadcast-FM receiver use radio you recei
|
||||
- **Statens vegvesen road cameras.** Keyless. The camera list is one GeoJSON request to the OGC API Features view of the official DATEX 3.1 CCTV site table (`ogckart-sn1.atlas.vegvesen.no/ogc/features/v1/collections/datex_3_1:CctvSimple/items`), so no DATEX account is needed; frames are stills on `kamera.atlas.vegvesen.no/api/images/<cameraId>`, and only that exact path per camera is registered. Cameras the feed reports as faulty are dropped. About 135 working cameras also publish live HLS (`kamera.vegvesen.no/public/<cameraId>/manifest.m3u8`, MPEG-TS); those play as live video through the bounded in-memory HLS relay, with the still as the snapshot fallback, and only that exact manifest path per camera is registered. `CCTV_VEGVESEN_VIDEO=0` keeps every camera on stills. `orientationDescription` names the place a camera faces, not a bearing, so it goes into the label and headings use the id-hash fallback at low confidence. By default every live camera loads (~850); `CCTV_VEGVESEN_MAX_SOURCES` (8–1000) lowers the cap, keeping the cameras nearest Oslo, Bergen, Stavanger, Trondheim, Kristiansand, Bodø and Tromsø and `CCTV_VEGVESEN_ENABLED=0` turns the pack off. Frames are fetched at request time and never stored or redistributed. The NLOD attribution is registered in the Data attribution popover.
|
||||
- **Kartverket ground heights for Statens vegvesen cameras.** The camera feed's points are 2D, so the loader asks Kartverket's keyless point-height API (`ws.geonorge.no/hoydedata/v1/punkt`, CC BY 4.0) for the terrain height at each camera. Requests carry 20 points: the API accepts 50, but above ~20 it answers the extra points from contour lines (`hoydekurver`, metres to ~20 m off) or not at all. Eight requests run at a time, about 36 for the whole country: a cold lookup took 6–13 s in testing (single requests 0.6–9.5 s). Answers are matched by the coordinates the API echoes and recorded only for points that request asked about. Over water the API returns the sea-floor depth (`dybdekurver` or `Havflate`), which is replaced by 0 m, the water surface; for the ~14 bridge cameras that is below the deck, but much closer than the sea floor or the flat prior. Heights are cached in memory by position for the life of the server, and points with no height (a few ferry quays and bridges, or a point a 200 answer leaves out) for 6 h, so the 15-minute catalog refresh only asks about new or moved cameras. The first failing request (a 408, 429 or 5xx, a network error, a request over 10 s, or an unreadable or oversized body) stops the lookup, with no retries, and no new lookup starts until the backoff ends (Retry-After when sent, else 30 min, longer than the refresh; bounded to 1 min–1 h). Any other 4xx marks that request's points as having no height and the lookup carries on. The whole lookup has a 30 s deadline; a lookup cut short by it resumes on the next refresh without a backoff. The lane waits at most 12 s, counted from the start of the loader, and only when more than 10% of the cameras have no answer yet; a few new cameras or expired misses are looked up in the background. A slower lookup keeps filling the cache, and the cameras it had not reached keep the flat prior until the next 15-minute refresh (about 190 of 865 on one slow first run). Only coordinates are sent, with the same User-Agent as the other CCTV requests. `CCTV_VEGVESEN_HEIGHTS=0` turns the lookup off. The Kartverket credit, with a note that heights over water are set to 0 m and heights are rounded to 0.1 m, is shown beside the Statens vegvesen entry in the Data attribution popover.
|
||||
- **NYC DOT Traffic Management Center cameras.** Off by default. NYC DOT's [developer data feeds page](https://www.nyc.gov/html/dot/html/about/datafeeds.shtml) asks developers who want the camera feed to contact `[email protected]` and sign a data-sharing agreement. This project does not hold one that covers downstream installations, so the pack loads only when an operator who holds their own agreement sets `CCTV_NYC_ENABLED=1`; with the flag unset, empty or any other value, the server makes no request to NYC DOT. The endpoint needs no key. The camera list is the public `webcams.nyctmc.org/api/cameras` catalog (~980 cameras across the five boroughs); frames are stills at `webcams.nyctmc.org/api/cameras/<uuid>/image`, synthesized from a validated UUID rather than taken from the payload, and only that host is registered. Cameras the feed reports as offline are dropped. The catalog publishes no camera facing, so headings use the shared id-hash fallback at low confidence and are corrected with the in-app calibration gizmo. Once enabled, the 250 cameras nearest the borough cores load; `CCTV_NYC_MAX_SOURCES` (8–400) changes the cap. Frames are fetched at request time and never stored or redistributed. NYC DOT asks every application that uses its data to carry its disclaimer; it is registered verbatim in the Data attribution popover.
|
||||
- **City of Toronto RESCU cameras.** Keyless. The camera list is the City's public `tmcearthcameras.json` on `opendata.toronto.ca` (dataset "Traffic Cameras", Transportation Services), served as JSONP and unwrapped with an anchored pattern. This is the municipal network the Ontario 511 pack does not carry: downtown arterials plus the Gardiner, DVP, Allen and Lake Shore. The list publishes no frame URL, so frame URLs are BUILT from the documented `CameraImages/loc####.jpg` convention and a strictly-digits camera number, pinning the frame proxy to the portal origin by construction; the list fetch refuses redirects and bounds the body it buffers. Frames are fetched at request time and never stored or redistributed. The dataset publishes no camera facing: the `D1`-`D4` fields are the directions of the _comparison_ images (static reference stills captured in 2016 under a different path), not a bearing for the live pan-tilt-zoom frame, so headings use the shared id-hash fallback at low confidence and are corrected with the in-app calibration gizmo. A camera that is temporarily out of service still answers 200 with a byte-identical "Image Unavailable" placeholder rather than an error (about 6% of the network at any moment), so such a camera reads as healthy; the frame it shows is the agency's, not a synthesized one. The licence requires the attribution statement above. Disable with `CCTV_TORONTO_ENABLED=0`.
|
||||
- **City of Toronto RESCU cameras.** Keyless. The camera list is the City's public `tmcearthcameras.json` on `opendata.toronto.ca` (dataset "Traffic Cameras", Transportation Services), served as JSONP and unwrapped with an anchored pattern. This is the municipal network the Ontario 511 pack does not carry: downtown arterials plus the Gardiner, DVP, Allen and Lake Shore. The list publishes no frame URL, so frame URLs are BUILT from the documented `CameraImages/loc####.jpg` convention and a strictly-digits camera number, pinning the frame proxy to the portal origin by construction; the list fetch refuses redirects and bounds the body it buffers. Frames are fetched at request time and never stored or redistributed. The dataset publishes no camera facing: the `D1`-`D4` fields are the directions of the *comparison* images (static reference stills captured in 2016 under a different path), not a bearing for the live pan-tilt-zoom frame, so headings use the shared id-hash fallback at low confidence and are corrected with the in-app calibration gizmo. A camera that is temporarily out of service still answers 200 with a byte-identical "Image Unavailable" placeholder rather than an error (about 6% of the network at any moment), so such a camera reads as healthy; the frame it shows is the agency's, not a synthesized one. The licence requires the attribution statement above. Disable with `CCTV_TORONTO_ENABLED=0`.
|
||||
- **Houston TranStar cameras.** Keyless. The camera list is the public `traffic.houstontranstar.org/data/layers/cctvSnapshots_json.js` catalog (~1,000 cameras across Greater Houston); frames are stills at `www.houstontranstar.org/snapshots/cctv/<id>.jpg`, synthesized from a validated numeric id rather than taken from the payload, and only that host is registered. Cameras whose catalog id is `0` (a different, non-snapshot class) and cameras outside Greater Houston are dropped. TranStar's `dir` field is the side of the freeway the camera sits on, not the way it faces: TranStar's own map shows it as "Traffic closest to the camera is traveling …" (South → eastbound, North → westbound, West → southbound, East → northbound). That travel direction (90°, 270°, 180°, 0°) seeds the heading as a low-confidence prior with the low-confidence pose; `None` or an unknown value uses the shared id-hash fallback at low confidence. Headings are corrected with the in-app calibration gizmo. Off by default. TranStar's [Content Usage terms](https://traffic.houstontranstar.org/disclaimer.aspx) prohibit copying or distributing the site's information, and external framing or linking to specific images, without TxDOT's prior written permission; its FAQ grants permission-free use only for the RSS feeds. This project does not hold that permission for downstream installations, so the pack loads only when an operator who holds TxDOT's written permission sets `CCTV_HOUSTON_ENABLED=1`; with the flag unset, empty or any other value, the server makes no request to TranStar. Once enabled, it loads the 250 cameras nearest downtown, Uptown, the Medical Center, IAH and Galveston; `CCTV_HOUSTON_MAX_SOURCES` (8–400) changes the cap. Snapshots update about every 3 minutes, which is also the ambient still cadence. Frames are fetched from TranStar and relayed to the browser on demand, buffered only transiently per request, sent with `Cache-Control: no-store`, and not archived.
|
||||
- **Autostrada del Brennero (A22) webcams.** Keyless. The camera list is one request to the Open Data Hub tourism API (`tourism.api.opendatahub.com/v1/WebcamInfo?source=a22`), run by NOI Techpark in South Tyrol, which republishes Autobrennero's own list of 13 motorway webcams with coordinates and kilometre markers. Frames are the operator's stills on `www.autobrennero.it/WebCamImg/km<N>.jpg`, refreshed about once a minute, and only the exact image for each camera's kilometre is registered. The feed names no bearing, so headings use the id-hash fallback at low confidence. The road climbs from about 20 m in the Po valley to about 1,370 m at the Brenner Pass, so each camera's ground elevation comes from a per-kilometre table sampled from the Copernicus GLO-90 DEM (via Open-Meteo's elevation API); a camera not in the table uses a 200 m prior. The Open Data Hub tags every record CC0 (`ClosedData: false`, Autobrennero as licence holder), but that tag is the aggregator's metadata and Autobrennero publishes no terms of its own for the images, so they are credited to the operator as a courtesy and are not redistributed. Frames are fetched at request time and never stored. Disable with `CCTV_A22_ENABLED=0`.
|
||||
- **Camera frame content.** Public camera frames can contain people, vehicles and license plates, and the camera layer does nothing with them beyond putting them on the map. A successful upstream response is relayed as the provider served it: nothing in the camera pipeline blurs, redacts, enhances or restores it, and nothing there runs face, plate or object detection or otherwise recognises or classifies what is in the picture. (The ALPR layer described below maps where plate-reader cameras are, from locations contributors tagged in OpenStreetMap; it reads nothing from any camera frame.) When an upstream has no frame for a camera, what you see instead is a Google Street View still or the app's own placeholder card; the panel's source badge names which of them you are looking at, and a refresh that fails after a frame has arrived leaves the last good picture on screen rather than replacing it. The browser resamples each frame for display: onto a fixed 1920x1080 surface for the camera's projection plane in the scene, and onto a 192x108 canvas for the small ambient card. That scaling is the only change made to the picture, and the only pixels the camera layer reads back are a 64x36 downscale hashed to tell whether the picture has changed. Live streams are piped through; the still path reads the image into memory to pass it on — TxDOT wraps its JPEG in a JSON envelope, which is decoded there — and no frame is written to disk (the disk cache, `.gev-cache/`, holds feed JSON for other layers and never camera imagery). Outside that pipeline, the voice assistant is the one feature that sends imagery anywhere: when it answers a question about what is in view it may attach a downscaled screenshot of the rendered scene — including any camera plane on screen — to the request it sends to the voice model. Frames are fetched only from server-registered camera URLs — a client cannot hand the proxy a URL (see [SECURITY.md](SECURITY.md)). What the app does stays inside the line README draws: no named-person search, no face recognition, no tracking individuals.
|
||||
@@ -298,7 +298,7 @@ The optional Local ADS-B layer and the broadcast-FM receiver use radio you recei
|
||||
Each Data Library entry is a manifest in `src/library/entries/` pointing at a live upstream its provider hosts; see [docs/DATA-LIBRARY.md](docs/DATA-LIBRARY.md). An entry appears on the map only after a viewer adds it from **DATA LAYERS ▸ Browse data library**, and its attribution is registered in the Data attribution popover while it is in use. This table is generated from the manifests: edit the manifest, then run `npm run library:docs`.
|
||||
|
||||
| Entry | How it is served | Licence / terms | Attribution |
|
||||
| ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| --- | --- | --- | --- |
|
||||
| **Alaska Statewide Imagery (2023)** (`ak-statewide-imagery`, `apps.geo.fpac.usda.gov`) | tiles, bbox, browser-direct | [Public Domain (U.S. Government work)](https://www.usgs.gov/information-policies-and-instructions/copyrights-and-credits) | "USDA / Alaska Geospatial Council" |
|
||||
| **Amsterdam traffic and ANPR camera positions** (`amsterdam-traffic-cameras`, `api.data.amsterdam.nl`) | dataset, geojson, browser-direct; operator adds `amsterdam-traffic-cameras` to `GEV_LIBRARY_ENABLE` | [Gemeente Amsterdam open data: public unless stated otherwise; no named licence](https://schemas.data.amsterdam.nl/datasets/verkeersinformatiesystemen/dataset) | "Gemeente Amsterdam, verkeersinformatiesystemen register (entry contributed by @Maher-Reven)" |
|
||||
| **Arkansas Statewide Imagery (2023)** (`ar-statewide-imagery`, `gis.arkansas.gov`) | tiles, bbox, browser-direct | [Public domain — Arkansas GIS Office open data](https://gis.arkansas.gov/) | "Arkansas GIS Office" |
|
||||
@@ -405,7 +405,7 @@ Static datasets shipped in the repo for an out-of-the-box experience. **None are
|
||||
The [Bhote Koshi event pack](public/events/bhote-koshi-2026/README.md), under `public/events/`, contains Vantor imagery crops and a GeoPera-derived river centerline under **CC BY-NC 4.0**, separately from the MIT code. The derived coordinate dataset in `src/data/bhoteKoshiFloodPath.js` has the same non-commercial restriction and is compiled into the Nepal scene. Commercial users must obtain separate permission or exclude both the event pack and that source-derived dataset from their source and build. Deleting only `public/events/bhote-koshi-2026/` does not remove all restricted data; excluding the scene also requires removing its registrations and imports before building. Linked witness posts and geolocation-map records retain their owners' terms; no social-media clips or cached posters are bundled. Other snapshots below are under `src/data/local_data/`.
|
||||
|
||||
| Dataset | Folder | License | Commercial use? | Attribution |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| --------------------------------------------------------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------- |
|
||||
| **Datacenters** (4,352) | `datacenters/` | **ODbL 1.0** (OpenStreetMap extract) | ✅ (attribution + share-alike on data) | © OpenStreetMap contributors (shared credit) |
|
||||
| **Dams** (704) | `dams/` | **ODbL 1.0** (OpenInfraMap / OSM extract) | ✅ (attribution + share-alike on data) | © OpenStreetMap contributors (shared credit) + Open Infrastructure Map |
|
||||
| **Military area names** (36,466) | `osm_military_names/` | **ODbL 1.0** (OpenStreetMap, via Overture Maps) | ✅ (attribution + share-alike on data) | © OpenStreetMap contributors (shared credit) + Overture Maps Foundation |
|
||||
@@ -640,6 +640,7 @@ Community context: [#85](https://github.com/bilawalsidhu/gods-eye-view/issues/85
|
||||
[#457 clouds](https://github.com/bilawalsidhu/gods-eye-view/pull/457).
|
||||
This implementation is original; those contributions have not been merged here.
|
||||
|
||||
|
||||
### Weather: NHC/CPHC cyclone advisories
|
||||
|
||||
- **Sources:** [NHC current tropical cyclone status](https://www.nhc.noaa.gov/CurrentStorms.json) and
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
- When the globe stops drawing after a render error or a lost WebGL context,
|
||||
an alert dialog says so instead of leaving a frozen or black globe behind
|
||||
working controls. Retry restarts drawing (Reload after a lost context), and
|
||||
Reset view reopens the app without the view restored from the address bar.
|
||||
Cesium's "Rendering has stopped" panel no longer appears in the app
|
||||
(German, @gekh, #1579).
|
||||
@@ -2473,6 +2473,53 @@ future driver fix restores the effect with no code change; iOS/iPadOS platform
|
||||
detection is the backstop for when no probe context can be created. Applied
|
||||
during viewer construction, before any tile builds a draw command.
|
||||
|
||||
## Render failure notice
|
||||
|
||||
When the globe stops drawing, the scene chrome says so instead of leaving a
|
||||
black globe behind working controls. `installRenderFailureNotice()`
|
||||
(`src/ui/renderFailure.js`) listens for Cesium's `renderError` and the canvas'
|
||||
`webglcontextlost`, logs the error, and publishes a notice that
|
||||
`RenderFailure.vue` shows as an alert dialog with focus on its first action.
|
||||
The app's viewer uses `showRenderLoopErrors: false`, so Cesium's dead-end
|
||||
"Rendering has stopped" panel no longer appears; `applicationViewerOptions()`
|
||||
keeps it by default for other callers.
|
||||
|
||||
- **Retry** restarts the render loop. The notice stays until a frame starts
|
||||
and ends without an error: Cesium raises `postRender` after a failed frame
|
||||
too.
|
||||
- **Reload**, after a lost context, reloads the page; the address keeps the
|
||||
view.
|
||||
- **Reset view** opens `appRootUrl()`, without the hash or `/share/<code>`
|
||||
path; the query, such as `?lang=`, is kept.
|
||||
|
||||
Pitfalls:
|
||||
|
||||
- An error thrown outside Scene's error handling (a frame listener, `onTick`,
|
||||
a resize) stops the loop without a `renderError`. The notice wraps the
|
||||
widget's `render()` and `resize()` and raises it as one, once even with
|
||||
`rethrowRenderErrors`.
|
||||
- A throwing listener leaves its Cesium event mid-raise, with listener changes
|
||||
only queued. The wrapper finishes those raises first (`finishRaise()` over
|
||||
`frameEvents()`), so a layer turned off or on meanwhile behaves.
|
||||
- A render error marks the loop stopped while its next frame is still queued.
|
||||
The wrapper keeps the loop marked running, so a Retry or a shown tab
|
||||
(`src/app/tools.js`) before that frame starts no second loop.
|
||||
- After a lost context, later render errors are only logged, so the notice
|
||||
keeps saying why. The listener neither prevents nor restores the loss.
|
||||
- When the globe draws again, focus goes back where it was, or to the globe's
|
||||
canvas, which the map's keys read as the map; the canvas is focusable only
|
||||
until focus leaves or the globe is pressed. Focus the user moved stays put.
|
||||
- The notice sits above floating panels such as the Québec camera viewer, and
|
||||
its buttons are 44 px tall on touch screens.
|
||||
|
||||
An inline conversation panel never reloads or navigates its host's page: it
|
||||
offers Retry after a render error only, and no notice after a lost context,
|
||||
where the panel runtime's own notice applies (`src/app/globePanelRuntime.js`).
|
||||
Its timer (`keepPanelRendering()`) draws only while the render loop is on and
|
||||
logs nothing itself, so each render error is logged once, by the notice. An
|
||||
error a timer frame throws is caught there: it has already been raised as a
|
||||
render error.
|
||||
|
||||
## Map Source control ownership
|
||||
|
||||
Map Source controls own chip listeners, source-state subscriptions and selection
|
||||
|
||||
@@ -9,7 +9,7 @@ like the source code. The exception is NASA's model of the ISS, described in
|
||||
[its own section](#the-iss-model-issglb) below.
|
||||
|
||||
| Path | What it holds |
|
||||
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
|---|---|
|
||||
| `fleet/catalog.json` | Every model by name: its file, category, built length, beam and bounds (metres, in Cesium's Z-up model frame: x along the length with the nose toward −X, y across the beam, z up), the clearance below its origin, and its 2D icon class. |
|
||||
| `fleet/types.json` | Which model draws which vehicle, and at what length: ICAO aircraft and helicopter type codes, ADS-B emitter categories, AIS ship-type and length ranges, GTFS route types, transit modes and rail categories, with the defaults. |
|
||||
| `fleet/aircraft/`, `fleet/helicopters/`, `fleet/ships/`, `fleet/buoys/`, `fleet/transit/`, `fleet/other/` | The models, one GLB each (EXT_meshopt_compression and KHR_mesh_quantization, vertex colours, no textures). |
|
||||
|
||||
@@ -557,6 +557,13 @@
|
||||
"src/ui/frameRateMonitor.js",
|
||||
"src/ui/frameRateMonitor.test.mjs",
|
||||
"src/ui/frameRateView.test.mjs",
|
||||
"src/ui/renderFailure.test.mjs",
|
||||
"src/ui/renderFailureView.test.mjs",
|
||||
"src/ui/renderFailureLoopErrors.test.mjs",
|
||||
"src/ui/renderFailureEventRetry.test.mjs",
|
||||
"src/app/renderFailureInlineRetry.test.mjs",
|
||||
"src/ui/renderFailureSecondLoop.test.mjs",
|
||||
"src/ui/renderLoopFixture.mjs",
|
||||
"src/layers/cctv/lifecycle.js",
|
||||
"src/layers/cctv/controls.js",
|
||||
"src/layers/cctv/geometry.js",
|
||||
|
||||
@@ -163,6 +163,7 @@
|
||||
"src/ui/kit/UiBadge.vue",
|
||||
"src/ui/stores/globeActions.js",
|
||||
"src/ui/views/panels/GlobeActions.vue",
|
||||
"src/ui/views/panels/RenderFailure.vue",
|
||||
"src/ui/views/panels/GlobeCompass.vue",
|
||||
"src/ui/stores/recording.js",
|
||||
"src/ui/styleParameters.js",
|
||||
@@ -3140,6 +3141,7 @@
|
||||
"src/ui/displayControls.js",
|
||||
"src/ui/effects.js",
|
||||
"src/ui/frameRateMonitor.js",
|
||||
"src/ui/renderFailure.js",
|
||||
"src/ui/layerPanel.js",
|
||||
"src/ui/weatherPanel.js",
|
||||
"src/ui/railCards.js",
|
||||
|
||||
@@ -400,6 +400,27 @@ test('Enter finishes from the canvas and the label field, never from a focused b
|
||||
}
|
||||
});
|
||||
|
||||
test('Enter on the globe canvas finishes, as after the render failure notice hands focus back', async () => {
|
||||
const h = harness();
|
||||
try {
|
||||
h.act('toggleDraw');
|
||||
h.tool.setShape('area');
|
||||
h.tool.addVertex(-97.75, 30.26);
|
||||
h.tool.addVertex(-97.74, 30.26);
|
||||
h.tool.addVertex(-97.74, 30.27);
|
||||
|
||||
// src/ui/views/panels/RenderFailure.vue focuses the canvas when the globe
|
||||
// draws again and the control that had focus is gone.
|
||||
h.documentDouble.emit('keydown', { key: 'Enter', target: h.viewer.scene.canvas });
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
assert.equal(h.annotations.calls.annotate.length, 1, 'Enter on the canvas finishes');
|
||||
assert.equal(h.annotations.calls.annotate[0].specs[0].type, 'area');
|
||||
} finally {
|
||||
h.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('the live preview hangs at the height the click landed on', async () => {
|
||||
const h = harness();
|
||||
try {
|
||||
|
||||
+9
-26
@@ -94,17 +94,6 @@ export function panelAwareVisibility(doc = globalThis.document) {
|
||||
const PANEL_FRAME_MS = 33;
|
||||
const MISSED_FRAMES_MS = 250;
|
||||
|
||||
/** A render error's details, including the plain objects workers report. */
|
||||
function describeError(error) {
|
||||
if (error instanceof Error)
|
||||
return `${error.name}: ${error.message}\n${error.stack}`;
|
||||
try {
|
||||
return JSON.stringify(error, Object.getOwnPropertyNames(error ?? {}));
|
||||
} catch {
|
||||
return String(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep the globe drawing in an inline panel. Some hosts report a panel on
|
||||
* screen as hidden, which stops the browser's animation frames and with them
|
||||
@@ -122,33 +111,27 @@ export function keepPanelRendering(
|
||||
frameRequest = windowRef.requestAnimationFrame(onFrame);
|
||||
};
|
||||
frameRequest = windowRef.requestAnimationFrame(onFrame);
|
||||
// Cesium stops drawing after a render error, and so does the timer.
|
||||
// Report the error in full: workers report plain objects, which Cesium
|
||||
// prints as [object Object].
|
||||
let failed = false;
|
||||
const removeErrorListener = viewer.scene?.renderError?.addEventListener(
|
||||
(_scene, error) => {
|
||||
failed = true;
|
||||
console.error(
|
||||
"[God's Eye View panel] render error:",
|
||||
describeError(error),
|
||||
);
|
||||
},
|
||||
);
|
||||
// Cesium stops its render loop after a render error, and the timer stops
|
||||
// with it; Retry restarts both. The render failure notice logs the error
|
||||
// (src/ui/renderFailure.js).
|
||||
const timer = windowRef.setInterval(() => {
|
||||
if (
|
||||
failed ||
|
||||
viewer.useDefaultRenderLoop === false ||
|
||||
now() - lastFrame < MISSED_FRAMES_MS ||
|
||||
viewer.isDestroyed?.()
|
||||
)
|
||||
return;
|
||||
try {
|
||||
viewer.resize();
|
||||
viewer.render();
|
||||
} catch {
|
||||
// Raised as a render error by now (src/ui/renderFailure.js), which
|
||||
// stops this timer; thrown on, it would only reach the host page.
|
||||
}
|
||||
}, PANEL_FRAME_MS);
|
||||
return () => {
|
||||
windowRef.clearInterval(timer);
|
||||
windowRef.cancelAnimationFrame(frameRequest);
|
||||
removeErrorListener?.();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+8
-21
@@ -457,8 +457,7 @@ test('a panel keeps drawing from a timer while animation frames stop', () => {
|
||||
assert.equal(frame, null);
|
||||
});
|
||||
|
||||
test('a panel reports a render error in full and stops drawing', () => {
|
||||
let listener = null;
|
||||
test('a panel stops drawing while its render loop is stopped', () => {
|
||||
let tick = null;
|
||||
const windowRef = {
|
||||
requestAnimationFrame: () => 1,
|
||||
@@ -467,31 +466,19 @@ test('a panel reports a render error in full and stops drawing', () => {
|
||||
clearInterval() {},
|
||||
};
|
||||
const drawn = [];
|
||||
const viewer = {
|
||||
resize() {},
|
||||
render: () => drawn.push('render'),
|
||||
scene: {
|
||||
renderError: {
|
||||
addEventListener: (fn) => ((listener = fn), () => (listener = null)),
|
||||
},
|
||||
},
|
||||
};
|
||||
const logged = [];
|
||||
const original = console.error;
|
||||
console.error = (...args) => logged.push(args.join(' '));
|
||||
try {
|
||||
const viewer = { resize() {}, render: () => drawn.push('render') };
|
||||
let clock = 0;
|
||||
const stop = keepPanelRendering(viewer, { windowRef, now: () => clock });
|
||||
listener(viewer.scene, { name: 'RuntimeError', message: 'worker failed' });
|
||||
assert.match(logged[0], /render error: .*"message":"worker failed"/);
|
||||
// Cesium stops its render loop after a render error.
|
||||
viewer.useDefaultRenderLoop = false;
|
||||
clock = 1000;
|
||||
tick();
|
||||
assert.deepEqual(drawn, []);
|
||||
// Retry restarts it, and the timer draws again.
|
||||
viewer.useDefaultRenderLoop = true;
|
||||
tick();
|
||||
assert.deepEqual(drawn, ['render']);
|
||||
stop();
|
||||
assert.equal(listener, null);
|
||||
} finally {
|
||||
console.error = original;
|
||||
}
|
||||
});
|
||||
|
||||
test('a followed aircraft owns the camera, and cockpit view is entered after it', async () => {
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
// Retry in an inline panel whose host stops animation frames, so the panel
|
||||
// draws from keepPanelRendering's timer. Drives Cesium's real startRenderLoop
|
||||
// and useDefaultRenderLoop setter (CesiumWidget.prototype).
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import { keepPanelRendering } from './embed.js';
|
||||
import { renderLoopFixture } from '../ui/renderLoopFixture.mjs';
|
||||
|
||||
function setup() {
|
||||
let tick = null;
|
||||
let clock = 0;
|
||||
// The host reports the panel hidden: its own animation frames never arrive.
|
||||
const windowRef = {
|
||||
requestAnimationFrame: () => 1,
|
||||
cancelAnimationFrame() {},
|
||||
setInterval: (fn) => ((tick = fn), 1),
|
||||
clearInterval() {},
|
||||
};
|
||||
const previousError = console.error;
|
||||
console.error = () => {};
|
||||
const state = { failure: null, drawn: 0 };
|
||||
const scene = {
|
||||
renderError: new Cesium.Event(),
|
||||
preUpdate: new Cesium.Event(),
|
||||
postRender: new Cesium.Event(),
|
||||
requestRender() {},
|
||||
initializeFrame() {},
|
||||
// Scene.render: a failing primitive update raises renderError
|
||||
// (tryAndCatchError) and returns; a failing listener throws.
|
||||
render() {
|
||||
state.drawn += 1;
|
||||
this.preUpdate.raiseEvent(this);
|
||||
if (state.failure === 'caught')
|
||||
this.renderError.raiseEvent(this, new Error('boom'));
|
||||
if (state.failure === 'thrown') throw new Error('boom');
|
||||
this.postRender.raiseEvent(this);
|
||||
},
|
||||
};
|
||||
const { frames, widget, viewer, store, runFrames, restore } =
|
||||
renderLoopFixture(scene, {
|
||||
viewer: {
|
||||
isDestroyed: () => false,
|
||||
render: () => widget.render(),
|
||||
resize: () => widget.resize(),
|
||||
},
|
||||
notice: { allowReload: false },
|
||||
});
|
||||
const stop = keepPanelRendering(viewer, { windowRef, now: () => clock });
|
||||
viewer.useDefaultRenderLoop = true;
|
||||
const timerFrame = () => {
|
||||
clock += 400;
|
||||
tick();
|
||||
};
|
||||
return {
|
||||
frames,
|
||||
state,
|
||||
store,
|
||||
timerFrame,
|
||||
animationFrames: runFrames,
|
||||
restore: () => {
|
||||
stop();
|
||||
restore();
|
||||
console.error = previousError;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
for (const failure of ['caught', 'thrown']) {
|
||||
test(`an error ${failure} in a frame the timer draws: Retry draws again with one render loop`, () => {
|
||||
const { frames, state, store, timerFrame, animationFrames, restore } =
|
||||
setup();
|
||||
try {
|
||||
// The host stops animation frames with the loop's next one queued.
|
||||
assert.equal(frames.length, 1);
|
||||
state.failure = failure;
|
||||
timerFrame(); // an error thrown here does not reach the host page
|
||||
assert.equal(store.renderFailure?.reason, 'render-error');
|
||||
assert.equal(typeof store.renderFailure.retry, 'function');
|
||||
state.failure = null;
|
||||
store.renderFailure.retry();
|
||||
const before = state.drawn;
|
||||
timerFrame();
|
||||
assert.ok(state.drawn > before, 'the panel draws again after Retry');
|
||||
assert.equal(
|
||||
store.renderFailure,
|
||||
null,
|
||||
'a clean frame clears the notice',
|
||||
);
|
||||
assert.equal(frames.length, 1, 'Retry starts no second loop');
|
||||
// The host resumes frames: the globe draws once a frame.
|
||||
state.drawn = 0;
|
||||
animationFrames(3);
|
||||
assert.equal(state.drawn, 3);
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
test('an error Scene caught in an animation frame right before the host stopped frames: Retry keeps one render loop', () => {
|
||||
const { frames, state, store, timerFrame, animationFrames, restore } =
|
||||
setup();
|
||||
try {
|
||||
state.failure = 'caught';
|
||||
animationFrames(1);
|
||||
assert.equal(store.renderFailure?.reason, 'render-error');
|
||||
assert.equal(frames.length, 1);
|
||||
state.failure = null;
|
||||
store.renderFailure.retry();
|
||||
timerFrame();
|
||||
assert.equal(store.renderFailure, null);
|
||||
assert.equal(frames.length, 1, 'Retry starts no second loop');
|
||||
state.drawn = 0;
|
||||
animationFrames(3);
|
||||
assert.equal(state.drawn, 3);
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
});
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
governorRequestRender,
|
||||
} from '../renderGovernor.js';
|
||||
import { describeError } from './errors.js';
|
||||
import { isEmbeddedInline } from './embed.js';
|
||||
import { installRenderFailureNotice } from '../ui/renderFailure.js';
|
||||
import { worldClock, worldTimeFor } from '../time/worldClock.js';
|
||||
import { followWorldTime } from '../time/viewerClock.js';
|
||||
import { onLocaleChange, t } from '../i18n/index.js';
|
||||
@@ -55,11 +57,17 @@ export async function createApplicationScene({
|
||||
const viewer = createApplicationViewer({
|
||||
container: 'cesiumContainer',
|
||||
creditContainer,
|
||||
// The render failure notice below replaces Cesium's dead-end panel.
|
||||
showRenderLoopErrors: false,
|
||||
});
|
||||
defer(() => {
|
||||
uninstallRenderGovernor(viewer);
|
||||
if (!viewer.isDestroyed()) viewer.destroy();
|
||||
});
|
||||
// An inline panel must not reload or navigate its host's page.
|
||||
defer(
|
||||
installRenderFailureNotice(viewer, { allowReload: !isEmbeddedInline() }),
|
||||
);
|
||||
defer(installTrackpadPinchZoom(viewer));
|
||||
defer(
|
||||
followWorldTime(viewer, worldTimeFor('sky'), {
|
||||
|
||||
+16
-4
@@ -375,8 +375,15 @@ export function installGlobeInViewRecovery(
|
||||
};
|
||||
}
|
||||
|
||||
/** Cesium.Viewer options of the standard globe viewer. */
|
||||
export function applicationViewerOptions(creditContainer) {
|
||||
/**
|
||||
* Cesium.Viewer options of the standard globe viewer. `showRenderLoopErrors`
|
||||
* false leaves render errors to the caller's own notice instead of Cesium's
|
||||
* panel.
|
||||
*/
|
||||
export function applicationViewerOptions(
|
||||
creditContainer,
|
||||
{ showRenderLoopErrors = true } = {},
|
||||
) {
|
||||
return {
|
||||
timeline: false,
|
||||
animation: false,
|
||||
@@ -396,16 +403,21 @@ export function applicationViewerOptions(creditContainer) {
|
||||
creditContainer,
|
||||
msaaSamples: 4,
|
||||
contextOptions: { webgl: { preserveDrawingBuffer: true } },
|
||||
showRenderLoopErrors,
|
||||
};
|
||||
}
|
||||
|
||||
/** Create the standard globe viewer in caller-owned, visible containers. */
|
||||
export function createApplicationViewer({ container, creditContainer }) {
|
||||
export function createApplicationViewer({
|
||||
container,
|
||||
creditContainer,
|
||||
showRenderLoopErrors,
|
||||
}) {
|
||||
if (!container || !creditContainer)
|
||||
throw new TypeError('Viewer and credit containers are required');
|
||||
const viewer = new Cesium.Viewer(
|
||||
container,
|
||||
applicationViewerOptions(creditContainer),
|
||||
applicationViewerOptions(creditContainer, { showRenderLoopErrors }),
|
||||
);
|
||||
try {
|
||||
viewer.targetFrameRate = 60;
|
||||
|
||||
@@ -3954,6 +3954,13 @@
|
||||
"Remove every added entry from Data Layers": "إزالة كل الإدخالات المُضافة من طبقات البيانات",
|
||||
"Showing {shown} of {total}": "عرض {shown} من {total}",
|
||||
"BROWSE DATA LIBRARY": "تصفّح مكتبة البيانات",
|
||||
"The globe stopped drawing": "توقفت الكرة الأرضية عن الرسم",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "استعاد المتصفح رسومات الكرة الأرضية ثلاثية الأبعاد. لا تزال الطبقات وعناصر التحكم تعمل، لكن الخريطة لن تُرسم حتى تُعاد تحميل الصفحة.",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "توقف العرض بعد خطأ. لا تزال الطبقات وعناصر التحكم تعمل، لكن الخريطة لا يتم تحديثها.",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "تعيد «إعادة ضبط العرض» تحميل التطبيق دون العرض المستعاد من شريط العنوان.",
|
||||
"Reload": "إعادة التحميل",
|
||||
"Retry": "إعادة المحاولة",
|
||||
"Reset view": "إعادة ضبط العرض",
|
||||
"ISS live video": "بث مباشر من محطة الفضاء الدولية",
|
||||
"ISS LIVE · NASA": "محطة الفضاء الدولية مباشر · NASA",
|
||||
"Open on YouTube": "فتح على YouTube",
|
||||
|
||||
@@ -3606,6 +3606,13 @@
|
||||
"Remove every added entry from Data Layers": "Alle hinzugefügten Einträge aus Datenebenen entfernen",
|
||||
"Showing {shown} of {total}": "{shown} von {total} angezeigt",
|
||||
"BROWSE DATA LIBRARY": "DATENBIBLIOTHEK DURCHSUCHEN",
|
||||
"The globe stopped drawing": "Der Globus zeichnet nicht mehr",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "Der Browser hat dem Globus die 3D-Grafik entzogen. Ebenen und Bedienelemente funktionieren weiter, aber die Karte kann erst nach dem Neuladen der Seite wieder zeichnen.",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "Das Rendern wurde nach einem Fehler angehalten. Ebenen und Bedienelemente funktionieren weiter, aber die Karte wird nicht aktualisiert.",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "Ansicht zurücksetzen lädt die App ohne die aus der Adressleiste wiederhergestellte Ansicht neu.",
|
||||
"Reload": "Neu laden",
|
||||
"Retry": "Erneut versuchen",
|
||||
"Reset view": "Ansicht zurücksetzen",
|
||||
"ISS live video": "ISS-Livevideo",
|
||||
"ISS LIVE · NASA": "ISS LIVE · NASA",
|
||||
"Open on YouTube": "Auf YouTube öffnen",
|
||||
|
||||
@@ -3693,6 +3693,13 @@
|
||||
"1,000–2,000 m": "1000–2000 m",
|
||||
"2,000–3,000 m": "2000–3000 m",
|
||||
"3,000 m and above": "3000 m o más",
|
||||
"The globe stopped drawing": "El globo dejó de dibujarse",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "El navegador retiró los gráficos 3D del globo. Las capas y los controles siguen funcionando, pero el mapa no se dibujará hasta que se recargue la página.",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "El renderizado se detuvo tras un error. Las capas y los controles siguen funcionando, pero el mapa no se actualiza.",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "Restablecer la vista recarga la app sin la vista restaurada desde la barra de direcciones.",
|
||||
"Reload": "Recargar",
|
||||
"Retry": "Reintentar",
|
||||
"Reset view": "Restablecer la vista",
|
||||
"ISS live video": "Vídeo en directo de la ISS",
|
||||
"ISS LIVE · NASA": "ISS EN DIRECTO · NASA",
|
||||
"Open on YouTube": "Abrir en YouTube",
|
||||
|
||||
@@ -3693,6 +3693,13 @@
|
||||
"Remove every added entry from Data Layers": "Retirer du panneau Couches toutes les entrées ajoutées",
|
||||
"Showing {shown} of {total}": "Affichées : {shown} sur {total}",
|
||||
"BROWSE DATA LIBRARY": "PARCOURIR LA BIBLIOTHÈQUE DE DONNÉES",
|
||||
"The globe stopped drawing": "Le globe ne s’affiche plus",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "Le navigateur a retiré au globe ses graphismes 3D. Les calques et les commandes fonctionnent toujours, mais la carte ne pourra s’afficher qu’après le rechargement de la page.",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "Le rendu s’est arrêté après une erreur. Les calques et les commandes fonctionnent toujours, mais la carte ne se met plus à jour.",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "Réinitialiser la vue recharge l’app sans la vue restaurée depuis la barre d’adresse.",
|
||||
"Reload": "Recharger",
|
||||
"Retry": "Réessayer",
|
||||
"Reset view": "Réinitialiser la vue",
|
||||
"ISS live video": "Vidéo en direct de l’ISS",
|
||||
"ISS LIVE · NASA": "ISS EN DIRECT · NASA",
|
||||
"Open on YouTube": "Ouvrir sur YouTube",
|
||||
|
||||
@@ -3693,6 +3693,13 @@
|
||||
"Remove every added entry from Data Layers": "הסרת כל הפריטים שנוספו משכבות נתונים",
|
||||
"Showing {shown} of {total}": "מוצגים {shown} מתוך {total}",
|
||||
"BROWSE DATA LIBRARY": "עיון בספריית הנתונים",
|
||||
"The globe stopped drawing": "הגלובוס הפסיק להצטייר",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "הדפדפן לקח בחזרה את הגרפיקה התלת-ממדית של הגלובוס. השכבות והפקדים עדיין פועלים, אבל המפה לא תוכל להצטייר עד שהעמוד ייטען מחדש.",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "הרינדור נעצר בעקבות שגיאה. השכבות והפקדים עדיין פועלים, אבל המפה אינה מתעדכנת.",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "\"איפוס תצוגה\" טוען מחדש את האפליקציה בלי התצוגה ששוחזרה משורת הכתובת.",
|
||||
"Reload": "טען מחדש",
|
||||
"Retry": "נסה שוב",
|
||||
"Reset view": "איפוס תצוגה",
|
||||
"ISS live video": "שידור חי מתחנת החלל",
|
||||
"ISS LIVE · NASA": "ISS בשידור חי · NASA",
|
||||
"Open on YouTube": "פתיחה ב-YouTube",
|
||||
|
||||
@@ -3693,6 +3693,13 @@
|
||||
"Remove every added entry from Data Layers": "Rimuovi da Livelli dati tutte le voci aggiunte",
|
||||
"Showing {shown} of {total}": "Mostrati: {shown} su {total}",
|
||||
"BROWSE DATA LIBRARY": "ESPLORA LIBRERIA DATI",
|
||||
"The globe stopped drawing": "Il globo ha smesso di disegnare",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "Il browser ha ritirato la grafica 3D del globo. Livelli e controlli funzionano ancora, ma la mappa non può essere disegnata finché la pagina non viene ricaricata.",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "Il rendering si è fermato dopo un errore. Livelli e controlli funzionano ancora, ma la mappa non si aggiorna.",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "Ripristina vista ricarica l’app senza la vista ripristinata dalla barra degli indirizzi.",
|
||||
"Reload": "Ricarica",
|
||||
"Retry": "Riprova",
|
||||
"Reset view": "Ripristina vista",
|
||||
"ISS live video": "Video in diretta dalla ISS",
|
||||
"ISS LIVE · NASA": "ISS IN DIRETTA · NASA",
|
||||
"Open on YouTube": "Apri su YouTube",
|
||||
|
||||
@@ -3519,6 +3519,13 @@
|
||||
"Remove every added entry from Data Layers": "追加したすべての項目をデータレイヤーから削除",
|
||||
"Showing {shown} of {total}": "{total}件中{shown}件を表示",
|
||||
"BROWSE DATA LIBRARY": "データライブラリを見る",
|
||||
"The globe stopped drawing": "地球儀の描画が止まりました",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "ブラウザーが地球儀の 3D グラフィックスを解放しました。レイヤーと操作は引き続き使えますが、ページを再読み込みするまで地図は描画されません。",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "エラーのため描画が停止しました。レイヤーと操作は引き続き使えますが、地図は更新されません。",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "「ビューをリセット」は、アドレスバーから復元したビューを使わずにアプリを再読み込みします。",
|
||||
"Reload": "再読み込み",
|
||||
"Retry": "再試行",
|
||||
"Reset view": "ビューをリセット",
|
||||
"ISS live video": "ISSのライブ映像",
|
||||
"ISS LIVE · NASA": "ISS ライブ · NASA",
|
||||
"Open on YouTube": "YouTubeで開く",
|
||||
|
||||
@@ -3693,6 +3693,13 @@
|
||||
"Remove every added entry from Data Layers": "Remover de \"Camadas de dados\" todas as entradas adicionadas",
|
||||
"Showing {shown} of {total}": "Mostrando {shown} de {total}",
|
||||
"BROWSE DATA LIBRARY": "EXPLORAR BIBLIOTECA DE DADOS",
|
||||
"The globe stopped drawing": "O globo parou de desenhar",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "O navegador retirou os gráficos 3D do globo. As camadas e os controles continuam funcionando, mas o mapa só volta a ser desenhado depois de recarregar a página.",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "A renderização parou após um erro. As camadas e os controles continuam funcionando, mas o mapa não está sendo atualizado.",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "Redefinir vista recarrega o app sem a vista restaurada da barra de endereços.",
|
||||
"Reload": "Recarregar",
|
||||
"Retry": "Tentar novamente",
|
||||
"Reset view": "Redefinir vista",
|
||||
"ISS live video": "Vídeo ao vivo da ISS",
|
||||
"ISS LIVE · NASA": "ISS AO VIVO · NASA",
|
||||
"Open on YouTube": "Abrir no YouTube",
|
||||
|
||||
@@ -3780,6 +3780,13 @@
|
||||
"1,000–2,000 m": "1000–2000 м",
|
||||
"2,000–3,000 m": "2000–3000 м",
|
||||
"3,000 m and above": "3000 м и выше",
|
||||
"The globe stopped drawing": "Глобус перестал отрисовываться",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "Браузер отключил 3D-графику глобуса. Слои и элементы управления работают, но карта не отрисуется, пока страница не будет перезагружена.",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "Отрисовка остановилась из-за ошибки. Слои и элементы управления работают, но карта не обновляется.",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "«Сбросить вид» перезагружает приложение без вида, восстановленного из адресной строки.",
|
||||
"Reload": "Перезагрузить",
|
||||
"Retry": "Повторить",
|
||||
"Reset view": "Сбросить вид",
|
||||
"ISS live video": "Прямая трансляция с МКС",
|
||||
"ISS LIVE · NASA": "МКС В ЭФИРЕ · NASA",
|
||||
"Open on YouTube": "Открыть на YouTube",
|
||||
|
||||
@@ -3606,6 +3606,13 @@
|
||||
"Remove every added entry from Data Layers": "Ta bort alla tillagda poster från Datalager",
|
||||
"Showing {shown} of {total}": "Visar {shown} av {total}",
|
||||
"BROWSE DATA LIBRARY": "BLÄDDRA I DATABIBLIOTEKET",
|
||||
"The globe stopped drawing": "Globen ritas inte längre",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "Webbläsaren tog tillbaka globens 3D-grafik. Lager och reglage fungerar fortfarande, men kartan kan inte ritas förrän sidan laddas om.",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "Renderingen stoppades efter ett fel. Lager och reglage fungerar fortfarande, men kartan uppdateras inte.",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "”Återställ vy” laddar om appen utan vyn som återställdes från adressfältet.",
|
||||
"Reload": "Ladda om",
|
||||
"Retry": "Försök igen",
|
||||
"Reset view": "Återställ vy",
|
||||
"ISS live video": "Livevideo från ISS",
|
||||
"ISS LIVE · NASA": "ISS LIVE · NASA",
|
||||
"Open on YouTube": "Öppna på YouTube",
|
||||
|
||||
@@ -3780,6 +3780,13 @@
|
||||
"Remove every added entry from Data Layers": "Видалити всі додані записи з «Шарів даних»",
|
||||
"Showing {shown} of {total}": "Показано {shown} з {total}",
|
||||
"BROWSE DATA LIBRARY": "ВІДКРИТИ БІБЛІОТЕКУ ДАНИХ",
|
||||
"The globe stopped drawing": "Глобус перестав відмальовуватися",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "Браузер вимкнув 3D-графіку глобуса. Шари та елементи керування працюють, але карта не відмалюється, доки сторінку не буде перезавантажено.",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "Відмальовування зупинилося через помилку. Шари та елементи керування працюють, але карта не оновлюється.",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "«Скинути вигляд» перезавантажує застосунок без вигляду, відновленого з адресного рядка.",
|
||||
"Reload": "Перезавантажити",
|
||||
"Retry": "Повторити",
|
||||
"Reset view": "Скинути вигляд",
|
||||
"ISS live video": "Пряма трансляція з МКС",
|
||||
"ISS LIVE · NASA": "МКС НАЖИВО · NASA",
|
||||
"Open on YouTube": "Відкрити на YouTube",
|
||||
|
||||
@@ -3519,6 +3519,13 @@
|
||||
"Remove every added entry from Data Layers": "从数据图层中移除所有已添加条目",
|
||||
"Showing {shown} of {total}": "显示 {shown} / {total}",
|
||||
"BROWSE DATA LIBRARY": "浏览数据资源库",
|
||||
"The globe stopped drawing": "地球已停止绘制",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "浏览器收回了地球的 3D 图形。图层和控件仍可使用,但在重新加载页面之前地图无法绘制。",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "渲染因错误而停止。图层和控件仍可使用,但地图不再更新。",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "“重置视图”会重新加载应用,不使用从地址栏恢复的视图。",
|
||||
"Reload": "重新加载",
|
||||
"Retry": "重试",
|
||||
"Reset view": "重置视图",
|
||||
"ISS live video": "国际空间站直播视频",
|
||||
"ISS LIVE · NASA": "国际空间站直播 · NASA",
|
||||
"Open on YouTube": "在 YouTube 上打开",
|
||||
|
||||
@@ -3519,6 +3519,13 @@
|
||||
"Remove every added entry from Data Layers": "從數據圖層中移除所有已添加條目",
|
||||
"Showing {shown} of {total}": "顯示 {shown} / {total}",
|
||||
"BROWSE DATA LIBRARY": "瀏覽數據資源庫",
|
||||
"The globe stopped drawing": "地球已停止繪製",
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.": "瀏覽器收回了地球的 3D 圖形。圖層和控件仍可使用,但在重新加載頁面之前地圖無法繪製。",
|
||||
"Rendering stopped after an error. Layers and controls still work, but the map is not updating.": "渲染因錯誤而停止。圖層和控件仍可使用,但地圖不再更新。",
|
||||
"Reset view reloads the app without the view restored from the address bar.": "「重置視圖」會重新加載應用,不使用從地址欄恢復的視圖。",
|
||||
"Reload": "重新加載",
|
||||
"Retry": "重試",
|
||||
"Reset view": "重置視圖",
|
||||
"ISS live video": "國際太空站直播影片",
|
||||
"ISS LIVE · NASA": "國際太空站直播 · NASA",
|
||||
"Open on YouTube": "在 YouTube 上開啟",
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
import { useStatusStore } from './stores/status.js';
|
||||
import { applicationPinia } from './vueRuntime.js';
|
||||
import { describeError } from '../app/errors.js';
|
||||
import { appRootUrl } from '../share/shareLinkPath.js';
|
||||
|
||||
/**
|
||||
* Show a recoverable notice when the globe stops drawing, instead of a black
|
||||
* globe behind working controls. Retry restarts the render loop, or reloads
|
||||
* after a lost WebGL context; Reset opens the app's root address. With
|
||||
* `allowReload: false`, Reset is dropped and a lost context shows no notice:
|
||||
* only a reload draws again, and the page says so itself.
|
||||
* Returns a function that removes the notice.
|
||||
*/
|
||||
export function installRenderFailureNotice(
|
||||
viewer,
|
||||
{
|
||||
store = useStatusStore(applicationPinia()),
|
||||
locationRef = globalThis.location,
|
||||
allowReload = true,
|
||||
logError = (error) =>
|
||||
console.error('[Render] The globe stopped drawing:', error),
|
||||
} = {},
|
||||
) {
|
||||
const { scene } = viewer;
|
||||
const { canvas } = viewer;
|
||||
let notice = null;
|
||||
let contextLost = false;
|
||||
// With rethrowRenderErrors, Scene throws the error it has just raised;
|
||||
// the render() wrapper must not raise it again.
|
||||
let raisedByScene = null;
|
||||
let frameFailed = false;
|
||||
let removeFrameListeners = null;
|
||||
|
||||
function retry() {
|
||||
if (contextLost) {
|
||||
locationRef.reload();
|
||||
return;
|
||||
}
|
||||
viewer.useDefaultRenderLoop = true;
|
||||
scene.requestRender();
|
||||
}
|
||||
|
||||
function reset() {
|
||||
locationRef.assign(appRootUrl(locationRef.href));
|
||||
}
|
||||
|
||||
function stopWatchingFrames() {
|
||||
removeFrameListeners?.();
|
||||
removeFrameListeners = null;
|
||||
}
|
||||
|
||||
function clear() {
|
||||
stopWatchingFrames();
|
||||
if (store.renderFailure === notice) store.publishRenderFailure(null);
|
||||
notice = null;
|
||||
}
|
||||
|
||||
// Cesium raises postRender after a failed frame too, so only a frame that
|
||||
// starts and ends without a render error clears the notice.
|
||||
function watchFrames() {
|
||||
if (removeFrameListeners || contextLost) return;
|
||||
const removeStart = scene.preUpdate.addEventListener(() => {
|
||||
frameFailed = false;
|
||||
raisedByScene = null;
|
||||
});
|
||||
const removeEnd = scene.postRender.addEventListener(() => {
|
||||
if (!frameFailed) clear();
|
||||
});
|
||||
removeFrameListeners = () => {
|
||||
removeStart();
|
||||
removeEnd();
|
||||
};
|
||||
}
|
||||
|
||||
function present(detail) {
|
||||
const reason = contextLost ? 'context-lost' : 'render-error';
|
||||
// A loop restarted into the same error keeps the notice as it was.
|
||||
if (notice?.reason === reason && notice.detail === detail) return;
|
||||
notice = {
|
||||
reason,
|
||||
detail,
|
||||
retry,
|
||||
reset: allowReload ? reset : null,
|
||||
};
|
||||
store.publishRenderFailure(notice);
|
||||
watchFrames();
|
||||
}
|
||||
|
||||
const onRenderError = (_scene, error) => {
|
||||
raisedByScene = { error };
|
||||
frameFailed = true;
|
||||
logError(error);
|
||||
// A lost context fails every frame after it; the notice keeps saying why.
|
||||
if (contextLost) return;
|
||||
present(error ? describeError(error) : '');
|
||||
};
|
||||
const onContextLost = () => {
|
||||
contextLost = true;
|
||||
// No frame can clear this one; only a reload draws again.
|
||||
stopWatchingFrames();
|
||||
// A page that must not reload has nothing to offer: an inline panel
|
||||
// shows its own lost-context notice (src/app/globePanelRuntime.js).
|
||||
if (!allowReload) {
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
present('');
|
||||
};
|
||||
|
||||
const removeRenderError = scene.renderError.addEventListener(onRenderError);
|
||||
// An error thrown outside Scene's error handling (a frame listener, onTick,
|
||||
// resize) stops the loop without a renderError. Raise one, so Cesium, an
|
||||
// inline panel's timer and this notice all see it. First finish the event
|
||||
// raises it cut short, so listeners added or removed meanwhile apply.
|
||||
const unguard = ['resize', 'render'].map((name) =>
|
||||
reportThrown(viewer.cesiumWidget, name, (error) => {
|
||||
frameEvents(viewer).forEach(finishRaise);
|
||||
if (!raisedByScene || raisedByScene.error !== error)
|
||||
scene.renderError.raiseEvent(scene, error);
|
||||
raisedByScene = null;
|
||||
}),
|
||||
);
|
||||
canvas.addEventListener('webglcontextlost', onContextLost);
|
||||
return () => {
|
||||
removeRenderError();
|
||||
unguard.forEach((restore) => restore());
|
||||
canvas.removeEventListener('webglcontextlost', onContextLost);
|
||||
clear();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Events Cesium raises in a frame outside Scene's error handling, which a
|
||||
* listener's error can leave mid-raise. Only top-level tilesets are reached.
|
||||
*/
|
||||
function frameEvents(viewer) {
|
||||
const { scene } = viewer;
|
||||
const events = [
|
||||
scene.preUpdate,
|
||||
scene.postUpdate,
|
||||
scene.preRender,
|
||||
scene.postRender,
|
||||
scene.camera?.changed,
|
||||
scene.camera?.moveStart,
|
||||
scene.camera?.moveEnd,
|
||||
viewer.clock?.onTick,
|
||||
viewer.clock?.onStop,
|
||||
scene.globe?.tileLoadProgressEvent,
|
||||
];
|
||||
const primitives = scene.primitives;
|
||||
for (let i = 0; i < (primitives?.length ?? 0); i += 1) {
|
||||
const tileset = primitives.get(i);
|
||||
events.push(
|
||||
tileset?.loadProgress,
|
||||
tileset?.allTilesLoaded,
|
||||
tileset?.initialTilesLoaded,
|
||||
);
|
||||
}
|
||||
return events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish a raise a throwing listener cut short. Until a raise ends, Cesium's
|
||||
* `Event` only queues added and removed listeners; apply that queue.
|
||||
* These are Cesium's private fields (`_invokingListeners`, `_toAdd`,
|
||||
* `_toRemove`, `_listeners`, and the widget's `_renderLoopRunning`), checked
|
||||
* against cesium 1.138 / @cesium/engine 22.3.0; the render loop fixture tests
|
||||
* drive the real classes and fail when an upgrade renames them.
|
||||
*/
|
||||
function finishRaise(event) {
|
||||
if (!event?._invokingListeners) return;
|
||||
event._invokingListeners = false;
|
||||
for (const [listener, scopes] of event._toAdd) {
|
||||
const added = event._listeners.get(listener) ?? new Set();
|
||||
scopes.forEach((scope) => added.add(scope));
|
||||
event._listeners.set(listener, added);
|
||||
}
|
||||
event._toAdd.clear();
|
||||
for (const [listener, scopes] of event._toRemove) {
|
||||
const left = event._listeners.get(listener);
|
||||
scopes.forEach((scope) => left?.delete(scope));
|
||||
if (left?.size === 0) event._listeners.delete(listener);
|
||||
}
|
||||
event._toRemove.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Report an error the widget's `name` method throws, and rethrow it.
|
||||
*
|
||||
* A render error marks the loop stopped, but a call made while it ran leaves
|
||||
* its next frame queued, and that frame stops it. Keep the loop marked
|
||||
* running, so a Retry or a shown tab before that frame starts no second loop.
|
||||
* After a throw, the loop's own catch still marks it stopped.
|
||||
*/
|
||||
function reportThrown(widget, name, report) {
|
||||
const original = widget?.[name];
|
||||
if (typeof original !== 'function') return () => {};
|
||||
const own = Object.hasOwn(widget, name);
|
||||
const guarded = function (...args) {
|
||||
const looping = widget._renderLoopRunning;
|
||||
try {
|
||||
return original.apply(this, args);
|
||||
} catch (error) {
|
||||
report(error);
|
||||
throw error;
|
||||
} finally {
|
||||
if (looping) widget._renderLoopRunning = true;
|
||||
}
|
||||
};
|
||||
widget[name] = guarded;
|
||||
return () => {
|
||||
if (widget[name] !== guarded) return;
|
||||
if (own) widget[name] = original;
|
||||
else delete widget[name];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import { installRenderFailureNotice } from './renderFailure.js';
|
||||
|
||||
function fixture(t, options = {}) {
|
||||
const canvasListeners = new Map();
|
||||
const scene = {
|
||||
renderError: new Cesium.Event(),
|
||||
preUpdate: new Cesium.Event(),
|
||||
postRender: new Cesium.Event(),
|
||||
requestRender() {
|
||||
this.requests = (this.requests ?? 0) + 1;
|
||||
},
|
||||
};
|
||||
const viewer = {
|
||||
scene,
|
||||
useDefaultRenderLoop: true,
|
||||
canvas: {
|
||||
addEventListener: (name, listener) => canvasListeners.set(name, listener),
|
||||
removeEventListener: (name, listener) => {
|
||||
if (canvasListeners.get(name) === listener)
|
||||
canvasListeners.delete(name);
|
||||
},
|
||||
},
|
||||
};
|
||||
const store = {
|
||||
renderFailure: null,
|
||||
published: [],
|
||||
publishRenderFailure(next) {
|
||||
this.renderFailure = next;
|
||||
this.published.push(next);
|
||||
},
|
||||
};
|
||||
const visits = [];
|
||||
const locationRef = {
|
||||
href: 'https://gev.example/share/AQc?lang=ru#lat=48.8584&lon=2.2945',
|
||||
reload: () => visits.push('reload'),
|
||||
assign: (url) => visits.push(String(url)),
|
||||
};
|
||||
const logged = [];
|
||||
const uninstall = installRenderFailureNotice(viewer, {
|
||||
store,
|
||||
locationRef,
|
||||
logError: (error) => logged.push(error),
|
||||
...options,
|
||||
});
|
||||
t.after(uninstall);
|
||||
// One Cesium frame: preUpdate, an optional render error, then postRender,
|
||||
// which Cesium raises after a failed frame too.
|
||||
const frame = (error) => {
|
||||
scene.preUpdate.raiseEvent(scene);
|
||||
if (error) {
|
||||
viewer.useDefaultRenderLoop = false;
|
||||
scene.renderError.raiseEvent(scene, error);
|
||||
}
|
||||
scene.postRender.raiseEvent(scene);
|
||||
};
|
||||
return {
|
||||
viewer,
|
||||
scene,
|
||||
store,
|
||||
visits,
|
||||
logged,
|
||||
uninstall,
|
||||
frame,
|
||||
loseContext: () => canvasListeners.get('webglcontextlost')?.({}),
|
||||
canvasListeners,
|
||||
};
|
||||
}
|
||||
|
||||
test('a render error shows a notice that survives the failed frame', (t) => {
|
||||
const f = fixture(t);
|
||||
assert.equal(f.store.renderFailure, null);
|
||||
const error = new Error('Expected width to be greater than 0');
|
||||
f.frame(error);
|
||||
const notice = f.store.renderFailure;
|
||||
assert.equal(notice.reason, 'render-error');
|
||||
assert.equal(notice.detail, 'Expected width to be greater than 0');
|
||||
assert.equal(typeof notice.retry, 'function');
|
||||
assert.equal(typeof notice.reset, 'function');
|
||||
assert.deepEqual(f.logged, [error]);
|
||||
});
|
||||
|
||||
test('Retry restarts the render loop and a clean frame clears the notice', (t) => {
|
||||
const f = fixture(t);
|
||||
f.frame(new Error('boom'));
|
||||
f.store.renderFailure.retry();
|
||||
assert.equal(f.viewer.useDefaultRenderLoop, true);
|
||||
assert.equal(f.scene.requests, 1);
|
||||
assert.ok(f.store.renderFailure, 'the notice waits for a frame');
|
||||
f.frame();
|
||||
assert.equal(f.store.renderFailure, null);
|
||||
// Clearing stops the per-frame listeners.
|
||||
assert.equal(f.scene.preUpdate.numberOfListeners, 0);
|
||||
assert.equal(f.scene.postRender.numberOfListeners, 0);
|
||||
});
|
||||
|
||||
test('a loop restarted into the same error keeps one notice', (t) => {
|
||||
const f = fixture(t);
|
||||
f.frame(new Error('boom'));
|
||||
const first = f.store.renderFailure;
|
||||
f.store.renderFailure.retry();
|
||||
f.frame(new Error('boom'));
|
||||
assert.equal(f.store.renderFailure, first);
|
||||
assert.equal(f.store.published.length, 1);
|
||||
f.frame(new Error('other'));
|
||||
assert.equal(f.store.renderFailure.detail, 'other');
|
||||
assert.ok(!f.store.published.includes(null), 'no new appearance');
|
||||
});
|
||||
|
||||
test('a new failure after recovery is a new appearance', (t) => {
|
||||
const f = fixture(t);
|
||||
f.frame(new Error('boom'));
|
||||
f.store.renderFailure.retry();
|
||||
f.frame();
|
||||
f.frame(new Error('boom'));
|
||||
assert.deepEqual(
|
||||
f.store.published.map((notice) => notice?.reason ?? null),
|
||||
['render-error', null, 'render-error'],
|
||||
);
|
||||
});
|
||||
|
||||
test('a render error without a value shows no detail', (t) => {
|
||||
const f = fixture(t);
|
||||
f.viewer.useDefaultRenderLoop = false;
|
||||
f.scene.renderError.raiseEvent(f.scene, undefined);
|
||||
assert.equal(f.store.renderFailure.reason, 'render-error');
|
||||
assert.equal(f.store.renderFailure.detail, '');
|
||||
});
|
||||
|
||||
test('Reset opens the app root without the restored view', (t) => {
|
||||
const f = fixture(t);
|
||||
f.frame(new Error('boom'));
|
||||
f.store.renderFailure.reset();
|
||||
assert.deepEqual(f.visits, ['https://gev.example/?lang=ru']);
|
||||
});
|
||||
|
||||
test('a lost context offers a reload and no frame clears it', (t) => {
|
||||
const f = fixture(t);
|
||||
f.loseContext();
|
||||
const notice = f.store.renderFailure;
|
||||
assert.equal(notice.reason, 'context-lost');
|
||||
assert.equal(notice.detail, '');
|
||||
// Cesium's next frame then fails on the dead drawing buffer.
|
||||
f.frame(new Error('Expected width to be greater than 0'));
|
||||
assert.equal(f.store.renderFailure, notice, 'the notice keeps saying why');
|
||||
f.frame();
|
||||
assert.ok(f.store.renderFailure, 'a lost context never draws again');
|
||||
f.store.renderFailure.retry();
|
||||
assert.deepEqual(f.visits, ['reload']);
|
||||
});
|
||||
|
||||
test('a page that must not reload offers neither reload nor reset', (t) => {
|
||||
const f = fixture(t, { allowReload: false });
|
||||
f.frame(new Error('boom'));
|
||||
assert.equal(typeof f.store.renderFailure.retry, 'function');
|
||||
assert.equal(f.store.renderFailure.reset, null);
|
||||
// Only a reload draws again, which this page must not offer: the notice
|
||||
// goes, and the page's own lost-context notice speaks instead.
|
||||
f.loseContext();
|
||||
assert.equal(f.store.renderFailure, null);
|
||||
f.frame(new Error('Expected width to be greater than 0'));
|
||||
assert.equal(f.store.renderFailure, null);
|
||||
});
|
||||
|
||||
test('uninstall removes the listeners and the notice', (t) => {
|
||||
const f = fixture(t);
|
||||
f.frame(new Error('boom'));
|
||||
f.uninstall();
|
||||
assert.equal(f.store.renderFailure, null);
|
||||
assert.equal(f.scene.renderError.numberOfListeners, 0);
|
||||
assert.equal(f.scene.postRender.numberOfListeners, 0);
|
||||
assert.equal(f.canvasListeners.size, 0);
|
||||
f.frame(new Error('later'));
|
||||
assert.equal(f.store.renderFailure, null);
|
||||
});
|
||||
@@ -0,0 +1,207 @@
|
||||
// Retry after a scene event listener throws. Cesium's Event.raiseEvent has no
|
||||
// try/finally, so the event stays mid-raise and only queues listener changes.
|
||||
// Drives Cesium's real Event and startRenderLoop.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import { installRenderFailureNotice } from './renderFailure.js';
|
||||
import { renderLoopFixture } from './renderLoopFixture.mjs';
|
||||
|
||||
function setup() {
|
||||
// Scene.render as in Scene.js:4369: preUpdate always, preRender/postRender
|
||||
// only when a frame is rendered (requestRenderMode idle skips them).
|
||||
const scene = {
|
||||
renderError: new Cesium.Event(),
|
||||
preUpdate: new Cesium.Event(),
|
||||
preRender: new Cesium.Event(),
|
||||
postRender: new Cesium.Event(),
|
||||
requestRenderMode: true,
|
||||
_renderRequested: false,
|
||||
rendered: 0,
|
||||
requestRender() {
|
||||
this._renderRequested = true;
|
||||
},
|
||||
initializeFrame() {},
|
||||
render(time) {
|
||||
this.preUpdate.raiseEvent(this, time);
|
||||
const shouldRender = !this.requestRenderMode || this._renderRequested;
|
||||
if (!shouldRender) return;
|
||||
this._renderRequested = false;
|
||||
this.preRender.raiseEvent(this, time);
|
||||
this.rendered += 1;
|
||||
this.postRender.raiseEvent(this, time);
|
||||
},
|
||||
};
|
||||
return { scene, ...renderLoopFixture(scene) };
|
||||
}
|
||||
|
||||
for (const eventName of ['postRender', 'preUpdate']) {
|
||||
test(`idle: a ${eventName} listener that threw once; a successful Retry clears the notice`, () => {
|
||||
const { scene, viewer, store, runFrames, restore } = setup();
|
||||
try {
|
||||
let broken = true;
|
||||
scene[eventName].addEventListener(() => {
|
||||
if (broken) throw new TypeError('listener failed');
|
||||
});
|
||||
scene.requestRender();
|
||||
viewer.useDefaultRenderLoop = true;
|
||||
runFrames(1);
|
||||
assert.equal(store.renderFailure?.reason, 'render-error');
|
||||
assert.equal(viewer.useDefaultRenderLoop, false);
|
||||
broken = false; // the cause goes away
|
||||
store.renderFailure.retry();
|
||||
const before = scene.rendered;
|
||||
runFrames(10); // idle: no camera move, no render request
|
||||
assert.ok(scene.rendered > before, 'the globe drew again');
|
||||
assert.equal(store.renderFailure, null, 'the notice is cleared');
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
test('a throwing postRender listener removed before Retry is not called again', () => {
|
||||
const { scene, viewer, store, runFrames, restore } = setup();
|
||||
try {
|
||||
let calls = 0;
|
||||
const remove = scene.postRender.addEventListener(() => {
|
||||
calls += 1;
|
||||
throw new TypeError('layer listener failed');
|
||||
});
|
||||
scene.requestRender();
|
||||
viewer.useDefaultRenderLoop = true;
|
||||
runFrames(1);
|
||||
assert.equal(store.renderFailure?.reason, 'render-error');
|
||||
remove(); // the user turns the layer off
|
||||
store.renderFailure.retry();
|
||||
runFrames(5);
|
||||
assert.equal(calls, 1, 'the removed listener ran again after Retry');
|
||||
assert.equal(viewer.useDefaultRenderLoop, true, 'the loop keeps running');
|
||||
assert.equal(store.renderFailure, null, 'the notice is cleared');
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
});
|
||||
|
||||
const listenerCount = (event) =>
|
||||
[...event._listeners.values()].reduce((sum, scopes) => sum + scopes.size, 0);
|
||||
|
||||
// While the loop is stopped, a layer turned off and on again, or a ground
|
||||
// task in worldAnnotationRenderer that starts, times out and starts again.
|
||||
const RESUBSCRIBE = {
|
||||
'turned off and on': (event, listener) => {
|
||||
event.removeEventListener(listener);
|
||||
event.addEventListener(listener);
|
||||
},
|
||||
'added, removed and added again': (event, listener) => {
|
||||
event.addEventListener(listener);
|
||||
event.removeEventListener(listener);
|
||||
event.addEventListener(listener);
|
||||
},
|
||||
};
|
||||
|
||||
for (const [name, resubscribe] of Object.entries(RESUBSCRIBE)) {
|
||||
test(`a listener ${name} while the loop is stopped runs after Retry`, () => {
|
||||
const { scene, viewer, store, runFrames, restore } = setup();
|
||||
try {
|
||||
let broken = true;
|
||||
scene.postRender.addEventListener(() => {
|
||||
if (broken) throw new TypeError('layer listener failed');
|
||||
});
|
||||
let calls = 0;
|
||||
const listener = () => {
|
||||
calls += 1;
|
||||
};
|
||||
if (name === 'turned off and on')
|
||||
scene.postRender.addEventListener(listener);
|
||||
scene.requestRender();
|
||||
viewer.useDefaultRenderLoop = true;
|
||||
runFrames(1);
|
||||
assert.equal(store.renderFailure?.reason, 'render-error');
|
||||
resubscribe(scene.postRender, listener);
|
||||
broken = false;
|
||||
store.renderFailure.retry();
|
||||
calls = 0;
|
||||
scene.requestRender();
|
||||
runFrames(3);
|
||||
assert.ok(calls > 0, 'the re-added listener runs after Retry');
|
||||
assert.equal(
|
||||
scene.postRender.numberOfListeners,
|
||||
listenerCount(scene.postRender),
|
||||
);
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Every event a listener's error can cut short is finished when the error
|
||||
// surfaces, so a listener added at once is subscribed.
|
||||
const FRAME_EVENTS = {
|
||||
'scene.preUpdate': (v) => v.scene.preUpdate,
|
||||
'scene.postUpdate': (v) => v.scene.postUpdate,
|
||||
'scene.preRender': (v) => v.scene.preRender,
|
||||
'scene.postRender': (v) => v.scene.postRender,
|
||||
'camera.changed': (v) => v.scene.camera.changed,
|
||||
'camera.moveStart': (v) => v.scene.camera.moveStart,
|
||||
'camera.moveEnd': (v) => v.scene.camera.moveEnd,
|
||||
'clock.onTick': (v) => v.clock.onTick,
|
||||
'clock.onStop': (v) => v.clock.onStop,
|
||||
'globe.tileLoadProgressEvent': (v) => v.scene.globe.tileLoadProgressEvent,
|
||||
'tileset.loadProgress': (v) => v.scene.primitives.get(0).loadProgress,
|
||||
'tileset.allTilesLoaded': (v) => v.scene.primitives.get(0).allTilesLoaded,
|
||||
'tileset.initialTilesLoaded': (v) =>
|
||||
v.scene.primitives.get(0).initialTilesLoaded,
|
||||
};
|
||||
|
||||
for (const [name, pick] of Object.entries(FRAME_EVENTS)) {
|
||||
test(`a listener that throws in ${name} leaves it finished`, () => {
|
||||
const events = () => ({
|
||||
changed: new Cesium.Event(),
|
||||
moveStart: new Cesium.Event(),
|
||||
moveEnd: new Cesium.Event(),
|
||||
});
|
||||
const tileset = {
|
||||
loadProgress: new Cesium.Event(),
|
||||
allTilesLoaded: new Cesium.Event(),
|
||||
initialTilesLoaded: new Cesium.Event(),
|
||||
};
|
||||
const viewer = {
|
||||
scene: {
|
||||
renderError: new Cesium.Event(),
|
||||
preUpdate: new Cesium.Event(),
|
||||
postUpdate: new Cesium.Event(),
|
||||
preRender: new Cesium.Event(),
|
||||
postRender: new Cesium.Event(),
|
||||
camera: events(),
|
||||
globe: { tileLoadProgressEvent: new Cesium.Event() },
|
||||
primitives: { length: 1, get: () => tileset },
|
||||
},
|
||||
clock: { onTick: new Cesium.Event(), onStop: new Cesium.Event() },
|
||||
canvas: { addEventListener() {}, removeEventListener() {} },
|
||||
cesiumWidget: {
|
||||
_renderLoopRunning: false,
|
||||
render: () => pick(viewer).raiseEvent(),
|
||||
},
|
||||
};
|
||||
const store = { publishRenderFailure() {} };
|
||||
const uninstall = installRenderFailureNotice(viewer, {
|
||||
store,
|
||||
locationRef: { href: 'https://gev.example/', reload() {}, assign() {} },
|
||||
logError() {},
|
||||
});
|
||||
try {
|
||||
const event = pick(viewer);
|
||||
event.addEventListener(() => {
|
||||
throw new TypeError('listener failed');
|
||||
});
|
||||
assert.throws(() => viewer.cesiumWidget.render(), TypeError);
|
||||
assert.equal(event._invokingListeners, false);
|
||||
const listener = () => {};
|
||||
event.addEventListener(listener);
|
||||
assert.ok(event._listeners.has(listener));
|
||||
} finally {
|
||||
uninstall();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Errors thrown in the render loop outside Scene's tryAndCatchError. Drives
|
||||
// Cesium's real startRenderLoop through the useDefaultRenderLoop setter.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import { renderLoopFixture } from './renderLoopFixture.mjs';
|
||||
|
||||
function runLoop(render) {
|
||||
const scene = {
|
||||
renderError: new Cesium.Event(),
|
||||
preUpdate: new Cesium.Event(),
|
||||
postRender: new Cesium.Event(),
|
||||
requestRender() {},
|
||||
initializeFrame() {},
|
||||
render,
|
||||
};
|
||||
const fixture = renderLoopFixture(scene);
|
||||
fixture.viewer.useDefaultRenderLoop = true;
|
||||
fixture.runFrames(3);
|
||||
return { ...fixture, uninstall: fixture.restore };
|
||||
}
|
||||
|
||||
test('an error thrown outside tryAndCatchError still shows the notice', () => {
|
||||
// Scene.render raises preRender outside tryAndCatchError (Scene.js:4439),
|
||||
// so a listener's exception propagates.
|
||||
const { widget, store, logged, uninstall } = runLoop(function () {
|
||||
this.preUpdate.raiseEvent(this);
|
||||
throw new TypeError("Cannot read properties of undefined (reading 'x')");
|
||||
});
|
||||
assert.equal(widget.useDefaultRenderLoop, false);
|
||||
assert.equal(store.renderFailure?.reason, 'render-error');
|
||||
assert.equal(logged.length, 1);
|
||||
uninstall();
|
||||
});
|
||||
|
||||
test('an error Scene raised and threw on with rethrowRenderErrors is reported once', () => {
|
||||
const { store, logged, uninstall } = runLoop(function () {
|
||||
this.preUpdate.raiseEvent(this);
|
||||
const error = new Error('boom');
|
||||
this.renderError.raiseEvent(this, error);
|
||||
throw error;
|
||||
});
|
||||
assert.equal(store.renderFailure?.detail, 'boom');
|
||||
assert.equal(logged.length, 1);
|
||||
uninstall();
|
||||
});
|
||||
@@ -0,0 +1,95 @@
|
||||
// Retry after an error Scene catches itself: the loop is marked stopped but
|
||||
// its next frame is still queued, so an early Retry must not start a second
|
||||
// loop. Drives Cesium's real startRenderLoop and useDefaultRenderLoop setter.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import { renderLoopFixture } from './renderLoopFixture.mjs';
|
||||
|
||||
function setup({ targetFrameRate } = {}) {
|
||||
const scene = {
|
||||
renderError: new Cesium.Event(),
|
||||
preUpdate: new Cesium.Event(),
|
||||
preRender: new Cesium.Event(),
|
||||
postRender: new Cesium.Event(),
|
||||
broken: false,
|
||||
drawn: 0,
|
||||
requestRender() {},
|
||||
initializeFrame() {},
|
||||
// Scene.render (Scene.js:4369): an update error is caught by
|
||||
// tryAndCatchError, which raises renderError and returns normally.
|
||||
render(time) {
|
||||
this.drawn += 1;
|
||||
this.preUpdate.raiseEvent(this, time);
|
||||
if (this.broken) this.renderError.raiseEvent(this, new Error('boom'));
|
||||
this.preRender.raiseEvent(this, time);
|
||||
this.postRender.raiseEvent(this, time);
|
||||
},
|
||||
};
|
||||
return { scene, ...renderLoopFixture(scene, { targetFrameRate }) };
|
||||
}
|
||||
|
||||
for (const targetFrameRate of [undefined, 60]) {
|
||||
test(`targetFrameRate ${targetFrameRate}: Retry before the next frame after an error Scene caught keeps one render loop`, () => {
|
||||
const { frames, scene, viewer, store, runFrames, restore } = setup({
|
||||
targetFrameRate,
|
||||
});
|
||||
try {
|
||||
viewer.useDefaultRenderLoop = true;
|
||||
runFrames(2);
|
||||
scene.broken = true;
|
||||
runFrames(1);
|
||||
assert.equal(store.renderFailure?.reason, 'render-error');
|
||||
// The cause is gone; Retry runs (a queued Enter on the focused Retry)
|
||||
// before the loop's next animation frame.
|
||||
scene.broken = false;
|
||||
store.renderFailure.retry();
|
||||
assert.equal(frames.length, 1, 'one animation frame queued after Retry');
|
||||
scene.drawn = 0;
|
||||
runFrames(3);
|
||||
assert.equal(store.renderFailure, null);
|
||||
assert.equal(scene.drawn, 3, 'the globe draws once a frame');
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
test('control: Retry after the next frame ran keeps one render loop', () => {
|
||||
const { frames, scene, viewer, store, runFrames, restore } = setup();
|
||||
try {
|
||||
viewer.useDefaultRenderLoop = true;
|
||||
runFrames(2);
|
||||
scene.broken = true;
|
||||
runFrames(1);
|
||||
scene.broken = false;
|
||||
runFrames(1);
|
||||
assert.equal(frames.length, 0, 'the stopped loop queued nothing');
|
||||
store.renderFailure.retry();
|
||||
scene.drawn = 0;
|
||||
runFrames(3);
|
||||
assert.equal(scene.drawn, 3);
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('a tab hidden and shown again before the next frame after an error Scene caught keeps one render loop', () => {
|
||||
const { scene, viewer, runFrames, restore } = setup();
|
||||
try {
|
||||
viewer.useDefaultRenderLoop = true;
|
||||
runFrames(2);
|
||||
scene.broken = true;
|
||||
runFrames(1);
|
||||
scene.broken = false;
|
||||
// src/app/tools.js turns the loop off while the tab is hidden and back on
|
||||
// when it is shown, before the queued frame runs.
|
||||
viewer.useDefaultRenderLoop = false;
|
||||
viewer.useDefaultRenderLoop = true;
|
||||
scene.drawn = 0;
|
||||
runFrames(3);
|
||||
assert.equal(scene.drawn, 3, 'the globe draws once a frame');
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,173 @@
|
||||
// The scene chrome renders the render failure notice and its actions.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import { createPinia } from 'pinia';
|
||||
import { useStatusStore } from './stores/status.js';
|
||||
import SceneChromeView from './views/SceneChromeView.vue';
|
||||
|
||||
function mount(t) {
|
||||
document.body.replaceChildren();
|
||||
const pinia = createPinia();
|
||||
const app = createApp(SceneChromeView).use(pinia);
|
||||
app.mount(document.body.appendChild(document.createElement('div')));
|
||||
t.after(() => app.unmount());
|
||||
return useStatusStore(pinia);
|
||||
}
|
||||
|
||||
const notice = () => document.getElementById('render-failure');
|
||||
const buttons = () =>
|
||||
[...(notice()?.querySelectorAll('button') ?? [])].map((button) =>
|
||||
button.textContent.trim(),
|
||||
);
|
||||
|
||||
test('a render failure shows an alert dialog that moves focus to Retry', async (t) => {
|
||||
const store = mount(t);
|
||||
assert.equal(notice(), null, 'no notice while the globe draws');
|
||||
const calls = [];
|
||||
store.publishRenderFailure({
|
||||
reason: 'render-error',
|
||||
detail: 'Expected width to be greater than 0',
|
||||
retry: () => calls.push('retry'),
|
||||
reset: () => calls.push('reset'),
|
||||
});
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
const element = notice();
|
||||
assert.equal(element.getAttribute('role'), 'alertdialog');
|
||||
assert.equal(
|
||||
document.getElementById(element.getAttribute('aria-labelledby'))
|
||||
.textContent,
|
||||
'The globe stopped drawing',
|
||||
);
|
||||
assert.match(
|
||||
document.getElementById(element.getAttribute('aria-describedby'))
|
||||
.textContent,
|
||||
/^Rendering stopped after an error\./,
|
||||
);
|
||||
assert.equal(
|
||||
element.querySelector('.render-failure-detail').textContent,
|
||||
'Expected width to be greater than 0',
|
||||
);
|
||||
assert.deepEqual(buttons(), ['Retry', 'Reset view']);
|
||||
assert.equal(document.activeElement?.textContent.trim(), 'Retry');
|
||||
for (const button of element.querySelectorAll('button')) button.click();
|
||||
assert.deepEqual(calls, ['retry', 'reset']);
|
||||
store.publishRenderFailure(null);
|
||||
await nextTick();
|
||||
assert.equal(notice(), null);
|
||||
});
|
||||
|
||||
test('a lost context offers Reload, and a panel that cannot reload offers nothing', async (t) => {
|
||||
const store = mount(t);
|
||||
store.publishRenderFailure({
|
||||
reason: 'context-lost',
|
||||
detail: '',
|
||||
retry: () => {},
|
||||
reset: () => {},
|
||||
});
|
||||
await nextTick();
|
||||
assert.match(
|
||||
document.getElementById('render-failure-message').textContent,
|
||||
/3D graphics/,
|
||||
);
|
||||
assert.equal(notice().querySelector('.render-failure-detail'), null);
|
||||
assert.deepEqual(buttons(), ['Reload', 'Reset view']);
|
||||
store.publishRenderFailure({
|
||||
reason: 'context-lost',
|
||||
detail: '',
|
||||
retry: null,
|
||||
reset: null,
|
||||
});
|
||||
await nextTick();
|
||||
assert.deepEqual(buttons(), []);
|
||||
assert.equal(notice().querySelector('.render-failure-hint'), null);
|
||||
});
|
||||
|
||||
const failure = () => ({
|
||||
reason: 'render-error',
|
||||
detail: '',
|
||||
retry: () => {},
|
||||
reset: null,
|
||||
});
|
||||
const settle = async () => {
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
};
|
||||
|
||||
test('focus goes back where it was when the globe draws again', async (t) => {
|
||||
const store = mount(t);
|
||||
const search = document.body.appendChild(document.createElement('input'));
|
||||
search.focus();
|
||||
store.publishRenderFailure(failure());
|
||||
await settle();
|
||||
assert.equal(document.activeElement?.textContent.trim(), 'Retry');
|
||||
store.publishRenderFailure(null);
|
||||
await settle();
|
||||
assert.equal(document.activeElement, search);
|
||||
});
|
||||
|
||||
// The globe's canvas, as CesiumWidget builds it inside the container.
|
||||
const addGlobeCanvas = () => {
|
||||
const widget = document.createElement('div');
|
||||
widget.className = 'cesium-widget';
|
||||
document.getElementById('cesiumContainer').appendChild(widget);
|
||||
return widget.appendChild(document.createElement('canvas'));
|
||||
};
|
||||
|
||||
test('focus goes to the globe canvas when the element it came from is gone', async (t) => {
|
||||
const store = mount(t);
|
||||
const canvas = addGlobeCanvas();
|
||||
const search = document.body.appendChild(document.createElement('input'));
|
||||
search.focus();
|
||||
store.publishRenderFailure(failure());
|
||||
await settle();
|
||||
search.remove();
|
||||
store.publishRenderFailure(null);
|
||||
await settle();
|
||||
// The map's keys, Enter to finish a drawing among them, read the canvas
|
||||
// as the map (src/annotations/drawTool.js).
|
||||
assert.equal(document.activeElement, canvas);
|
||||
assert.equal(canvas.getAttribute('tabindex'), '-1');
|
||||
canvas.blur();
|
||||
assert.equal(canvas.hasAttribute('tabindex'), false, 'only this once');
|
||||
});
|
||||
|
||||
test('focus goes to the globe canvas when the element it came from cannot take it', async (t) => {
|
||||
const store = mount(t);
|
||||
const canvas = addGlobeCanvas();
|
||||
const button = document.body.appendChild(document.createElement('button'));
|
||||
button.focus();
|
||||
store.publishRenderFailure(failure());
|
||||
await settle();
|
||||
button.disabled = true;
|
||||
store.publishRenderFailure(null);
|
||||
await settle();
|
||||
assert.equal(document.activeElement, canvas);
|
||||
// A press on the globe leaves focus on the page again, as Cesium has it.
|
||||
canvas.dispatchEvent(new Event('pointerdown'));
|
||||
assert.equal(document.activeElement, document.body);
|
||||
assert.equal(canvas.hasAttribute('tabindex'), false);
|
||||
});
|
||||
|
||||
test('focus the user moved while the notice was up stays put', async (t) => {
|
||||
const store = mount(t);
|
||||
store.publishRenderFailure(failure());
|
||||
await settle();
|
||||
const chat = document.body.appendChild(document.createElement('textarea'));
|
||||
chat.focus();
|
||||
store.publishRenderFailure(null);
|
||||
await settle();
|
||||
assert.equal(document.activeElement, chat);
|
||||
});
|
||||
|
||||
test('the globe drawing from the start leaves focus alone', async (t) => {
|
||||
mount(t);
|
||||
await settle();
|
||||
assert.equal(document.activeElement, document.body);
|
||||
assert.equal(
|
||||
document.getElementById('cesiumContainer').hasAttribute('tabindex'),
|
||||
false,
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
// A widget on Cesium's real CesiumWidget.prototype (startRenderLoop, the
|
||||
// useDefaultRenderLoop setter, render) around a scene double, with animation
|
||||
// frames queued by hand and the render failure notice installed.
|
||||
import * as Cesium from 'cesium';
|
||||
import { installRenderFailureNotice } from './renderFailure.js';
|
||||
|
||||
export function renderLoopFixture(
|
||||
scene,
|
||||
{ targetFrameRate, viewer: viewerExtras = {}, notice = {} } = {},
|
||||
) {
|
||||
const frames = [];
|
||||
const previousRaf = globalThis.requestAnimationFrame;
|
||||
globalThis.requestAnimationFrame = (fn) => frames.push(fn);
|
||||
const widget = Object.create(Cesium.CesiumWidget.prototype);
|
||||
Object.assign(widget, {
|
||||
_scene: scene,
|
||||
_clock: { tick() {} },
|
||||
_canRender: true,
|
||||
_useDefaultRenderLoop: false,
|
||||
_renderLoopRunning: false,
|
||||
// What src/app/scene.js passes to the viewer.
|
||||
_showRenderLoopErrors: false,
|
||||
_targetFrameRate: targetFrameRate,
|
||||
isDestroyed: () => false,
|
||||
resize() {},
|
||||
});
|
||||
// CesiumWidget's own renderError handler, which marks the loop stopped.
|
||||
scene.renderError.addEventListener(() => {
|
||||
widget._useDefaultRenderLoop = false;
|
||||
widget._renderLoopRunning = false;
|
||||
});
|
||||
const viewer = Object.assign(
|
||||
{
|
||||
scene,
|
||||
cesiumWidget: widget,
|
||||
canvas: { addEventListener() {}, removeEventListener() {} },
|
||||
get useDefaultRenderLoop() {
|
||||
return widget.useDefaultRenderLoop;
|
||||
},
|
||||
set useDefaultRenderLoop(value) {
|
||||
widget.useDefaultRenderLoop = value;
|
||||
},
|
||||
},
|
||||
viewerExtras,
|
||||
);
|
||||
const store = {
|
||||
renderFailure: null,
|
||||
publishRenderFailure(next) {
|
||||
this.renderFailure = next;
|
||||
},
|
||||
};
|
||||
const logged = [];
|
||||
const uninstall = installRenderFailureNotice(viewer, {
|
||||
store,
|
||||
locationRef: { href: 'https://gev.example/', reload() {}, assign() {} },
|
||||
logError: (error) => logged.push(error),
|
||||
...notice,
|
||||
});
|
||||
let time = 0;
|
||||
const runFrames = (n) => {
|
||||
for (let i = 0; i < n; i += 1) {
|
||||
// Above a 60 fps target's interval, so every frame draws.
|
||||
time += 17;
|
||||
for (const fn of frames.splice(0)) fn(time);
|
||||
}
|
||||
};
|
||||
const restore = () => {
|
||||
uninstall();
|
||||
globalThis.requestAnimationFrame = previousRaf;
|
||||
};
|
||||
return { frames, widget, viewer, store, logged, runFrames, restore };
|
||||
}
|
||||
+17
-1
@@ -7,7 +7,9 @@ import { markRaw, shallowRef } from 'vue';
|
||||
* road network chip, CctvControls the camera grid chip; the toast shows
|
||||
* what any owner's createToast() (src/ui/toast.js) publishes, and the title
|
||||
* bar the FPS readout createFrameRateMonitor() publishes. Each label keeps its
|
||||
* last text while hidden, so the next change flaps from what was shown.
|
||||
* last text while hidden, so the next change flaps from what was shown. The
|
||||
* render failure notice is what installRenderFailureNotice()
|
||||
* (src/ui/renderFailure.js) publishes while the globe cannot draw.
|
||||
*/
|
||||
export const useStatusStore = defineStore('gev-status', () => {
|
||||
/**
|
||||
@@ -32,6 +34,13 @@ export const useStatusStore = defineStore('gev-status', () => {
|
||||
*/
|
||||
const fps = shallowRef(null);
|
||||
|
||||
/**
|
||||
* The globe's render failure, `{reason, detail, retry, reset}`; null while
|
||||
* the globe draws. `reason` is 'render-error' or 'context-lost', and `retry`
|
||||
* and `reset` are null where that action is not offered.
|
||||
*/
|
||||
const renderFailure = shallowRef(null);
|
||||
|
||||
/** @param {?object} next A fresh presentation of the loading status. */
|
||||
function publishLoading(next) {
|
||||
loading.value = next && markRaw(next);
|
||||
@@ -57,6 +66,11 @@ export const useStatusStore = defineStore('gev-status', () => {
|
||||
fps.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
/** @param {?object} next A fresh presentation of the render failure. */
|
||||
function publishRenderFailure(next) {
|
||||
renderFailure.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
return {
|
||||
fps,
|
||||
publishFps,
|
||||
@@ -68,5 +82,7 @@ export const useStatusStore = defineStore('gev-status', () => {
|
||||
publishTraffic,
|
||||
cctv,
|
||||
publishCctv,
|
||||
renderFailure,
|
||||
publishRenderFailure,
|
||||
};
|
||||
});
|
||||
@@ -405,6 +405,76 @@ html:not([lang='en']) #global-loading-detail {
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Render failure notice ───────────────────── */
|
||||
/* Above the loading screen, so a globe that fails while it loads says so too,
|
||||
and above floating panels such as the Québec camera viewer (2000). */
|
||||
#render-failure {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 2001;
|
||||
box-sizing: border-box;
|
||||
width: min(420px, calc(100vw - 32px));
|
||||
max-height: calc(100vh - 32px);
|
||||
overflow-y: auto;
|
||||
padding: 20px 22px;
|
||||
background: var(--glass-bg);
|
||||
border: 1px solid #ff7272;
|
||||
border-radius: 12px;
|
||||
backdrop-filter: blur(16px);
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
box-shadow: 0 0 24px rgba(255, 88, 88, 0.18);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-sans);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
#render-failure-title {
|
||||
margin: 0 0 8px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 2px;
|
||||
text-transform: uppercase;
|
||||
color: #ff7272;
|
||||
}
|
||||
|
||||
#render-failure p {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
#render-failure .render-failure-detail {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
color: var(--text-secondary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#render-failure .render-failure-hint {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
#render-failure .render-failure-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
#render-failure .gev-action-button {
|
||||
font-size: 11px;
|
||||
padding: 8px 14px;
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
#render-failure .gev-action-button {
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Toast Notification ──────────────────────── */
|
||||
#toast {
|
||||
position: fixed;
|
||||
|
||||
@@ -18,6 +18,7 @@ import ScreenAnnotations from './panels/ScreenAnnotations.vue';
|
||||
import AwarenessDirection from './panels/AwarenessDirection.vue';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import GlobeActions from './panels/GlobeActions.vue';
|
||||
import RenderFailure from './panels/RenderFailure.vue';
|
||||
import WorldTimeline from './panels/WorldTimeline.vue';
|
||||
|
||||
// The ACTIVE STYLE corner shows the style VisualSettings publishes.
|
||||
@@ -61,6 +62,7 @@ const vToastText = {
|
||||
|
||||
<template>
|
||||
<div id="cesiumContainer"></div>
|
||||
<RenderFailure />
|
||||
<div id="world-overlay-root" aria-hidden="true">
|
||||
<canvas id="world-overlay-canvas"></canvas>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<script setup>
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { msg, t } from '../../../i18n/index.js';
|
||||
import { useStatusStore } from '../../stores/status.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
|
||||
// Published by installRenderFailureNotice() (src/ui/renderFailure.js).
|
||||
const { renderFailure: failure } = storeToRefs(useStatusStore());
|
||||
const panel = ref(null);
|
||||
const MESSAGES = {
|
||||
'context-lost': msg(
|
||||
"The browser took back the globe's 3D graphics. Layers and controls still work, but the map cannot draw until the page reloads.",
|
||||
),
|
||||
'render-error': msg(
|
||||
'Rendering stopped after an error. Layers and controls still work, but the map is not updating.',
|
||||
),
|
||||
};
|
||||
// Focus goes to the first action when the notice appears. When the globe
|
||||
// draws again, it goes back, or to the map, unless the user moved it.
|
||||
let focusBefore;
|
||||
watch(
|
||||
() => Boolean(failure.value),
|
||||
async (shown) => {
|
||||
if (shown) {
|
||||
focusBefore = document.activeElement;
|
||||
await nextTick();
|
||||
panel.value?.querySelector('button')?.focus();
|
||||
return;
|
||||
}
|
||||
if (focusBefore === undefined) return;
|
||||
const previous = focusBefore;
|
||||
focusBefore = undefined;
|
||||
await nextTick();
|
||||
const active = document.activeElement;
|
||||
if (active && active !== document.body) return;
|
||||
if (previous?.isConnected && previous !== document.body) {
|
||||
previous.focus({ preventScroll: true });
|
||||
// A control disabled, hidden or made inert meanwhile does not take it.
|
||||
if (document.activeElement === previous) return;
|
||||
}
|
||||
focusMap();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
// The map's keys (Enter to finish a drawing, Space to talk) read the canvas
|
||||
// as the map. It stays focusable only until focus leaves or the globe is
|
||||
// pressed; a press leaves focus on the page, as in Cesium.
|
||||
function focusMap() {
|
||||
const canvas = document.querySelector(
|
||||
'#cesiumContainer .cesium-widget canvas',
|
||||
);
|
||||
if (!canvas) return;
|
||||
if (!canvas.hasAttribute('tabindex')) {
|
||||
canvas.tabIndex = -1;
|
||||
const done = new AbortController();
|
||||
const release = () => {
|
||||
done.abort();
|
||||
canvas.removeAttribute('tabindex');
|
||||
};
|
||||
canvas.addEventListener('blur', release, { signal: done.signal });
|
||||
canvas.addEventListener(
|
||||
'pointerdown',
|
||||
() => {
|
||||
release();
|
||||
canvas.blur();
|
||||
},
|
||||
{ capture: true, signal: done.signal },
|
||||
);
|
||||
}
|
||||
canvas.focus({ preventScroll: true });
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="failure" id="render-failure" ref="panel" role="alertdialog" aria-labelledby="render-failure-title" aria-describedby="render-failure-message">
|
||||
<h2 id="render-failure-title">{{ t('The globe stopped drawing') }}</h2>
|
||||
<p id="render-failure-message">{{ t(MESSAGES[failure.reason] ?? MESSAGES['render-error']) }}</p>
|
||||
<p v-if="failure.detail" class="render-failure-detail" translate="no">{{ failure.detail }}</p>
|
||||
<p v-if="failure.reset" class="render-failure-hint">{{ t('Reset view reloads the app without the view restored from the address bar.') }}</p>
|
||||
<div v-if="failure.retry || failure.reset" class="render-failure-actions">
|
||||
<UiButton v-if="failure.retry" class="gev-action-button render-failure-retry" :onClick="failure.retry">{{ failure.reason === 'context-lost' ? t('Reload') : t('Retry') }}</UiButton>
|
||||
<UiButton v-if="failure.reset" class="gev-action-button render-failure-reset" :onClick="failure.reset">{{ t('Reset view') }}</UiButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user