Skip to content

Sound loading performance issues #1257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
st3v0 opened this issue Nov 25, 2019 · 0 comments
Open

Sound loading performance issues #1257

st3v0 opened this issue Nov 25, 2019 · 0 comments

Comments

@st3v0
Copy link

st3v0 commented Nov 25, 2019

We ran into a performance issue with howler. It was grinding the UI Thread to a halt. It was caused by the fact that you only allow sounds to be loaded via dataURI or XHR. We preload all our assets in a worker thread after which we have access to the DataURI and ArrayBuffer. The problem came when we passed in the dataURI there's a loop which converts it to Uint8Array in the loadBuffer method, it then passes the buffer into decodeAudioData. We found the loop was killing us and was unnecessary since we already had access to the ArrayBuffer data with no way to inject it into Howler.

Our Solution was to hack Howler and modify the loadBuffer method to include the following:

if (self._buffer) {
    decodeAudioData(self._buffer, self);
} else if (/^data:[^;]+;base64,/.test(url)) {
...etc
}

Then all we had to do was set the src, format and buffer props and then call load().

this.howl._src[0] = asset.dataURI;
this.howl._format = [asset.format];
this.howl._buffer = asset.arrayBuffer;
this.howl.load();

We don't want to maintain this hack and would greatly appreciate it if howler could be changed slightly to allow the src to be set to a third type of data, an ArrayBuffer. This way anyone can choose to preload sound however the wish and then inject it into howler.

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

No branches or pull requests

1 participant