feat(droid): add downscale/upscale API for worker management#8105
Merged
feat(droid): add downscale/upscale API for worker management#8105
Conversation
Adds window.kbve.downscale() and window.kbve.upscale() to control droid worker thread usage at runtime. Downscale terminates canvas worker, mod workers, gateway pool, and overlay — keeping only DB + WS SharedWorkers for session persistence. Upscale restores full capacity. Designed for pages that need pthread/WASM thread headroom (e.g. isometric game).
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
13 new Playwright tests covering: initial full mode, downscale to minimal, overlay/canvas teardown, DB+WS persistence, event emission, idempotency, upscale restoration, and full cycle error-free operation.
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.
Summary
window.kbve.downscale()— terminates canvas worker, mod workers, gateway worker pool, and overlay manager while keeping DB + WS SharedWorkers alive for session persistencewindow.kbve.upscale()— re-initializes all terminated workers back to full capacitywindow.kbve.scaleLevel()— returns current scale level ('full'or'minimal')droid-downscaleanddroid-upscaleevents on the droid event busdownscale,upscale,getScaleLevel, andDroidScaleLeveltype from@kbve/droidUse case: The isometric game page needs pthread/WASM thread headroom. Before loading the game WASM, it can call
await window.kbve.downscale()to free up worker threads, thenawait window.kbve.upscale()when navigating away.Test plan
nx build droidpasseswindow.kbve.downscale()in console, verify canvas/overlay stop, DB+WS still workwindow.kbve.upscale()to restore full functionality