Bug 218949 - WebGL instanced draw calls are very slow on iPhone 12 Pro
Summary: WebGL instanced draw calls are very slow on iPhone 12 Pro
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: Safari 14
Hardware: iPhone / iPad Other
: P2 Major
Assignee: Kimmo Kinnunen
URL:
Keywords: InRadar
Depends on: 220896
Blocks: webgl2perfproblem
  Show dependency treegraph
 
Reported: 2020-11-14 18:44 PST by Akihiko Kusanagi
Modified: 2021-09-20 22:05 PDT (History)
16 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Akihiko Kusanagi 2020-11-14 18:44:02 PST
WebGL instanced draw calls are very slow in any browser on iPhone 12 Pro. There is no performance issue in the same browser/OS versions on my old iPhone 8 Plus. Initially I noticed this in deck.gl code, but later realized that this issue is not deck.gl specific as a simple three.js program that uses instanced draw calls has the same issue.

How to reproduce:
- Instancing example (https://cdn.rawgit.com/pailhead/three.js/instancing-part2/examples/webgl_interactive_cubes.html) in this article: https://medium.com/@pailhead011/instancing-with-three-js-part-2-3be34ae83c57
- Deck.gl examples (GeoJsonLayer(Polygons), GeoJsonLayer(Paths), ...) in this page: https://deck.gl/examples

Environment:
- Browser: Safari 14, Chrome (for iOS) 86.0.4240.93 and FireFox (for iOS) 29.1
- OS: iOS 14.1 and 14.2
- Device: iPhone 12 Pro
Comment 1 Radar WebKit Bug Importer 2020-11-14 21:25:20 PST
<rdar://problem/71408222>
Comment 2 Kenneth Russell 2020-11-16 14:20:43 PST
Hmm, that's interesting. Certainly unrelated, but coincidentally, there was an instancing performance regression in Qualcomm's Adreno driver in Android R: http://crbug.com/1123700 . It was fixed in a subsequent driver release.

Kimmo or Dean, can either of you confirm whether this is a regression from the switch to ANGLE? Or is it hardware-specific and unrelated to ANGLE?
Comment 3 Kimmo Kinnunen 2020-11-16 23:52:16 PST
Thanks for the report!

https://threejs.org/examples/webgl_interactive_cubes.html
iPhone Xr iOS 14.2 60fps
iPhone 12 iOS 14.2 18fps

It appears to be HW-specific regression.
Comment 4 Kenneth Russell 2020-11-17 10:53:37 PST
Thanks for confirming Kimmo. Can this performance regression be reported to Apple's OpenGL ES driver team?

Raising to Major severity - in recent years most WebGL applications have transitioned to using instanced draw calls to achieve better scaling, and this regression will adversely affect the entire ecosystem.

Kimmo, could you perhaps track progress of this report through Apple's internal bug tracker?
Comment 5 Akihiko Kusanagi 2020-12-09 08:46:04 PST
Is there any update on this issue?
Comment 6 Toni Martí 2021-02-02 04:28:44 PST
Ping! How it's going with this issue?
Comment 7 Akihiko Kusanagi 2021-02-12 01:42:36 PST
I still see this regression on iOS 14.4.
Comment 8 Akihiko Kusanagi 2021-02-27 19:46:36 PST
This performance regression is seen on all A14 Bionic devices.
Comment 9 Marcin 2021-03-17 09:57:13 PDT
I can't reproduce it on iPad Air 2020 (A14 Bionic) with iPadOS 14.4.1

Repro case https://threejs.org/examples/webgl_interactive_cubes.html runs easily at 60fps
Comment 10 Akihiko Kusanagi 2021-03-18 00:50:10 PDT
> I can't reproduce it on iPad Air 2020 (A14 Bionic) with iPadOS 14.4.1
>
> Repro case https://threejs.org/examples/webgl_interactive_cubes.html runs easily at 60fps

It's the original three.js example which runs with no problem. I see a performance regression in https://cdn.rawgit.com/pailhead/three.js/instancing-part2/examples/webgl_interactive_cubes.html, the instancing version of it.
Comment 11 Marcin 2021-03-18 02:05:37 PDT
Confirmed, https://cdn.rawgit.com/pailhead/three.js/instancing-part2/examples/webgl_interactive_cubes.html
runs 18fps on iPad Air 2020, iPadOS 14.4.1
Comment 12 Gary Herman 2021-04-01 06:42:29 PDT
We are also seeing significant performance issues in our WebGL application at https://human.biodigital.com on these devices.  Has Apple acknowledged this issue? As more people get iPhone 12 we are seeing an increase in the number of complaints from our users.
Comment 14 Kimmo Kinnunen 2021-04-13 03:27:39 PDT
The enablement of ANGLE Metal backend on iPhone seems to fix the immediate performance issue here.
Comment 15 Kenneth Russell 2021-04-13 12:12:13 PDT
To the reporters: we're collaborating as quickly as possible to shake out the bugs from ANGLE's Metal backend that Apple's made tremendous improvements to. That sounds like it will be the fastest resolution to this device-specific performance issue.
Comment 16 Lasse Laakkonen 2021-04-15 04:22:26 PDT
This https://cdn.rawgit.com/pailhead/three.js/instancing-part2/examples/webgl_interactive_cubes.html should probably not be used for any testing, it seems to be running ThreeJS revision "97dev" from 2018: https://github.com/mrdoob/three.js/releases?after=r98

Also:

Assuming that the issue is on all devices with A14 Bionic chips.

1. Since Kimmo was able to reproduce the issue on 2020-11-16 in https://threejs.org/examples/webgl_interactive_cubes.html using an iPhone 12 and now the issue can not be reproduced on that page with a iPad Air 4th gen 2020, it would mean that issue would have been fixed in Three.js?

2. Since for example all of these work at FPS 60 on an iPad Air 4th gen 2020, Three.js has fixed / worked around the issue somehow?

  - https://threejs.org/examples/webgl_interactive_cubes.html
  - https://threejs.org/examples/#webgl_instancing_dynamic
  - https://threejs.org/examples/#webgl_instancing_performance
  - https://threejs.org/examples/#webgl_instancing_raycast
  - https://threejs.org/examples/#webgl_instancing_scatter
Comment 17 Akihiko Kusanagi 2021-04-15 06:35:41 PDT
I replaced three.js in https://cdn.rawgit.com/pailhead/three.js/instancing-part2/examples/webgl_interactive_cubes.html with the latest version (r127), but FPS is still around 18. See the codepen:
https://codepen.io/nagixx/full/RwKJRQy
Comment 18 Steven Briscoe 2021-05-20 04:15:32 PDT
Is there any movement on this issue? I'm facing this same issue and we have customers complaining due to the performance being really bad. All other iOS devices seem unaffected but the iPhone 12 seems particularly bad.

This seems to be the same issue here: https://github.com/visgl/deck.gl/issues/5101

Appreciate the help!
Steve
Comment 19 Steven Briscoe 2021-05-20 04:21:31 PDT
(In reply to Steven Briscoe from comment #18)
> Is there any movement on this issue? I'm facing this same issue and we have
> customers complaining due to the performance being really bad. All other iOS
> devices seem unaffected but the iPhone 12 seems particularly bad.
> 
> This seems to be the same issue here:
> https://github.com/visgl/deck.gl/issues/5101
> 
> Appreciate the help!
> Steve

Quick edit: I've also been told that iOS 14.6 does not address this issue.
Comment 20 Frank Sculli 2021-06-10 14:53:18 PDT
Following up on Steve's comment above, as more people have the iPhone 12 we are now receiving a ton of complaints.

Is it possible to provide some insight into the status of this fix? Much appreciated!
Comment 21 Akihiko Kusanagi 2021-09-20 22:05:20 PDT
Today I updated my iPhone 12 Pro to iOS 15, and I confirmed that this instancing performance issue was fixed! At least, my application and deck.gl examples all work smoothly, so I set this bug to RESOLVED.