Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

WebGL builds throwing errors on Safari (macOS Catalina)

Discussion in 'WebGL' started by InteractivaStudios, Jun 20, 2020.

  1. InteractivaStudios

    InteractivaStudios

    Joined:
    Apr 28, 2013
    Posts:
    19
    Hi all,

    I haven't been able to get WebGL builds to work on Safari (on the latest version of macOS Catalina), it always reloads or throws an error once it finishes loading. I've tried it in another Mac, and I can get it to work for a bit until the webpage reloads because "an error occurred." It seems to be arbitrary as different things happen in different systems and different times.

    The error I sometimes get:
    TypeError: Argument 1 ('sync') to WebGL2RenderingContext.clientWaitSync must be an instance of WebGLSync

    This only happens on Safari, all other browsers work flawlessly. I made sure to tick "auto graphics API", so that WebGL 1.1 is used on Safari, since 2.0 is troublesome, but to no avail. I'm using Unity 2019.3.5.

    Here are the builds, if you could try them on Safari and report back with the results, I'd be immensely grateful.

    https://interactiva-studios.com/en/portfolio/umass-virtual-tour/

    https://interactiva-studios.com/en/portfolio/interactiva-museum-of-fine-arts/

    Any insight is appreciated.
     
    Last edited: Jun 20, 2020
  2. wuannetraam

    wuannetraam

    Joined:
    Oct 29, 2019
    Posts:
    87
    Hi,

    We've had all these problems a while back and luckily were able to fix it. Safari is really a game break tho for webgl. Your stuck to WebGL 1.0. To get this to work you should turn off Auto Graphics API and then you need to remove Webgl2.0 and only leave Webgl1.0 in it. That would fix the webgl error. Another problem that can occur is with ASM.js and WASM.js. Safari gives errors with WASM so you need to make sure that you set your project to ASM.

    The way to do this:
    Go to your project folder then go to ProjectSettings folder and open the file "ProjectSettings" in a text editor.
    Then search for "webGLLinkerTarget:" It's probarly set to "1" (WASM). Make sure to change that to "0" (ASM).
    That should fix your next problem.

    Also make sure your "webGLMemorySize:" is set to something like 128mb

    Hope this helps. It took me weeks to fix this.

    Best,
    Maarten
     
    InteractivaStudios likes this.
  3. InteractivaStudios

    InteractivaStudios

    Joined:
    Apr 28, 2013
    Posts:
    19
    Thank you! I'll try it and report back tomorrow. This sounds like such an obscure workaround, you'd think Unity would've nailed this by now. I sure would've never guessed it. Much appreciated!

     
  4. InteractivaStudios

    InteractivaStudios

    Joined:
    Apr 28, 2013
    Posts:
    19
    Thank you! This mostly solved the problem.

    Quick update: Changing the linker target to ASM instead WASM fixed it with Safari, now it loads without issues. However, performance is reduced considerably, both loading, memory usage, and playing (we get lag spikes with the ASM build)--What I resorted to doing, for now, was to use conditional logic in the webpage, display the ASM build only of Safari browsers, and use the regular WASM on non safari browsers.

    Any idea of whether Safari will fully support WASM without issues in the future?
     
  5. attishno1

    attishno1

    Joined:
    Dec 6, 2016
    Posts:
    18
    Please tell me how did you use the conditional logic. Thank you.