Skip to content

Fix: Name and log file in decode errors - #336

Merged
zbdd merged 1 commit into
zbdd/wait-on-audio-clock-in-tests-v5from
zbdd/decode-error-url-v5
Nov 21, 2026
Merged

zbdd merged 1 commit into
zbdd/wait-on-audio-clock-in-tests-v5from
zbdd/decode-error-url-v5

Conversation

@zbdd

@zbdd zbdd commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

A WebAudio sound that fails to decode now says which file it was, and the error is logged to the console when there is no loaded callback to receive it. Before, the error was dropped without a callback, and with one it only carried the browser's text. Backport of #330.

Changes

  • The error message is now Failed to decode sound from <url>: <browser message>, and the browser's own error is in cause.
  • With no loaded callback, the error is logged once with console.error.
  • A data URL is shortened to its header (data:audio/mpeg;base64,…), and a sound made from an ArrayBuffer with no URL gets Failed to decode sound: <browser message>.
  • WebAudioContext.decode passes on the browser's error, so its name (for example EncodingError) is kept.
  • The loaded option's docs describe the error.
  • Tests cover the message, the cause and the logging, adapted to PixiJS 7.

Backport of #330.

(cherry picked from commit b37d514)

- Cause: A WebAudio decode error arrives through the decode callback, after the try/catch that logs fetch errors has finished. With no loaded callback it was dropped, and with one the message was only the browser's text, with no file name. WebAudioContext.decode also copied the browser's error into a plain Error, losing its name.
- Fix: WebAudioMedia wraps a decode error as "Failed to decode sound from <url>: <browser message>" with the browser's error in cause, and logs it with console.error when there is no callback. The URL is left out for an ArrayBuffer source, and a data URL is cut to its header. WebAudioContext.decode passes the browser's error through, and still falls back to "Unable to decode file" when there is no error or no message. HTML audio is unchanged: it already logs, and its message has no URL.
- Tests: decode-error.test.ts covers logging once without a callback and not logging with a callback, a rejected play() or a rejected Assets.load, on both backends. The WebAudio cases check the message for a file URL, a data URL, an ArrayBuffer source, a source given with a URL and Assets, the cause and its name, and the fallback message. The tests are adapted to PixiJS 7: Assets from @pixi/assets with an array alias, and the fetch mock on settings.ADAPTER.
@zbdd
zbdd added this pull request to stack #339 November 21, 2026 12:28
@zbdd
zbdd merged commit acd45fd into v5.x Nov 21, 2026
2 checks passed
@zbdd
zbdd deleted the zbdd/decode-error-url-v5 branch November 21, 2026 12:32
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.

1 participant