WebGL build&run, chrome and audioclip issues

Hello!

I use chrome and firefox, both up-to-date. When I build WebGL version by clicking build, the only browser that opens it is Firefox. Chrome just don’t want to open, it shows the WebGL player, but the content doesn’t appear.
I found that if build pressing ‘build&run’ then unity will create temporary server, so the built project opens in chrome. And here the problem comes with my Audio files. Background music(which is Audio component of main camera and goes as public AudioSource in the script), and GameOver sound (which goes as public AudioClip in the same script). Both are stereo files.

After opened in chrome (after build&run as a temp.server), the background music comes only from right speaker, setting ‘Spatial blend’ value to 0 helps to avoid it. But the ‘GameOver’ sound is just a sound in my assets collection. Script don’t take it as some GameObject’s component. So there is no such option as ‘spatial blend’. Besides what if I don’t want to make all my sounds as some GameObject’s components? Without setting ‘spatial blend’ to zero the sounds come from right speaker. And while these come from right speakers others sounds like hit/shot or coin collecting comes from right speaker only. And that’s the problem of ‘Build&Run’ option.

As I said chrome doesn’t open project without clicking ‘build&run’ so I don’t know if its fully chrome’s issue or bug in temporary created local server. But as I said Firefox opens the project very well. And play all the sounds good.

The problem didn’t exist when I built ‘web player’ version. I used Unity 5.3.5f1, but since ‘web player’ no longer supported I started to explore WebGL builds. WebGL problem exist both in Unity 5.3.5f1 and 5.4.0f3 which I downloaded and tested thoroughly.

Converting audio files to mono channel doesn’t help. Placing audio listener to any other object doesn’t help. Making parent&child relationship between objects (camera/ game manager script) also doesn’t help.

Should I stick to Firefox only while testing? But what I supposed to do when turn this simple scene to entire game and want to deploy to people who don’t use Firefox browser?

P.S. I tried to describe the problem thoroughly. Hope it’s not that hard to understand/reproduce the issue: unable to open in chrome when build without temp.server and problem with audio files.

yes, that’s normal. You need to start Chrome with --disable-web-security for that to work, as described here.

do the sounds work as you expect when you Play in the editor ?

the best way to distribute your game is to have it hosted (your own server or itch.io, newsgrounds, kongregate, etc…).

1 Like

I tried before to launch chrome with this command –disable-web-security. It keeps saying:
You are using an unsupported command-line flag: --disable-web-security. Stability and security will suffer.

Which results in the next dialog box pop-up when I try to open index.html file of the project:
It seems your browser does not support running Unity WebGL content from file:// urls. Please upload it to an http server, or try a different browser.

Yes, sounds work as expected in editor. The issue is only when I build project.


I can stick to Firefox. It’s okay. I just worried a little bit, because I don’t know how the projects would appear and work in other browsers, such as chrome. But using just Firefox doesn’t cancel those workarounds I need to do (spatial blend set to zero, force sound to mono, etc.)

Hello Yaroslav-Osipov.

This has been changed in the recent versions of Chrome. Now you should use –allow-file-access-from-files flag.
I would recommend to use both –allow-file-access-from-files and –disable-web-security so that you can both load files from your local drive and download content from a remote server without having to setup CORS headers during development.

@alexsuvorov Any feedback on the audio issues being experienced in Chrome that the OP mentions?

I’m having the same problem in Chrome.
My engine sounds seem to only play in the right-hand speaker in Chrome.

In the editor, the engine sounds come out both speakers. In Firefox, the engines comes out both speakers.

Anything I can check or change? This is using 5.4.1f1