Poor performance of WebGL 2.0 on iOS 15?

  1. Unity2021.3.5 create a default URP project
  2. Use High for the Graphic quality of H5
  3. PlayerSettings select WebGL2
  4. Tested on iOS 15.6, iPhone13 found that the frame rate is only 10 fps.
  5. Use safari inspector to find the bottleneck in drawElements?
    Sorted by Self Time:

Sorted by Call Trees:

The sample scene probably isn’t a good testbed for mobile performance. You may want to check if there are any post-processing effects (I think Bloom is enabled which is pretty heavy for mobile) and disable them so you just get the geometry performance.

Anyway, don’t expect WebGL to perform well on mobile, at least not anywhere close to the same content in a native app. While you’re at it, this is something you could try: make a regular iOS build for comparison. Then you have a performance baseline to see what would be possible, and how much WebGL performance sucks.

Sorry, but its true. :smile:

2 Likes

I found that UniversalRP-LowQuality has no performance problem, the problem only exists in Mid and High.
By comparing the three configurations one by one, it is found that Lighting-Additional Lights will greatly affect the performance. On the iPhone 13, if PerPixel is selected, the frame rate will drop to 10fps. And PerVertex can reach 60fps.

Modifed UniversalRP-MediumQuality to find the difference.
It’s OK:

Poor Performence:

So what causes such a problem? Why is “drawElements”?

1 Like

“drawElements” is the draw call submitted to WebGL, so the performance issue is in the WebGL browser implementation. There is a known issue with the Metal backend of WebGL, which iOS 15 is using, that causes performance issues. It’s related to shaders and uniform buffers. Apple and Google are working on it.

1 Like

But why wouldn’t have such a problem using PerVertex?

An equivalent scene in WebGL that doesn’t use uniform buffers gets to 60FPS, whereas the Unity one only reaches 6-10FPS. I think it’s a bug - mobile GPUs have their limitations (they generally hate fullscreen effects) but they’re plenty fast enough for many things.

@TLuthDidimo I’m guessing this is probably the known Apple WebGL bug on iOS where larger uniform buffers can cause drastic performance issues. Apple and Google have been working on a solution, but it’s taking them a long time because they’ve had limited resources. I certainly hope they can get to it soon.

“Apple and Google have limited resources”

LOL

They might have limited resources allocated to this thing in particular, of course.

Anyway, problem still persists today on Unity 2022.2.9.
I’m unable to reach even 30fps on Apple devices.