Search Unity

Question No sound clips in WebGL build

Discussion in 'Web' started by robindev, Dec 3, 2020.

  1. robindev

    robindev

    Joined:
    Sep 2, 2014
    Posts:
    8
    Hello,

    I'm running into an issue, and I have not been able to find a satisfactory solution on this forum, and am wondering if it is a bug, or my own fault. I'm using unity 2019.4.10f1 LTS under linux(ubuntu), and building a project for windows or linux goes fine, but under WebGL I'm running into an issue with sound, where I get the following error in the browser-debug screen:

    PlayOneShot was called with a null AudioClip.- (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

    Steps to reproduce:
    While building for webgl, I did get a message of missing ffmpeg.
    After installing ffmpeg;
    $ sudo apt install ffmpeg

    together with setting python2 as primary
    $ sudo update-alternatives --config python

    and libtinfo5
    $ sudo apt install libtinfo5

    the build went successful.
    To test the webpage, I use
    $ python -m SimpleHTTPServer

    However, no sound, and the error show above..
    I have encountered the same issue on 2 different machines.

    Attempts to solve it:
    1. I did a switch to a different platform and back to hopefully clear the cache, but this did not seem to resolve it.

    2. I also attempted to remove the complete project Library folder, and this seems to solve the issue for some reason. While according to the documentation, switching platform should trigger the same re-import, right?

    3. I've noticed that clearing the browser-cache is necessary as well for clearing the issue, after following the steps above. (makes sense, as the browser otherwise uses the old resource-files)

    Am I missing a step during a rebuild, is there another way to refresh the library, or is this maybe an issue with Unity and (WebGL) builds?

    Best regards,

    Robin
     
    bobbaluba likes this.
  2. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    I had unexplained issues with WebGL audio until 2021 - after upgrade to that, everything worked. I've seen other people mention this solved it for them as well, but I don't know if there are plans to backport whatever changes were made that fixed it ..maybe it was fixed accidentally somehow and nobody knows exactly what it was :D
     
    robindev likes this.
  3. bobbaluba

    bobbaluba

    Joined:
    Feb 27, 2013
    Posts:
    81
    @robindev I'm also running into this, did you find a solution?

    In my case:

    - It happens in CI (linux-based), so builds are completely clean each time.
    - Does not happen on my desktop (windows)
    - Refreshing or clearing cache has no effect
     
  4. robindev

    robindev

    Joined:
    Sep 2, 2014
    Posts:
    8
    Hi @bobbaluba , In my case I could resolve it my removing the library folder, and re-opening the project, after which the problem did not surface anymore. But I do not know if that applies to CI builds.. I did notice you have to choose the correct codecs/formats configured in unity, and installed in the browser(this may not always be the case by default on ubuntu)
     
  5. Amogh_Subhedar

    Amogh_Subhedar

    Joined:
    Jul 5, 2020
    Posts:
    2
    Any updates on this? I am in the same exact situation as @bobbaluba and have also tried clearing all Library cache before building. I am using 2019.4.10f1

    I also found a similar issue: Unity Issue Tracker - [WebGL] Audio is not played when in built Player (unity3d.com) for 2020.2 and 2018.2 versions of Unity that have been fixed.
     
    Last edited: Feb 28, 2021
    bobbaluba likes this.
  6. bobbaluba

    bobbaluba

    Joined:
    Feb 27, 2013
    Posts:
    81
    @Amogh_Subhedar No updates except it's still an issue in 2020.2.3.

    Only workaround I've found is to build on windows instead.

    Have you tried building on an actual linux desktop? Perhaps our ci images is missing some dependencies? (I'm using gameci/unityci 0.9, https://unity-ci.com/docs/docker/versions).
     
  7. Amogh_Subhedar

    Amogh_Subhedar

    Joined:
    Jul 5, 2020
    Posts:
    2
    I haven't tried building on an actual linux desktop yet. Are you building on windows locally because I don't think unity-ci docker images have support for windows. I did try their older ubuntu versions 18 and 16 but no luck there.

    I filed an issue here: WebGL builds have no audio · Issue #223 · game-ci/unity-builder
     
    Last edited: Mar 1, 2021
  8. bobbaluba

    bobbaluba

    Joined:
    Feb 27, 2013
    Posts:
    81
    Yeah, sorry. I'm just doing a regular windows desktop build manually and then shoehorning it into my pipeline.
     
  9. bobbaluba

    bobbaluba

    Joined:
    Feb 27, 2013
    Posts:
    81
  10. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    So the CI runs on an Ubuntu? That does sound like missing ffmpeg is not properly caught in the build. Added a note to the team to investigate, though filing a bug report would be best, that would get the QA attention to test the issue as well.
     
  11. bobbaluba

    bobbaluba

    Joined:
    Feb 27, 2013
    Posts:
    81
  12. DwightDavis

    DwightDavis

    Joined:
    Oct 19, 2019
    Posts:
    4
    I'm having a related problem. When I switch from Windows to WebGL in the editor, all of my .wav audio files suddenly are no longer recognized by Unity as sound files. Their icon changes from the orange sound wave to a blue music note with "WAV" underneath. All my Audio Source Components, for their AudioClip slot, list "Missing (Audio Clip)". Upon exporting, the entire game is muted. When I switch back to Windows, everything is suddenly fixed. Running 2021.1.5f1
     
  13. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Do you recall whether there was a good error message that pointed you towards the direction that ffmpeg was missing, I wonder if we have any missed/bad error reporting in play around that area?
     
  14. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    That looks very odd. Does that happen in a new project if you add audio clips and switch across platforms?
     
  15. bobbaluba

    bobbaluba

    Joined:
    Feb 27, 2013
    Posts:
    81
    > Do you recall whether there was a good error message that pointed you towards the direction that ffmpeg was missing, I wonder if we have any missed/bad error reporting in play around that area?

    EDIT: I wrote something completely wrong here.

    I checked my build logs, and the error is like this:

    Code (csharp):
    1.  -> (artifact id: '2e93aa66b285e4135bce300156cc3913') in 0.075023 seconds
    2. Start importing Assets/Audio/Tom1-3.wav using Guid(dad06761d892d6141b17b6ef734bdadb) Importer(-1,00000000000000000000000000000000) sh: 1: ffmpeg: not found
    3. sh: 1: ffmpeg: not found
    4. sh: 1: ffmpeg: not found
    5. Errors during import of AudioClip Assets/Audio/Tom1-3.wav:
    6. ffmpeg -i "Temp/fsbankcache 1/tmpinput_VEI82O.WAV" -f mp4 -codec aac -b:a 192000 -strict experimental -y "Temp/importedAudioTempPrimary"
    7. FSBTool ERROR: Error converting Temp/fsbankcache 1/tmpinput_VEI82O.WAV: make sure you have avconv or ffmpeg installed
    8. FSBTool ERROR: Failed encoding audio clip '/builds/johanhelsing/minijam-73-power/Assets/Audio/Tom1-3.wav' to AAC. Possibly the file is too short. Try to append silence such that the length becomes greater than 256 samples.
    9.  
    So it's pretty clear what's wrong, it's just confusing that the build passes, I would prefer a hard fail.
     
  16. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Gotcha. Yeah, the error looks sensible at least.

    I can see rationale for both kinds of behavior. E.g. a person doing a first build over to WebGL of a larger project, they might appreciate being able to truck on through this and seeing what the project looks like, even if it comes without sounds.

    Do the errors appear with a red exclamation mark in Unity Editor log view? If so, then I think the behavior is probably good for now. Though if the logs do get buried behind opening up Editor.log files, then that is quite hard to find.
     
  17. bobbaluba

    bobbaluba

    Joined:
    Feb 27, 2013
    Posts:
    81
    Sorry, I don't really know. I don't get the error on windows, and my CI setup runs gui-less. I do have a linux desktop distro installed somewhere, but pretty sure it has ffmpeg, though. I can try uninstalling and see what kind of error I get.

    I'm thinking this is mostly a CI issue where it works on your local desktop, but somehow surprisingly the ci-built versions come out without sound.

    But I guess now that it works with game.ci 0.10 (or perhaps it was 0.11), and I'm assuming it also works with unity cloud build, it's probably not that many people that are going to run into it.
     
  18. Irina-uk

    Irina-uk

    Joined:
    Feb 14, 2014
    Posts:
    62
    Oelson likes this.