Bug 227408

Summary: [macOS] WebGL content is unable to use the discrete GPU
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: ANGLEAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, ews-watchlist, giuseppesalvo, kbr, kkinnunen, kondapallykalyan, pontus, supermoos, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.chromium.org/p/angleproject/issues/detail?id=6105
https://bugs.webkit.org/show_bug.cgi?id=220843
https://bugs.webkit.org/show_bug.cgi?id=231012
https://bugs.webkit.org/show_bug.cgi?id=231946
Bug Depends on:    
Bug Blocks: 228298    
Attachments:
Description Flags
Patch none

Description Myles C. Maxfield 2021-06-25 15:52:47 PDT
[macOS] WebGL content is unable to use the discrete GPU
Comment 1 Myles C. Maxfield 2021-06-25 16:00:10 PDT
Created attachment 432301 [details]
Patch
Comment 2 EWS Watchlist 2021-06-25 16:01:25 PDT
Note that there are important steps to take when updating ANGLE. See https://trac.webkit.org/wiki/UpdatingANGLE
Comment 3 Myles C. Maxfield 2021-06-25 16:03:26 PDT
<rdar://problem/79216506>
Comment 4 EWS 2021-06-25 17:39:29 PDT
Committed r279303 (239179@main): <https://commits.webkit.org/239179@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 432301 [details].
Comment 6 supermoos 2021-09-08 03:13:53 PDT
This bug has appeared again in Safari Techonology Preview either 130 or 131, it was confirmed fixed in 129 (I tested it in that version), https://webkit.org/blog/11951/release-notes-for-safari-technology-preview-129/

but now I'm seeing the same performance degradations in 131 as before 129. Note I've double checked my examples and they work fine in Safari 13 too, before the bug was introduced with safari 14.

Specific release where this is NOT fixed: Release 131 (Safari 15.0, WebKit 16612.2.2)
MacOS: 11.5.2 (20G95)
Comment 7 Myles C. Maxfield 2021-09-10 01:04:08 PDT
I'm not seeing the regression in Safari Technology Preview 131 on macOS Monterey.
Comment 8 Myles C. Maxfield 2021-09-10 01:07:50 PDT
Can you provide a specific URL or a sample webpage which shows the regression between STP 129 and 131?
Comment 9 supermoos 2021-09-10 02:44:30 PDT
Yes, sure, try this link: https://anygivenmonday.org/clients/webkit_bug/pixi/

Could it be because we're on different OS versions?

I'm testing the performance specifically in full width and height (not fullscreen, just the window resized to fill the screen) on an LG 5K display connected via thunderbolt 3. On another machine running safari 13 the above demo runs 60 fps also connected to the same screen, but in both safari technology preview 131 and safari 14 on my machine it runs around 18 fps and noticeably slows down the whole computer.

The renderer is initialised like this:

        this.app = new PIXI.Application({
            resizeTo: window,
            antialias: true,
            powerPreference: 'high-performance',
            width: window.innerWidth, height: window.innerHeight, backgroundColor: 0xFEF7EF, resolution: window.devicePixelRatio || 1,
        });
Comment 10 supermoos 2021-09-10 02:51:11 PDT
Let me know if you wan't more info or a screenshare, I've confirmed the same issue on a colleagues computer. He runs Big Sur 11.4 and latest technology preview. The issue becomes very apparent when running on a 5K screen, on smaller resolutions you might not be able to pick up on the performance dip from not being able to access the discrete GPU.
Comment 11 Myles C. Maxfield 2021-09-10 14:56:33 PDT
I'll install 20G95 on my laptop to see if I can reproduce this.
Comment 12 Myles C. Maxfield 2021-09-10 17:40:37 PDT
I can reproduce the performance degradation on 20G95. I'm not sure whether it's because the wrong GPU is being selected though. I'll investigate further.
Comment 13 Myles C. Maxfield 2021-09-10 22:14:39 PDT
The performance degradation was fixed in https://trac.webkit.org/changeset/281245/webkit.
Comment 14 supermoos 2021-09-21 06:59:31 PDT
So this bug is NOT fixed in the recent public release of Safari 15 for macOS Big sur?
I'm still seeing bad performance on this link in Version 15.0 (16612.1.29.41.4, 16612): 
https://anygivenmonday.org/clients/webkit_bug/pixi/

Any word on when this might be publicly fixed?
Comment 15 supermoos 2021-09-29 05:20:04 PDT
I'm sorry if this comes off as pushy, however I'm really only trying to gauge whether this problem may have actually re-appeared, as I can't confirm it being fixed in neither the latest technology Release 132 (Safari 15.4, WebKit 16613.1.1.5) nor the publci release of safari 15: Version 15.0 (16612.1.29.41.4, 16612)
Comment 16 Giuseppe 2021-09-30 07:19:56 PDT
I can confirm that the bug presented itself again in the latest public release of Safari 15 and Safari tech preview 132.

The demo posted by supermoos is still good to expose the issue.

I can't confirm if the bug is present when using Monterey, but it's present on Big Sur 11.6.

Any updates on the issue?
Comment 17 Kimmo Kinnunen 2021-09-30 10:06:26 PDT
Thanks for the tests. I'll investigate more if there additional regressions.
Comment 18 Giuseppe 2022-05-16 12:31:26 PDT
hey there, I was testing the new Safari 15.5 and I believe this bug presented itself again in Safari 15.5.

The demo posted by supermoos is still valid: https://anygivenmonday.org/clients/webkit_bug/pixi/

One way to validate the issue is: 
1. Open the demo on Safari 15.5
2. The demo animation doesn't look very smooth
3. Open the demo in Chrome, which triggers the use of the discrete GPU
4. Keep Chrome in background and now look at Safari
5. The animation now should be smooth on Safari too, because they discrete GPU is in use, triggered by Chrome

Additional info: I'm on macOS 12.4.
Comment 19 Giuseppe 2022-05-17 01:56:41 PDT
Adding a bit more info:
I'm on a macbook pro 16", i7, AMD Radeon Pro 5300M.

The issue happens only when using the laptop without an external display attached (Of course, because the external monitor triggers the use of the discrete GPU).