Skip to content

web: LoadMode.disk streams the compressed data instead of decoding it whole - #635

Merged
alnitak merged 3 commits into
mainfrom
web-disk-wavstream
Dec 4, 2026
Merged

alnitak merged 3 commits into
mainfrom
web-disk-wavstream

Conversation

@alnitak

@alnitak alnitak commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Description

Supersedes #633 by @18thletter, whose commit is the first one here. The branch of #633 is in a fork owned by an organization, which maintainers cannot push to, so the additions are in this PR.

The change of #633

  • On the web LoadMode.disk was ignored: every load was decoded whole into a preserved buffer stream, like LoadMode.memory. A 90 s stereo Ogg of 1 MB took about 30 MB of the WASM heap.
  • A disk-mode load on the web now goes to the WASM loadMem, and the sound keeps its compressed bytes in a WavStream that each voice decodes while it plays, as on the other platforms.

Added on top

  • M4A/MP4, AAC and AC-3 loaded with LoadMode.disk keep the web loader (the browser's decoder). The engine has no decoder for them on the web, so with the change alone they failed to load, also through playSource, which uses disk by default.
  • The web binaries are rebuilt, in their own commit.
  • The __WEB__ macro in player.cpp is removed: nothing uses it any more.
  • Changelog (under "Behaviour changes"), dartdoc of loadMem and LoadMode.disk, and the loading and idioms skills.

Behaviour change

A sound loaded with LoadMode.disk on the web takes far less memory and loads faster. Each of its voices decodes in the audio callback, which is the main thread unless the page is cross-origin isolated. Seeking an MP3 lags and the sound cannot repeat with repeatEvery, as on the other platforms. LoadMode.memory behaves as before.

Added new tests.

Type of Change

  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • 📝 Documentation

18thletter and others added 3 commits December 4, 2026 19:16
On the web, loadMem and loadAsset ignored LoadMode.disk: every load went
through _loadMemWeb's preserved buffer stream, which keeps every decoded
sample, and Player::loadMem forced a Wav under __WEB__. A 90 s stereo
Ogg (1 MB) became about 30 MB of samples in the wasm heap.

Now a disk-mode load on the web goes to the wasm loadMem, and the player
keeps the compressed bytes in a WavStream that decodes as it plays, as on
the other platforms. Memory-mode loads are unchanged. The web binaries
need a rebuild for the change to take effect.
- m4a/mp4, aac and ac-3 loaded with LoadMode.disk on the web go through the web loader as before: the engine has no decoder for them there
- remove the __WEB__ macro, no longer used
- tests for the disk streams on the web; repeatEvery refuses them there too
- changelog, dartdoc and skills for LoadMode.disk on the web
@alnitak
alnitak merged commit a03755c into main Dec 4, 2026
1 check passed
@alnitak
alnitak deleted the web-disk-wavstream branch December 4, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants