Hi,
All of the sudden, I experience issues with the audio in my WebGL game in Chrome (Firefox works fine). It only happens in wasm builds (not in asm), and it didn’t happen before (I haven’t changed anything).
It just appeared… maybe because Chrome auto updated or something?
Anyway, I can’t find much information about it.
I checked the logs, and there something weird is happening too.
This part fires almost immediately (during the loading of my game):
UnityLoader.js:4 trying binaryen method: native-wasm
UnityLoader.js:4 asynchronously preparing wasm
UnityLoader.js:4 binaryen method succeeded.
Then, the game is loaded and I can start playing, but there’s no audio for 10-15 seconds.
Then all of the sudden, the audio starts, and together with that, the console continues too:
Loading player data from data.unity3d
UnityLoader.js:4 Initialize engine version: 2018.2.17f1 (88933597c842)
UnityLoader.js:4 Creating WebGL 2.0 context.
UnityLoader.js:4 Renderer: WebKit WebGL
UnityLoader.js:4 Vendor: WebKit
UnityLoader.js:4 Version: OpenGL ES 3.0 (WebGL 2.0 (OpenGL ES 3.0 Chromium))
UnityLoader.js:4 GLES: 3
UnityLoader.js:4 EXT_color_buffer_float GL_EXT_color_buffer_float EXT_disjoint_timer_query_webgl2 GL_EXT_disjoint_timer_query_webgl2 EXT_texture_filter_anisotropic GL_EXT_texture_filter_anisotropic OES_texture_float_linear GL_OES_texture_float_linear WEBGL_compressed_texture_s3tc GL_WEBGL_compressed_texture_s3tc WEBGL_compressed_texture_s3tc_srgb GL_WEBGL_compressed_texture_s3tc_srgb WEBGL_debug_renderer_info GL_WEBGL_debug_renderer_info WEBGL_debug_shaders GL_WEBGL_debug_shaders WEBGL_lose_context GL_WEBGL_lose_context
UnityLoader.js:4 OPENGL LOG: Creating OpenGL ES 3.0 graphics device ; Context level <OpenGL ES 3.0> ; Context handle 1
blob:https://www.mysite.com/920f163c-0f8e-46f5-bdee-3ff53f1e7f85:2 The Web Audio autoplay policy will be re-enabled in Chrome 71 (December 2018). Please check that your website is compatible with it. https://goo.gl/7K7WLu
_JS_Sound_Init @ blob:https://www.mysite.com/920f163c-0f8e-46f5-bdee-3ff53f1e7f85:2
wasm-function[2809] @ wasm-045f9b1e-2809:34
wasm-function[2777] @ wasm-045f9b1e-2777:886
wasm-function[2668] @ wasm-045f9b1e-2668:304
wasm-function[2656] @ wasm-045f9b1e-2656:17
wasm-function[3802] @ wasm-045f9b1e-3802:82
wasm-function[3797] @ wasm-045f9b1e-3797:346
wasm-function[3793] @ wasm-045f9b1e-3793:78
wasm-function[3792] @ wasm-045f9b1e-3792:13
wasm-function[845] @ wasm-045f9b1e-845:162
wasm-function[8507] @ wasm-045f9b1e-8507:83
wasm-function[8485] @ wasm-045f9b1e-8485:79
wasm-function[8431] @ wasm-045f9b1e-8431:439
wasm-function[8430] @ wasm-045f9b1e-8430:5
(anonymous) @ blob:https://www.mysite.com/920f163c-0f8e-46f5-bdee-3ff53f1e7f85:2
callMain @ blob:https://www.mysite.com/920f163c-0f8e-46f5-bdee-3ff53f1e7f85:2
doRun @ blob:https://www.mysite.com/920f163c-0f8e-46f5-bdee-3ff53f1e7f85:2
run @ blob:https://www.mysite.com/920f163c-0f8e-46f5-bdee-3ff53f1e7f85:2
runCaller @ blob:https://www.mysite.com/920f163c-0f8e-46f5-bdee-3ff53f1e7f85:2
removeRunDependency @ blob:https://www.mysite.com/920f163c-0f8e-46f5-bdee-3ff53f1e7f85:2
processDataJob @ UnityLoader.js:4
a.callback @ UnityLoader.js:3
setTimeout (async)
a.complete @ UnityLoader.js:3
(anonymous) @ UnityLoader.js:4
r.worker.onmessage @ UnityLoader.js:3
UnityLoader.js:4 UnloadTime: 0.700000 ms
[Violation] 'setTimeout' handler took 836ms
10[Violation] 'requestAnimationFrame' handler took <N>ms
blob:https://www.mysite.com/920f163c-0f8e-46f5-bdee-3ff53f1e7f85:2 warning: 2 FS.syncfs operations in flight at once, probably just doing extra work
UnityLoader.js:4 UnloadTime: 8.500000 ms
UnityLoader.js:4 Unloading 5 Unused Serialized files (Serialized files now loaded: 0)
blob:https://www.mysite.com/920f163c-0f8e-46f5-bdee-3ff53f1e7f85:2 warning: 2 FS.syncfs operations in flight at once, probably just doing extra work
UnityLoader.js:4
UnityLoader.js:4 Unloading 7 unused Assets to reduce memory usage. Loaded Objects now: 4839.
UnityLoader.js:4 Total: 8.300000 ms (FindLiveObjects: 1.200000 ms CreateObjectMapping: 0.400000 ms MarkObjects: 6.400000 ms DeleteObjects: 0.300000 ms)
That didn’t happen before. Before, the game loaded and during this load the second part of the console was written, not after 10-15 seconds.
Does anyone know what’s causing this? Is there a fix?
I stumbled upon this game on the internet: https://webassembly.org/demo/Tanks/
This game has the exact same issue as I describe, so I guess it’s not only a problem in my game…
(note: the tanks demo has errors in the console, mine hasn’t).
[This user]( Chrome On The Dev Branch (version 66) May Block Audio For Unity WebGL page-2#post-3938836) seems to address the same problem.
There’s something about Chrome’s Web Audio autoplay policy in the logs as you can see… not sure if this has something to do with it.
Any help is much appreciated… I have no idea how to tackle this…