Search Unity

WebGL: "both async and sync fetching of the wasm failed". Build and runs works, fails when uploading

Discussion in 'Web' started by Mikyjax, Aug 3, 2020.

  1. Mikyjax

    Mikyjax

    Joined:
    Jan 4, 2015
    Posts:
    4
    Hello,
    I tried to build the most simple WebGL application possible with Unity 2020.1 as I was having issue with uploading my game. I thought it was the game itself so I tried a very simple project.

    One label showing "Test"

    While build and run works flawlessly locally, I tried to upload it on my ftp and get a few errors.
    "Both async and sync fetching of the wasm failed"

    Then the loading is stuck at 90%
    I have the same behavior in Firefox and Chrome.
    See errors here:
    www.awakendreamsprod.com

    Hope you can help, thanks in advance!
     
    MilenaRocha likes this.
  2. Mikyjax

    Mikyjax

    Joined:
    Jan 4, 2015
    Posts:
    4
    enabling Decompression fallback fixed my issue.. Now I'm not sure it's a good thing...
    I have no experience with online application.
    Should I do something else?
    Thanks
     
  3. Kjelle69

    Kjelle69

    Joined:
    Nov 9, 2016
    Posts:
    53
    I got the same issue where a simple application stopped at 90%.
    Disabled the compression in Player settings - Publishing settings - Compression format and then it worked. At least in MS Edge.
     
  4. anthonykwinters

    anthonykwinters

    Joined:
    Feb 28, 2018
    Posts:
    1
    I'm having the same issue as the original post. I have disabled compression and I still get the same error. Any other ideas?
     
  5. murdoc911

    murdoc911

    Joined:
    Jul 26, 2020
    Posts:
    1
    yeah, same probleme here...
     
  6. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    There is one bug where if you use "Filenames as hashes" together with a compressed build (gzip or brotli) then decompression will fail. Even with the new web.config or htaccess file.
    This is due to the fact that when filenames are converted to hashes they lose their .data and .wasm extension in the naming.
    Which brings me to my next point, they changed the extension a little bit. So mimetypes have to be changed accordingly.

    If you're running old configurations you're going to require a new configuration.
    https://docs.unity3d.com/2020.1/Documentation/Manual/webgl-server-configuration-code-samples.html

    So yeah quite some changes have been made to 2020.1 WebGL, including the Template it uses. Old custom templates will be broken as far as I know.

    WebGL Mobile is no longer blocked by an unsupported message. But it is not the most performant either.
    for Apple devices, Safari is only supporting WebGL 1.0 (unless experimental WebGL 2.0 is enabled. They never continued development because they are focussing on WebGPU instead)
    for Android WebGL 2.0 can be used on Chrome / Firefox. But still, not super performant.
    The hope is that in some time (1 or 2 yrs) WebGPU is fully developed and embraced by all browsers.
     
    Last edited: Aug 25, 2020
  7. JeffreyBennett

    JeffreyBennett

    Joined:
    May 18, 2017
    Posts:
    25
    It worked for me.

    I'm using Unity 2020, and since that has a compression bug, I had to turn off GZip compression in the player settings (So go to File > Build Settings > Player Settings > Player > Publish Settings > set Compression Format to Disabled.

    I assume when the bug gets fixed the Gzip can be turned back on. Then, following the link from Masked Mouse above, I went there, found the IIS Uncompressed section, and copied and pasted all of that text to a new Text Edit file (I work on a Mac, but not posting to Apache server in my case). Here is the link to the discussion about the bug > https://forum.unity.com/threads/unc...htmlscriptelement-script-onload-webgl.803967/

    I saved the file, naming it web.config and then copied that up to my server into my build folder. When I reloaded the page, it worked.
     
  8. sbeachld

    sbeachld

    Joined:
    Jul 20, 2020
    Posts:
    2
    To anyone following this- after chasing my tail on this exact issue for a week and doing what everyone mentioned above (as well as a few other things.) Here is the apache config that actually worked for me:

    Code (Apache):
    1. <IfModule mod_mime.c>
    2. AddType application/wasm .wasm
    3. AddOutputFilterByType DEFLATE application/wasm
    4. </IfModule>
    If you have turned off compression to work around the bug and have the line "AddEncoding br .wasm" in your config, it will throw the wasm error in any browser that isnt Firefox.
     
  9. buzzing_jelly

    buzzing_jelly

    Joined:
    Oct 3, 2018
    Posts:
    1
    How do you find and copy the edited text file to the server? I have my .config file I made from the link, but how do I use/apply it to the build? Thanks
     
    MilenaRocha likes this.
  10. mauriciowgarcia

    mauriciowgarcia

    Joined:
    Aug 4, 2020
    Posts:
    1
    I don't know what is an apache config. Where should I put this code?
     
    MilenaRocha likes this.
  11. Shaolin-Dave

    Shaolin-Dave

    Joined:
    Apr 3, 2015
    Posts:
    32
    I'd also like to know where to put this code.

    Been having the issue with my current project. I've tried all compression formats, hashes and no, development and release builds, I've tweaked the eneable exceptions and webassembly arithmetic exceptions settings, I've tried everything.

    My game sometimes runs the first time from my disk but won't run a second time. It won't run even once if I post it online.

    MY WORKAROUND:
    This might not work for everyone but I did get a stable build doing it this way.
    First of all, I used Unity's Cloud Build service. Building locally didn't work, but on Cloud did.
    Default player settings didn't work even on Cloud. I'm not sure which of these was relevant, but these settings combined worked:
    Enable Exceptions: None
    WebAssembly Arithmetic Exceptions: Ignore
    Compression Format: Brotli
    Name Files as Hashes: false
    Data Caching: True
    Debug Symbols: false
    Decompression Fallback: true
     
    Last edited: Oct 7, 2020
    melmin likes this.
  12. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    A few things in this thread:

    I have been very vocal in our team that we should delete the whole `Decompression Fallback` feature from Unity. As result, when we refactored the loader in 2020.1 (iirc) it was at least disabled by default. The reason is that it is a bandaid to hide a core problem under the rug and it lets the developer forget about needing to fix things up later. Basically doing a grave disservice to developers.

    What Decompression Fallback does is that it decompresses the downloaded content in JavaScript, if the hosting web server was not properly configured to advertise compression in HTTP Content-Encoding response header (and as a result, user's browser did not decompress the content in native code). This has big problems:
    - it is SLOW on desktop devices,
    - it is SUPER SLOW on mobile devices and burns battery at startup,
    - it prevents the use of WebAssembly streaming compilation, where the .wasm file is compiled into the browser already while it is being downloaded; a feature that usually makes it look like compilation time was instantaneous, and one just had to wait for the network download.

    We have talked a lot about Unity's "Performance by Default" philosophy, and the Decompression Fallback certainly is at the opposite end of the spectrum of that. Sure, it made the build start up, which one might argue is better than not starting up at all; but the root issue is that it might hint a developer to call it a day right there, and the real hosting problem would not then get addressed.

    To fix the situation properly, one should always disable the Decompression Fallback, and then update the web server configuration to properly advertise Content-Encoding: gzip (or br if using Brotli), and the respective Content-Type headers.

    Agreed, looks like this issue is in our QA queue atm.

    To debug all these kinds of loading errors, the web browser console and the Network tab are your friends. Use the browser console to find if there are any site errors, and the Network tab to verify what files got downloaded from the server, and what HTTP Response Headers they were served with.

    That will help you figure out what is missing from the proper configuration.
     
    rafftune, Akashelia and KamilCSPS like this.
  13. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
    Any way we can add to your "vocalisation" about this? I wholeheartedly agree with everything you said about the decompression fallback, it shouldn't be an option, much less activated by default.
     
    MilenaRocha likes this.
  14. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    I am planning that we would add a warning box next to the option to mention that it should not be used in production. Maybe that will remind users as long as they have that enabled. (and keep it disabled by default)
     
  15. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    Sometimes just for tests I run builds on local servers with no configuration, so I do like this feature, but when on the actual production server, removing this code would be better.
     
  16. SerializeField

    SerializeField

    Joined:
    May 22, 2017
    Posts:
    22
    I'm building a WebGL game, that's hosted on an AWS bucket. The only way I can get it to load from there is if I enable "Decompression Fallback".

    From what I understand from this thread is that I shouldn't enable it but I can't get it to work without it.
    Any advice on what I should do?
     
  17. BlingBlueStar

    BlingBlueStar

    Joined:
    Dec 21, 2016
    Posts:
    1
    I have same issue too...
    I change compression disable but still not working...
     
    MilenaRocha likes this.
  18. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    106
    While I agree with the concept, Decompression Fallback was the only way for my client to get his WebGL game downloaded. Yes, it's a server configuration problem, but I haven't been able to find a solution anywhere. I dare say it's a trivial matter of updating the Content-Encoding and Content-Type on the server, but my client has access to a CPanel admin page, which looks to be allowing new content types to be added, but no matter what combination of entries he makes, he can't seem to get the compression working. And of course, then that falls back on to me, rightly or wrongly, and I'm now having to try and figure out how to get something that should be simple, working. He thinks it should "just work", and I don't blame him.

    So, after all of that, is there any recommendations/instructions for the configuration of a system that has CPanel?
     
  19. slaga

    slaga

    Joined:
    Dec 3, 2018
    Posts:
    142
    anyone found a decent solution? i only get this error when my game is opened through facebooks browser. funny thing is that its only on this game in particular event though it loads on desktop and mobile browsers. i dont know what to do!!!

    in case someone might help this one http://todiktamo.slaga-games.com/ doesnt open through fb browser

    and http://showcase.slaga-games.com/ works just fine. both use 2020.1.4f same build settings. im losing my mind. i tried some other builds that i had already given to clients and they worked fine in their hosting services but when i upload them on mine they dont work
     
  20. Shrubokrant

    Shrubokrant

    Joined:
    Oct 2, 2016
    Posts:
    80
    Just want to bump the thread: I tried to build a demo for WebGL with both 2019.4 and 2020.2: 2020.2 fails and raises this error no matter what I try, and 2019.4 is working no problem: this has to do with a bug in the new version
     
    MilenaRocha likes this.
  21. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    It depends on your settings and server configuration.

    The only bug so far which I am aware of and I don't know if it is already fixed or not is the toggle for "Name Files As Hashes" setting.
    If toggled on it doesn't keep the required extensions in its name. The server can't serve the files properly when that happens.

    So a few questions:
    - Decompression Fallback turned off?
    - What is your web server based on? IIS, Apache? else? unknown?
    if IIS or Apache
    - Do you use the server configuration file meant for either of those?
    - Are you using Gzip or Brotli compression?
    If Brotli
    - Are you using https?
     
  22. Shrubokrant

    Shrubokrant

    Joined:
    Oct 2, 2016
    Posts:
    80
    Tried all the build options, Decompression turned on or off.
    No server, just the "build and run"
    tries gzip brotli or none
    https, yes
     
  23. Emilinat0r

    Emilinat0r

    Joined:
    Aug 28, 2018
    Posts:
    1
    To anyone seeking a solution from this thread: I was having the same issue that people here are facing and couldn't determine what it was for 2 days. Finally I found out that when my game scene was loaded, the application froze or ran out of memory or something similar because I was instantiating so many gameobjects at once.

    I solved my problem by adding a small timer after the scene was loaded before instantiating my gameobjects. Not sure why that makes such a difference, but it does and now my application works flawlessly.

    Sorry if this post wasn't as technical as the other more informative ones, just thought I'd share my solution here if anyone else came across this similar issue. :)
     
  24. VoidBreakX

    VoidBreakX

    Joined:
    Dec 21, 2020
    Posts:
    1
    Hi, apparently I have the same problem as Mikyjax, but my one DOESN'T EVEN LOAD. Please don't be too technical. I didn't understand a word of what was above, if you have a solution, can you please describe it STEP BY STEP please? Help is greatly appreciated.
     
  25. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    The procedure that I recommend here is:

    1. Try downloading Unity 2021.1.0b4 Pre-Release and see if that brings up more helpful diagnostics about the problem. (you don't necessarily need to update your proejct to Unity 2021.1.0b4 to test, but can use that to build and deploy an empty WebGL project to your hosting server)
    2. If you have access to the server configuration, follow https://docs.unity3d.com/Manual/webgl-deploying.html to configure the web server for compression. If you do not have access to the server configuration, reach out to the web server admin to configure the web server appropriately.
    3. If configuring the web server is not possible, as a last resort, enable the "Decompression Fallback" in the WebGL player project settings.
    4. If none of the above steps help, then it is likely that the error is somewhere else. In that case, please open a new thread and log out the errors that are posted. (Preferably host the page live somewhere that people can check out to help)
     
  26. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    I just ran into the same problem:
    The project was created in Unity 2020.1 and updated to 2020.2.2f1 yesterday.
    It's a pretty simple thing: A player that can walk around inside a room (2 objects: 1. floor+walls, 2. roof) and enter one of 2 doors. Each door is a plane with a lava shader (free asset from the store) on top (to make it "wobbly") and I also added bloom (to make it glow) through post processing.
    This works fine in Unity itself but when I try to run the .html file in my browser (tested with Firefox 85.0 and Chrome), it displays a grey rectangle with the Unity logo and a loading bar but also pretty much instantly pops up the error message.

    Compression was set to "Gzip" and if I disable it, there's an additional error message (it doesn't show up with compression enabled!), even though it still finishes exporting:
    I already had problems with similar errors after updating yesterday but then I updated a couple of "Unity Registry" assets (everything installed is now up to date, PostProcessing: 3.0.1) and the errors were gone.

    I keep reading about setting up a server but the "UnityWebRequest" code in my project is currently commented out, so I just double-click the html file or drag it into the browser of my choice. Am I missing anything here?
     
  27. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Yesterday when reading this thread https://forum.unity.com/threads/uni...dexeddb-database-could-not-be-opened.1047761/ I noticed that there is a bug with game being unable to load if
    - Data Caching is enabled in project build settings, and
    - running in a browser that does not have IndexedDB support available (Safari inside IFrame, or any browser in Private Browsing mode)

    That is a bug in Unity. A local fix is posted in that forum thread, I'm landing that fix to Unity trunk shortly, where it should become available to different release channels.
     
  28. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    I wasn't sure if just double-clicking the html file was the right way to do it, so I googled a bit and just came across this video:
    It tells you to use Firefox and change the "privacy.file_unique_origin" setting in its "about:config" to "false" (should be enabled by default).
    I did that and all of a sudden my app is loading just fine (export with compression enabled), no error popup and also no error in the development console.

    I enabled the setting again and all of a sudden the error was back. I never got the "browser not supporting WebGL" error shown in the video though.

    Privacy mode isn't active but data caching is enabled.
     
  29. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Oh I see. The issue was with using the `file://` URL to load up the page, instead of a web server.

    Changing privacy.file_unique_origin to false can open your browser to security issues, so it is in general not recommended to browse the web with it. Instead, use an ad hoc web server, e.g. https://github.com/emscripten-core/emscripten/blob/master/emrun.py to run the builds when running outside Unity.
     
    SimRuJ likes this.
  30. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    Thanks for the warning. I'm aware, I'm going to change it back to "true" when I'm done testing.

    It's interesting that this seemed to instantly fix it but I'm not sure if there's still a problem (that's just being ignored because of the setting) because I never got the proper WebGL error message shown in the video.
    It would be interesting to see the full error message others got and if theirs has the "file://" part too.

    Ad your server suggestion:
    Download the file (right-click on "raw" - save target as), then cd to where it is and use this:
    Or is there more to it?
     
  31. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    To run, try passing

    python emrun.py filename.html

    or

    python emrun.py --no_browser directory/to/unity/build

    You can also pass --port to specify which web server listen port to use.
     
  32. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    I just noticed, emrun is already part of the WebGL package in Unity. For me it's in:
    C:\Program Files\Unity\Hub\Editor\2020.2.2f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten

    As someone else already pointed out here, the full command is (if you let python add itself to PATH):
    I installed the 64bit version but it complained:
    I then also installed the 32bit version but still get the same error. Is "pywin32" something else?

    Edit: I also tested what was suggested in the next post (here):
    With "<old_WebGL_output_dir>" being the path to the index.html. It says
    but doesn't open the file. When I open it myself, I get the "abort(...)" error again.
     
    Last edited: Feb 3, 2021
  33. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
  34. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    Thanks, I installed it and ran it again:
    I re-downloaded the emrun.py today but it always outputs:
     
  35. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    Changing those privacy settings for this purpose is not a good thing.
    If you have issues with the "Build and Run" option of Unity, or you want to open your build without using the "Build and Run" button, you can use local web server.
    One option is NGINX.
    Another option would be Node.JS and the "http-server" package https://www.npmjs.com/package/http-server
     
  36. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    SimRuJ likes this.
  37. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    @jukka_j
    Thanks so much for the insanely fast fix!
    Now it opens the browser and the error's gone too (even with the setting enabled). :)
     
    jukka_j likes this.
  38. Oinkymoo

    Oinkymoo

    Joined:
    Nov 10, 2017
    Posts:
    2
    I'm having the same issue when i run the HTML file directly, but im trying to upload my build to itch.io, and itch doesn't even seem to recognize the build as webgl
     
  39. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    If the build is not recognizing, try contacting Itch.io help for what kind of upload structure it expects. Maybe there is an extra directory in the build, or some directory is missing? (You can also post more information here, though maybe itch.io forums will reach more Itch.io utilizing eyeballs)
     
  40. Oinkymoo

    Oinkymoo

    Joined:
    Nov 10, 2017
    Posts:
    2
    aight it turns out it was me being stupid, not itch. i just forgot to tell itch that it was an HTML game and not a downloadable
     
  41. CodeInMotion

    CodeInMotion

    Joined:
    Jun 1, 2018
    Posts:
    10

    What apache config file? where is it found?

    reading the response in the thread i feel like a real dumbass even though i've been working in unity for 7 years. I can't find an apcahe config file anywhere. can someone please help?
     
  42. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Apache config file is used only with the Apache web server. It stores its main configuration in a file called httpd.conf, which can be found under something like
    - https://stackoverflow.com/questions...find-httpd-conf-file-for-apache-on-my-windows
    - https://access.redhat.com/documenta...linux/4/html/reference_guide/s1-apache-config
    - https://www.phusionpassenger.com/library/install/apache/working_with_the_apache_config_file.html

    Check out https://httpd.apache.org/docs/current/configuring.html for the documentation of the Apache config file. If you are not using Apache, but are using some other web server hosting, e.g. nginx or IIS, they have their own respective config files to use.
     
  43. CodeInMotion

    CodeInMotion

    Joined:
    Jun 1, 2018
    Posts:
    10
    yes, i am using Apache. i managed to find the file. adding said code to it crashes the server.

    is there a way to get live help? I am on a deadline. my game works perfecly in unity. Pc build works fine. but i dont know what's wrong with the web build. tried 20+ different things
     
  44. Boudewijn

    Boudewijn

    Joined:
    Mar 23, 2016
    Posts:
    15
    My webgl build works fine in Chrome and Edge but not in Firefox: "both async and sync fetching of the wasm failed".
    I use brotli compression without decompression fallback.
    Is this a known issue in Firefox? Is there any solution?

    In every browser I get the message: falling back to ArrayBuffer instantiation and Incorrect response MIME type. Expected 'application/wasm'.

    This is the .htaccess:
    <IfModule mod_mime.c>
    # The following lines are required for builds without decompression fallback, compressed with Brotli
    RemoveType .br
    RemoveLanguage .br
    AddEncoding br .br
    AddType application/octet-stream .data.br
    AddType application/wasm .wasm.br
    AddType application/javascript .js.br
    AddType application/octet-stream .symbols.json.br
     
  45. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    397
    xTheTimeSte and Boudewijn like this.
  46. unity_3dvoov

    unity_3dvoov

    Joined:
    Sep 27, 2021
    Posts:
    1
    completely delete unity and reinstall it
     
  47. Boudewijn

    Boudewijn

    Joined:
    Mar 23, 2016
    Posts:
    15
  48. ThmCuong

    ThmCuong

    Joined:
    Nov 27, 2018
    Posts:
    3
    I got this problem. And i turn on Compression format to Gzip, turn off data checking and decompression fallback solve it. Screenshot 2021-10-13 102737.png
     
  49. dahiyabunty1

    dahiyabunty1

    Joined:
    Jan 22, 2020
    Posts:
    68
    i check the structure of my website/server folder and found that my "GAME.DATA" & "GAME.WASM" are outside of the directory i.e. root...
    Then I copy back them both to the Build Folder and game works like charge.....
     
  50. Amar1312

    Amar1312

    Joined:
    Sep 19, 2018
    Posts:
    2
    After trying everything.Finally work for me , by following below step

    1.Unity -> Player Setting -> Publish Setting -> Compression Format -> Disable
    2.Unity -> Player Setting -> Publish Setting -> Decompression Callback -> On
    3.After making build , go to the build folder
    create two file
    1. .htaccess - copy code from here -> https://docs.unity3d.com/Manual/webgl-server-configuration-code-samples.html
    2 web.config - copy code from here -> https://docs.unity3d.com/Manual/webgl-server-configuration-code-samples.html

    error disappear
     
    ijusan, IndigoGorki and AlexGamzG like this.