Search Unity

Bug Unity WebGL poor rendering performance on iOS 16.x safari

Discussion in 'Web' started by OceanX000, Feb 11, 2023.

  1. OceanX000

    OceanX000

    Joined:
    Feb 24, 2021
    Posts:
    120
    We test a rendered scene without much computational logic. In iPhone13 (iOS 16.2) iPhoneX (16.3) safari, it can be seen that the frame rate is very low, only 12 fps. Demo: https://www.oooceanworld.com/testgame/rendercase1

    After repeated attempts, the frame rate will be increased several times(fps12-->60!!) by disabling the WebGL on Metal option of safari.

    1. Use safari to remote attach and look at the timeline, you can see that it takes 100ms+ from requestAnimationFrame request to actual execution (such as frame269)
    upload_2023-2-11_15-45-17.png

    2. Using the Instrument activity monitor, you can see that the usage of the GPU process is significantly higher, and it will be less than 5% when disabled WebGL via metal
    upload_2023-2-11_15-48-25.png

    3. Use the Instrument Metal System Trace tool to detect the GPU process, and you can see that the data between the two is very different. Enable WebGL on Metal

    upload_2023-2-11_15-42-21.png

    upload_2023-2-11_15-43-23.png
     
    MisfitXXX likes this.
  2. OceanX000

    OceanX000

    Joined:
    Feb 24, 2021
    Posts:
    120
    Looks like it has something to do with iOS "WebGL Via Metal", any info on that? @brendanduncan_u3d
     
  3. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    437
  4. OceanX000

    OceanX000

    Joined:
    Feb 24, 2021
    Posts:
    120
    That issue seems to be related to "too many uniforms". How to confirm what is the cause of my case? Is there any more accurate means of webkit analysis or workaround solution from the game logic?
     
  5. OceanX000

    OceanX000

    Joined:
    Feb 24, 2021
    Posts:
    120
    @brendanduncan_u3d, The safari rendering of Unity games on iOS/macOS still has serious performance problems. When WebGL Via Metal is turned on and off, there is a clear gap. I submitted an issue to webkit, can you help me find the reason?

    255987 – [ANGLE] Poor game render performence when enable "WebGL Via Metal" (webkit.org)
     
  6. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    437
    @OceanX000 I know Apple has been slowly working on fixing a major issue with larger uniform buffers causing WebGL Metal to come to a crawl because of the way they translated WebGL buffers to the buffer packing needed for Metal. I believe they have it solved now, or mostly solved. But the other problem with Apple is that even when they have it solved in the Webkit source, it takes an undefined amount of time for those fixes to roll into the release builds that go out into iOS updates. So we are completely at their mercy, and it's awful.
     
    unityruba likes this.
  7. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    356
    This is 10000% a massive issue. My game runs perfect on windows/chrome. Its absolutely garbage on macos and is a small game.
     
  8. OceanX000

    OceanX000

    Joined:
    Feb 24, 2021
    Posts:
    120
    255987 – REGRESSION (iOS 15.4): Poor game render performance with "WebGL via Metal" (webkit.org)
    @brendanduncan_u3d, From the development reply of Apple's webkit, this performance problem seems to be a bit complicated? It will involve several dependent issues
     
  9. fxlange

    fxlange

    Joined:
    Dec 20, 2016
    Posts:
    45
    In our case the metal backend for webgl siltently crashes/restarts our application after a short time running. So I'm assuming the fixed bug mentioned above still didn't hit latest safari? I'm on ios 16.5