Search Unity

Question WebGL build of URP project not rendering properly in Chrome/Safari on Mac and iOS

Discussion in 'Web' started by therealmattkain, May 4, 2023.

  1. therealmattkain

    therealmattkain

    Joined:
    Oct 27, 2013
    Posts:
    7
    Hi! I have an existing project that I updated to use the URP in Unity 2021.3.23f1. For the most part, I started with the SampleScene in the Unity Hub URP template and just added my existing scene content. I didn't add additional lighting or post-processing effects or anything new. I then made a WebGL 2.0 build and tested it in browsers. It works fine on Windows machines in Chrome and Firefox. However, on both iOS 15.6.1 and macOS 13.3.1 the WebGL build does not properly render in either Chrome or Safari. There are strange black lines and render patterns across many of the surfaces.


    I then tried making a brand new 3D URP project using the Unity Hub template. I added 9 cubes to the SampleScene that each use the URP Lit shader and made no other additions or changes to the project (other than removing WebGL 1.0 and Brotli compression from the build settings). I see the same problem when I run this in Chrome or Safari on macOS or iOS. I see strange black patterns on the cube surfaces.


    Here is the above running on my site where I see the render issues on Mac and iOS:
    https://team2bit.com/test/

    Am I missing something obvious? Should a WebGL build of a simple URP project run properly on macOS and iOS? Or is there some initial setting that I need to modify or change? I'm kind of shocked that this doesn't work out of the box. Have other got this to work? Is it potentially tied to my Unity version? Any help is greatly appreciated!

    thanks!
    Matt
     
    Last edited: May 4, 2023
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,847
    There have been reports about this distortion issues with Safari and in particular with the new M1 macs. If there was a solution it should be in one of the threads in this forum. I vaguely remember something about changing some setting but it may just have been a recommendation, not a fix.

    It may just be one of those Apple+WebGL issues which I attribute to Apple possibly deliberately deprioritizing WebGL because it is threatening their walled garden business.

    One thing I would strongly recommend with WebGL is to try out 2022.2 and even 2023.1 beta given that you already have a test project. Because WebGL tech is frequently undertaking under the hood improvements.
     
    Stormer2020 likes this.
  3. therealmattkain

    therealmattkain

    Joined:
    Oct 27, 2013
    Posts:
    7
    I was able to revert to a non-URP project, import the post-processing effects package, set up the same post-processing features, export a WebGL build and it ran properly in Safari and Chrome on a Mac and on iOS. It seems to be tied to the URP or some default setting that is part of the Unity Hub template.

    I'll likely try 2022 and 2023 at some point, but for now it looks like the URP just isn't "universal" enough to meet our project needs. I hate reverting to old ways of doing things, but we need this project to run in a browser.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,847
    You found one solution but that doesn‘t mean it‘s the only one. And it‘s a pretty grim one because it‘ll be far less performant. Unless you are hard pressed for time I‘d play with some of the urp, graphics, quality, player and specifically lightmap/shadow settings to see if there‘s an easier workaround.

    And let‘s not forget, Apple has a long history of undersupporting WebGL and taking an unfair amount of time to fix issues on their end. And also this post. That same thread has a number of tips and potential workarounds you could try.
     
  5. therealmattkain

    therealmattkain

    Joined:
    Oct 27, 2013
    Posts:
    7
    Thanks again for the tips. I appreciate it. I'll try some of your ideas before deciding to revert the project.
     
  6. NMsnipeshoot

    NMsnipeshoot

    Joined:
    Feb 21, 2023
    Posts:
    1
  7. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    128
    Hey, I bumped into the same issue. Did you manage to solve it?
     
  8. josefgrunig

    josefgrunig

    Joined:
    Jan 23, 2017
    Posts:
    62
  9. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    128
    What solved it for me (2023.1.10 / Mac M1 / Safari 16.6) is setting URP's Depth Priming Mode to auto / disabled.
     
    Pouletepicer and josefgrunig like this.
  10. josefgrunig

    josefgrunig

    Joined:
    Jan 23, 2017
    Posts:
    62
    Thank you very much @WildMaN,
    I confirm that this solves the rendering issue. I will update the information on the Issue Tracker, too.
    Thank you!