Three.js: AudioLoader and LoadingManager onLoad Race

Created on 2 Feb 2017  路  3Comments  路  Source: mrdoob/three.js

Description of the problem

AudioLoader calls scope.manager.itemEnd (through the file loader) after loading the buffer, but its own onLoad after decoding it. Since decoding the buffer is asynchronous (or at least, has a callback) you can get into a race condition if the audio loader is the last loader in the loading manager's queue, where the manager thinks all of it's items are finished but the individual loaders haven't finished parsing. We noticed this in our preloading situation and had to implement our own loading queue that used the per-item onLoad to tick off complete items.

Unfortunately, looking at FileLoader/AudioLoader source, I'm not sure how to fix this or if it's even a concern; maybe the easiest solution to just clarify in the docs that LoadingManager#onLoad only indicates the network request is finished, and doesn't indicate that the data has been parsed.

Three.js version
  • [x] r84
Browser
  • [x] All of them
OS
  • [x] All of them
Bug Loaders

Most helpful comment

Hmm, so I guess AudioLoader shouldn't pass the manager to FileLoader and call the functions itself?

All 3 comments

Hmm, so I guess AudioLoader shouldn't pass the manager to FileLoader and call the functions itself?

That would definitely fix it for a custom loading manager. The default loading manager would still ignore the decoding callback, but how many people use the default loading manager in this context?

I experienced the same problem. At the moment it's not possible to securely play an audio file after the managers onLoad callback fired.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

stonexjr picture stonexjr  路  3Comments

fuzihaofzh picture fuzihaofzh  路  3Comments

boyravikumar picture boyravikumar  路  3Comments

scrubs picture scrubs  路  3Comments