fix(utils-sound): load audio via a ranged fetch into a Blob for WebAudio; list mp3 first - #40
Open
ThisIsSheikhRidwan wants to merge 1 commit into
Open
fix(utils-sound): load audio via a ranged fetch into a Blob for WebAudio; list mp3 first#40ThisIsSheikhRidwan wants to merge 1 commit into
ThisIsSheikhRidwan wants to merge 1 commit into
Conversation
…nd list mp3 first
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.
Problem
On some setups the game produces no sound even though every asset request succeeds. Two independent causes:
204 No Content. Howler's default (WebAudio) path fetches the sprite over XHR; when that response comes back empty, decoding fails withDecoding audio data failed.and theHowlstays inloadingforever. (Reproduced in two independent Chromium instances against the Storybook dev server; aRangerequest for the same URL returns the full body as206.)sounds.jsonlistssounds.oggfirst, and on the affected Chromium the media path rejects it withMEDIA_ERR_SRC_NOT_SUPPORTED.Browsers also treat the failed fetch as a download in some configurations, prompting a "save file" dialog for the audio.
Change
packages/utils-sound/src/createSound.svelte.ts:Range: bytes=0-request (which returns the whole file as206), build aBlob, and hand Howler the object URL.formatoption. Without it Howler rejects ablob:URL withNo codec support for selected audio sources.because it derives the codec from the URL extension.html5: false), which supports real audio sprites and overlapping one-shots (music + rapid SFX).apps/{lines,cluster,scatter,ways,price}/static/assets/audio/sounds.json: listsounds.mp3beforesounds.oggso a supported codec is picked first.Verification
Against the
linessample in Storybook, on the affected machine:Howlstate:loaded(previously stuck atloading)howl._webAudio === true,howl._srcis ablob:URL,howl._format === ['mp3']AudioContext.state === 'running',Howler._muted === falseafter the first user gesturebgm_mainandsfx_btn_spinplay simultaneously (playing() === truefor both)decodeAudioDataon the fetched buffer returns a 406s buffer, confirming the file itself is validNotes
load()still returns{ destroy }; player creation is simply deferred until the blob is ready.utils-soundplus the per-gamesounds.jsonfiles.