Below is the error I get when running the development build of the game. I really have no idea what is causing it not to work. I tried a newer version of unity, several different project settings. I tried a windows build and that worked no problem. What could be causing this error?
An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:
RuntimeError: remainder by zero
at AudioSource_Get_Custom_PropTime(Il2CppObject*) (http://localhost:62089/Build/Build.wasm:wasm-function[153582]:0x38ed947)
at dynCall_fi (http://localhost:62089/Build/Build.wasm:wasm-function[155145]:0x396fe4a)
at http://localhost:62089/Build/Build.framework.js:1049:20
at invoke_fi (http://localhost:62089/Build/Build.framework.js:15319:10)
at AudioSource_get_time_m130D08644F36736115FE082DAA2ED5E2C9D97A93 (http://localhost:62089/Build/Build.wasm:wasm-function[56120]:0x1410f7f)
at dynCall_fii (http://localhost:62089/Build/Build.wasm:wasm-function[155103]:0x396faf1)
at http://localhost:62089/Build/Build.framework.js:1049:20
at invoke_fii (http://localhost:62089/Build/Build.framework.js:15330:10)
at Music_Update_mC6F22F59D6B422F19FB150AD107AFDD671A2A17A (http://localhost:62089/Build/Build.wasm:wasm-function[108340]:0x2783eb9)
at RuntimeInvoker_TrueVoid_t4861ACF8F4594C3437BB48B6E56783494B843915(void (*)(), MethodInfo const*, void*, void**, void*) (http://localhost:62089/Build/Build.wasm:wasm-function[131722]:0x2e3b744)
at il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**) (http://localhost:62089/Build/Build.wasm:wasm-function[134521]:0x2e75802)
at dynCall_iiii (http://localhost:62089/Build/Build.wasm:wasm-function[155089]:0x396fa0d)
at http://localhost:62089/Build/Build.framework.js:1049:20
at invoke_iiii (http://localhost:62089/Build/Build.framework.js:15143:10)
at il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) (http://localhost:62089/Build/Build.wasm:wasm-function[134496]:0x2e74c25)
at il2cpp_runtime_invoke (http://localhost:62089/Build/Build.wasm:wasm-function[134569]:0x2e76fac)
at ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) (http://localhost:62089/Build/Build.wasm:wasm-function[152219]:0x38839b7)
at MonoBehaviour::CallUpdateMethod(int) (http://localhost:62089/Build/Build.wasm:wasm-function[152159]:0x387f493)
at MonoBehaviour::Update() (http://localhost:62089/Build/Build.wasm:wasm-function[152160]:0x387f4a8)
at void BaseBehaviourManager::CommonUpdate<BehaviourManager>() (http://localhost:62089/Build/Build.wasm:wasm-function[137342]:0x2f0be19)
at BehaviourManager::Update() (http://localhost:62089/Build/Build.wasm:wasm-function[137341]:0x2f0bb9a)
at InitPlayerLoopCallbacks()::UpdateScriptRunBehaviourUpdateRegistrator::Forward() (http://localhost:62089/Build/Build.wasm:wasm-function[151915]:0x385b080)
at ExecutePlayerLoop(NativePlayerLoopSystem*) (http://localhost:62089/Build/Build.wasm:wasm-function[137150]:0x2ef88f7)
at ExecutePlayerLoop(NativePlayerLoopSystem*) (http://localhost:62089/Build/Build.wasm:wasm-function[137150]:0x2ef8993)
at MainLoop() (http://localhost:62089/Build/Build.wasm:wasm-function[149814]:0x372330c)
at dynCall_v (http://localhost:62089/Build/Build.wasm:wasm-function[155085]:0x396f9d2)
at http://localhost:62089/Build/Build.framework.js:1049:20
at browserIterationFunc (http://localhost:62089/Build/Build.framework.js:9546:13)
at callUserCallback (http://localhost:62089/Build/Build.framework.js:7736:3)
at Object.runIter (http://localhost:62089/Build/Build.framework.js:7797:4)
at Browser_mainLoop_runner (http://localhost:62089/Build/Build.framework.js:7711:20)
The solution in my case was that music was set to streaming but was not in the resources folder. This error is going to result from about a million different things from what I understand. My steps were
Build in development mode
Observe the error in development mode
Find something that seemed relevant and actionable
Make changes
Rinse repeat
It took a ton of time to find the solution but it seems pretty easy in hindsight. Best of luck!
A property of the issue was that it only occurred in looping audio playback if I remember correctly. Playing non-looping audio would not exhibit the bug. The bug was caused due to Web Audio API performing audio decoding asynchronously, and while the decoding is taking place, JS code would not know the length of the clip to determine the proper loop point. So if C# code attempted to ask for the loop point or start playback while decoding was still taking place, the audio player would incorrectly think that the loop cycle would have to be zero length, resulting in a division by zero.
Looks like the issue has been fixed into 2022.3.10f1, 2023.1.13f1, 2023.2.0b9, 2023.3.0a2, and looking at 2021.3 dev branch, I see that a backport did already land 3 weeks ago, but I am not sure why issue tracker web site does not match that, and is stuck at printing “Fix In Review for 2021.3.31f1”. That should have come out in Unity 2021.3.30f1 by now.
In any case, if you are using a Unity version that is newer than any of those and the issue still persists, please raise a new bug report, as that suggests that the above bug would have been different, and just accidentally with the same division by zero error message.
I suspect that dotnet runtime issue would not be related to this.
It does have the same error message for sure, but the call stacks of where the errors occur look very different. That dotnet issue is something to do with hash tables, though the issue we are looking at here is related to something specifically in the audio backend. So my first gut feeling is that these would be separate.