Unity WebGL poor rendering performance on iOS 16.x safari

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)

  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

  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

1 Like

Looks like it has something to do with iOS “WebGL Via Metal”, any info on that? @brendanduncan_u3d

I know Apple is slowly picking away at some long standing WebGL Metal performance issues and errors. We got this one fixed after a year, https://bugs.chromium.org/p/angleproject/issues/detail?id=7189#c11.The results of that fix should have a big impact on performance as well. Fingers crossed it gets out to iOS asap and improves these issues.

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?

@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)

@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.

1 Like

This is 10000% a massive issue. My game runs perfect on windows/chrome. Its absolutely garbage on macos and is a small game.

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

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