WebGL Audio Problems
This page documents and track the reasons why Compatibility Mode is present.
In short
- Tiny Ambience is NOT SUPPORTED in WebGL, as I officially states. But there are ways to make it somewhat work if you really want to use it in WebGL, such as your game being a multi-platform game and it is a pain to remove Tiny Ambience in just WebGL build. (Or you really love Tiny Ambience...)
- Update to the latest of your version that is over 2020.3.X. For example, 2021.2.1f1 gives much more catastrophic audio bugs than 2021.2.4f1.
- If you use any Timeline layer in your
Ambience
asset file, use the Compatibility Mode settings to specify a fallback. (Do not select "Play Anyway" or you will hit a bug.)
See the bugs in their glory
To demonstrate how incompetent Unity is on WebGL audio, I have built a special demo with an intent to crash Unity. It is the same as Day and Night Demo but all Timeline layers are marked "Play Anyway" in their Compatibility Mode instead of avoiding the bugs.
- Bugged 2020.3.23f1
- Play "Day" ambience and wait a bit to see FMOD spam errors about code 36 :
getNumOutputs
,getOutputs
and code 78 :setMix
,setUserData
. But technically the audio sounds as if Timeline works perfectly, only error spam is the problem. The error spams indefinitely. - "Night" works perfectly, since it uses only Looping Clip layer, not Timeline.
- Play "Day" ambience and wait a bit to see FMOD spam errors about code 36 :
- Bugged 2021.2.4f1
- Play "Day", stop, then play "Day" again (or play 2 times consecutively) to get FMOD spam error about code 36 :
getNumOutputs
,getOutput
, andsetMix
. The error logs for only a bit instead of indefinitely. Again, audio sounds as if Timeline works perfectly.
- Play "Day", stop, then play "Day" again (or play 2 times consecutively) to get FMOD spam error about code 36 :
Detailed error messages
Provided to catch some Google traffic when someone searched for this bug, so they know it is a known bug. Look at the "error code __" and the function name to match with the reproduce steps above.
FMOD returns error code 36 (FMOD_ERR_INVALID_HANDLE) executing getNumOutputs
./Modules/Audio/Public/Director/AudioPlayable.cpp(28) : Error executing headDSP->getNumOutputs(&outputCount) (An invalid object handle was used. )
FMOD returns error code 36 (FMOD_ERR_INVALID_HANDLE) executing getOutput
./Modules/Audio/Public/Director/AudioPlayable.cpp(32) : Error executing headDSP->getOutput(0, NULL, &outputConnection) (An invalid object handle was used. )
FMOD returns error code 36 (FMOD_ERR_INVALID_HANDLE) executing setMix
./Modules/Audio/Public/Director/AudioPlayable.cpp(35) : Error executing outputConnection->setMix(mix) (An invalid object handle was used. )
FMOD returns error code 78 (FMOD_ERR_UNIMPLEMENTED) executing setMix
./Modules/Audio/Public/Director/AudioPlayable.cpp(35) : Error executing outputConnection->setMix(mix) (Something in FMOD hasn't been implemented when it should be! contact support! )
FMOD returns error code 78 (FMOD_ERR_UNIMPLEMENTED) executing getUserData
FMOD returns error code 78 (r) executing getUserData
./Modules/Audio/Public/Director/AudioPlayable.cpp(233) : Error executing group->getUserData(&check) (Something in FMOD hasn't been implemented when it should be! contact support! )
FMOD returns error code 78 (FMOD_ERR_UNIMPLEMENTED) executing setUserData
FMOD returns error code 78 (r) executing setUserData
./Modules/Audio/Public/Director/AudioPlayable.cpp(330) : Error executing m_ChannelGroup->setUserData(CHANNELGROUP_REFRESH_REQUIRED) (Something in FMOD hasn't been implemented when it should be! contact support! )