Repository navigation
Make the clouds' map and noise in a web worker - #323
Merged
Merged
Conversation
The cloud map (about 60 ms for the 1024 x 768 radar map) and the noise volumes (about a third of a second) were made on the page's thread, so the weather demo stalled at each hour change and when the clouds were first turned on. They are now made in a module worker, one call at a time, their pixels transferred back. The clouds keep the previous map until the new one is made, and a call for a map no longer wanted is aborted, whichever of the map and the next map is set first; a map or noise that fails is made again later. The clouds are drawn, and leave the rain under them to Precipitation, once the noise is made. Without workers, or if the worker fails to start, the same work runs on the page's thread, with a warning. cloud-map.js and cloud-noise.js import nothing: the demos' Cesium is a page global, which a worker does not see. closes TASK-15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The clouds' map (about 60 ms per radar map) and their noise volumes (about a third of a second) were made on the page's thread, so the weather demo stalled at each hour change and when the clouds were first turned on. They are now made in a module worker.
cloud-work.js: one worker, started at the first call, one call at a time, the pixels transferred back; a call aborted while it waits is dropped. WithoutWorker(Node, the tests) or if the worker fails to start, the call runs on the page's thread, with a console warning.clouds.js: settingmapornextMapreturns at once; the clouds keep the previous map until the new one is made, and drop a map no longer wanted, whichever of the two is set first. The clouds are drawn, and leave the rain under them toPrecipitation, once the noise is made.cloud-map.jsandcloud-noise.jsimport nothing: the demos' Cesium is a page global, which a worker does not see (added to AGENTS.md's known cases).optimizeDeps, or Vite's pre-bundling leaves the worker out (not verified in an app outside this repository).Tested:
npm test(the worker path with a fakeWorker, the fallback, abort, retry after a failure), typecheck, build,build-demos(the worker bundled, 4.3 kB). In the weather demo, measured with long-animation-frame entries: the clouds' scripts take at most 12 ms of a frame while playing 21 hour changes (nextMap2 to 5 ms, reading the canvas's pixels), 5 to 9 ms when they are turned on; the clouds render as before. Not measured:WeatherMap's own scans of each map, still on the page's thread.