Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering issues when antialias is enabled with terrain in iOS devices with 15.4 and M1 Macs with latest Safari #11609

Closed
avpeery opened this issue Mar 15, 2022 · 5 comments · Fixed by #11615
Labels

Comments

@avpeery
Copy link
Contributor

avpeery commented Mar 15, 2022

mapbox-gl-js version: Latest on main branch

browser: Safari 15.4, FireFox and Chrome on iPhone 12 Pro with 15.4 iOS

Steps to Trigger Behavior

  1. Download iOS 15.4
  2. open debug/threejs-antenna.html
  3. Note immediate flickering of sky layer and severe performance issues with zooming or panning the map.

Expected Behavior

No severe rendering issues should be noted. No flickering. Tested also with iPhone 11 with 14.6 iOS and iPhone 12 with 15.1 iOS, and MacBook Pro with Monterey 12.3 and they did not exhibit any issues.

Actual Behavior

When tested with iOS 15.4 on iPhone 12 Pro, severe rendering issues were noted on this testing page. See screen recording.

RPReplay_Final1647370656.MP4
@avpeery avpeery added bug 🐞 performance ⚡ Speed, stability, CPU usage, memory usage, or power usage environment-specific 🖥️ 3d 📐 labels Mar 15, 2022
@avpeery avpeery changed the title Major performance issues with 3d model with threejs with iOS 15.4 Major performance issues with 3d model using threejs with iOS 15.4 Mar 15, 2022
@rreusser
Copy link
Contributor

rreusser commented Mar 16, 2022

Please note: this could all be a red herring; it's the flickering and glitchy rendering that really made me think it looks similar…

But for reference, here was a previous issue containing a very similar issue: #10372

Three.js and Mapbox both manage the same underlying global WebGL state, and both maintain their own representation of that state in order to minimize actual WebGL state changes. This means as soon as either of them modify WebGL state, the other's representation will be incorrect.

That's why this line resets threejs's representation of state:

this.renderer.state.reset();

and why this line sets Mapbox's representation to dirty after custom content is rendered:

context.setDirty();

The result of the above was this PR which added a couple state resets which were missing: https://github.com/mapbox/mapbox-gl-js/pull/10412/files

I haven't tracked down a current reproduction of the above issue, but I just wanted to get some references linked since it looks quite similar. Didn't Safari switch their WebGL back end to metal recently-ish? Maybe that exposed (or introduced) a faulty assumption about default state values when transitioning back and forth between Three.js's and Mapbox's state management.

I think @karimnaaji is pretty skilled with the spector.js debugger. Maybe it's possible to inspect exactly what the state is when custom layer draw happens? I'd also try disabling the sky, as I recall that might have triggered a particular state change which exposed the linked bug.

@SnailBones
Copy link
Contributor

SnailBones commented Mar 16, 2022

Can this issue be fixed by disabling "WebGL via Metal"?

Similar issue in three.js here: mrdoob/three.js#23733

@ryanhamley
Copy link
Contributor

To keep everything in one place, here's the Webkit bug we filed and here's the JSBin example of the issue.

@ansis ansis changed the title Major performance issues with 3d model using threejs with iOS 15.4 Major rendering issues with 3d model using threejs with iOS 15.4 Mar 16, 2022
@avpeery
Copy link
Contributor Author

avpeery commented Mar 17, 2022

Update: This issue seems to be resolved when disabling antialiasing, and is most present when antialiasing is enabled with terrain. Occurs with iOS devices and M1 with 15.4

@avpeery avpeery changed the title Major rendering issues with 3d model using threejs with iOS 15.4 Rendering issues when antialias is enabled with terrain in iOS devices with 15.4 and M1 Macs with latest Safari Mar 18, 2022
@avpeery
Copy link
Contributor Author

avpeery commented May 26, 2022

Confirmed this issue is resolved in the latest 15.5 Safari release. https://bugs.webkit.org/show_bug.cgi?id=237918#c10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants