wasm: ship the user library with the build#2145
Open
jcelerier wants to merge 1 commit into
Open
Conversation
The library cannot be fetched at runtime in the browser: score downloads it from github's codeload, which sends no CORS headers, so PluginSettingsModel::firstTimeLibraryDownload() can only ever fail there. That left wasm builds with no shaders, presets or device templates at all. Preload it into the MEMFS image instead, at the path Library::Settings::Model computes for the default package, so the existing scanning path finds it with no runtime change. CI clones score-user-library at depth 1 and drops the .git directory, which is a third of the checkout. This is roughly 76MB of mostly text, and it is a deliberate trade: the first visit downloads it, --use-preload-cache then keeps the package in IndexedDB so later visits do not. Opt-in through SCORE_WASM_PRELOAD_LIBRARY, so a build that does not set it is unchanged. Also stop the deploy script from testing for the .data file with an `&&` one-liner: under `set -e` the whole statement fails when the file is absent, which would abort the deploy rather than skip the move. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019oPj1zRcxSQX7FNni7EHM6
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.
wasm builds shipped with no library at all — no shaders, no presets, no device templates.
The runtime download cannot work in a browser:
PluginSettingsModel::firstTimeLibraryDownload()fetchesgithub.com/ossia/score-user-library/archive/master.zip, and codeload sends no CORS headers. So there is nowhere to get the library from at runtime.This bakes it into the MEMFS image at link time instead, mounted at the path
Library::Settings::Modelalready computes for the default package — so the existing scanning code finds a populated directory with no runtime change.Cost
.git, which is a third of the checkout)ossia-score.dataossia-score.js--use-preload-cachekeeps the package in IndexedDB, so only the first visit pays for the download. The.jsgrowth is a per-load cost that the cache does not remove.It compresses about 2×, not more, because roughly a third is already-compressed or binary:
Presets/Faust/SAM/SHARCis 17.1 MB on its own, PNG+JPG another 11.3 MB. Trimming SHARC andbela/ReadMe.pdfalone would save ~19 MB with no shader loss, if the size ever becomes a problem.Opt-in via
SCORE_WASM_PRELOAD_LIBRARY, so a build that does not set it is unchanged.Also
ci/wasm.deploy.shtested for the.datafile with[ -f … ] && mv …. Underset -ethat aborts the whole deploy when the file is absent, rather than skipping the move. Now anif.Verification
Automated, in headless Chrome against the built artifact:
FS.readdirat/home/web_user/Documents/ossia/score/packages/defaultreturns all 5816 files, with the expected top-level entries.defaultand expands toCues / Devices / Media / Presets / Scripts / Skins / Util / LICENSE / package.json / README.md— i.e. score's own scanner walks it, not just files present in the filesystem.QWebSocketServer: WebSocket servers are not supported by Qt for WebAssembly.The mount path was confirmed against the SDK rather than assumed: emscripten sets
HOME=/home/web_user, andlibQt6Core.acarries/home/web_userand/Documentsas literals, soQStandardPaths::DocumentsLocationresolves as expected.