Search Unity

Bug Poor performance of WebGL 2.0 on iOS 15?

Discussion in 'Web' started by OceanX000, Jul 30, 2022.

  1. OceanX000

    OceanX000

    Joined:
    Feb 24, 2021
    Posts:
    120
    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:
    upload_2022-7-30_23-25-6.png

    Sorted by Call Trees:
    upload_2022-7-30_23-26-16.png

    upload_2022-7-30_23-23-31.png
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,849
    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. :D
     
    xiangshushu and kou-yeung like this.
  3. OceanX000

    OceanX000

    Joined:
    Feb 24, 2021
    Posts:
    120
    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:
    upload_2022-7-31_18-21-19.png

    Poor Performence:
    upload_2022-7-31_18-21-4.png

    So what causes such a problem? Why is "drawElements"?
     
    Last edited: Jul 31, 2022
    ppirner likes this.
  4. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    434
    "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.
     
    xiangshushu likes this.
  5. OceanX000

    OceanX000

    Joined:
    Feb 24, 2021
    Posts:
    120
    But why wouldn't have such a problem using PerVertex?
     
  6. TLuthDidimo

    TLuthDidimo

    Joined:
    Jul 11, 2021
    Posts:
    9
    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.
     
  7. brendanduncan_u3d

    brendanduncan_u3d

    Unity Technologies

    Joined:
    Jul 30, 2019
    Posts:
    434
    @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.
     
  8. richardNXRT

    richardNXRT

    Joined:
    Aug 4, 2022
    Posts:
    26
    "Apple and Google have limited resources"

    LOL
     
  9. MarcoSydea

    MarcoSydea

    Joined:
    Feb 3, 2023
    Posts:
    5
    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.