Repository navigation
Play page: the engine thinks in a worker, so the page never freezes - #15
Merged
Merged
Conversation
The engine ran on the page's thread: a tenth of its moves take over 60 ms, the slowest several hundred, and the page froze for each. It now runs in a worker, inlined into the play script (so the offline file keeps working), with calls sent in batches, one round trip per move. The 220 ms aiming pause now overlaps the engine's thinking instead of preceding it, and the heat map comes with the move that changes it instead of being recomputed on every render. Where no worker can start, the engine runs on the page as before.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 engine ran on the page's own thread. Most moves take under a millisecond, but a tenth take over 60 ms and the slowest several hundred (more on a phone). The page froze for each one: no hover, no clicks, no animation.
What changes
site/src/components/game/engine.ts,engine.worker.ts). The page compiles the engine and hands the module to the worker. Calls go in batches, one round trip per move. The worker is inlined into the play script as a blob, so the offlinebroadside.htmlstill works from disk.max(220 ms, thinking)instead of220 ms + thinking.render(), which includes every hover.Measured (headless Chromium, 8 full games each, built site)
Also played through in a browser:
Checks
cargo clippy --all-targets: clean.cargo test: 61 passed.npm run check: 0 errors, 0 warnings.npm run build: builds, includingdist/broadside.html.