Bug 229136

Summary: Canvas artifacts and system instability (including kernel panics) when drawing to a canvas
Product: WebKit Reporter: george.pomas
Component: CanvasAssignee: Nobody <webkit-unassigned>
Severity: Normal CC: boogywoogy1234, dino, mmaxfield, sabouhallawa, simon.fraser
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: Mac (Intel)   
OS: Unspecified   
Description Flags
It seems I can only attach one file, but there are: video of bug, test file for reproduction and two screens of kernel panic.
this one was made when whole system was messed up
lightweight test case none

Description george.pomas 2021-08-16 06:44:43 PDT
Created attachment 435593 [details]
It seems I can only attach one file, but there are: video of bug, test file for reproduction and two screens of kernel panic.

Hello! We have encountered a bug in Safari, we found a Canvas scene, that was causing Safari to produce various glitches: Canvas Rendering with artefacts, Canvas blinking, DOM elements not rendering, system unresponsiveness for brief periods (about 6 seconds on average), apps not responding, permanent system unresponsiveness, black screen and sometimes even a kernel panic. Page reload does not help in this case, once bug has occur - the page is bugged even after reload.
We tested this scene on MacBook Pro (16-inch, 2019) on OS Catalina 10.15.7 (19H1217) and Big Sur 11.4 (20F71). This bug seems to be able to reproduce only on Intel UHD card, which is default on Big Sur, but requires “sudo pmset -c gpuswitch 0” on Catalina.

We have created an isolated test file, run it with caution. This HTML file contains images and two sets of Canvas API calls (snapshot of a real scene), that cause the bug. We tried to strip it as much as possible, but I believe there is still a room for improvement. Also this scene turned out to be quite jerky, so SEIZURE WARNING. Without some sort of movement the bug seems fail to reproduce for us.

We want to ask to share any knowledge about possible workarounds, so we could use it before your fix is released, so please, let us know!
Comment 1 Simon Fraser (smfr) 2021-08-16 16:48:11 PDT
The test case uses 2D canvas, not WebGL.
Comment 2 Radar WebKit Bug Importer 2021-08-16 16:48:42 PDT
Comment 3 Anton Kuliapin 2021-08-23 01:50:16 PDT
Hi all! Any updates on this one pls?
Comment 4 Said Abou-Hallawa 2021-08-30 15:28:08 PDT
I can't reproduce this bug on macOS Big Sur or macOS Monterey with system or trunk WebKit. Can you please try to get a sysdiagnose from your system once the bug happens?  You can do this by pressing: shift + ctrl + option + command (⌘) + . the system will flash and the sysdiagnose will be generated after a few minutes.
Comment 5 george.pomas 2021-09-06 22:03:00 PDT
Created attachment 437451 [details]
Comment 6 george.pomas 2021-09-08 01:43:36 PDT
Created attachment 437613 [details]
this one was made when whole system was messed up
Comment 7 george.pomas 2021-09-08 02:42:17 PDT
Created attachment 437615 [details]
lightweight test case

We found out a really lightweight test case, you can try it if nothing works.
Comment 8 Myles C. Maxfield 2021-09-10 01:36:39 PDT
I can't reproduce this either on Monterey. The page is unresponsive for a few seconds, but it behaves that way in every browser. Being unresponsive for a few seconds is a reasonable result from just running a lot of javascript.
Comment 9 Myles C. Maxfield 2021-09-10 01:40:51 PDT
From looking at the content, this is almost certainly not a bug in WebKit, and is almost certainly a bug in a lower-level framework.
Comment 10 george.pomas 2021-09-13 05:22:16 PDT
Have you tried this on MacBook? I think this bug is hardware-dependant, we have reproduced it using Intel UHD Graphics 630 on our MacBook Pro. I agree, WebKit is probably not causing this bug directly, we have just found one way to reproduce this. Can you at least assist us in finding right people to report this? It's really weird that you cannot reproduce this. Latest test case causing all of Big Sur UI to literally melt after about 4-5 runs.
Comment 11 Myles C. Maxfield 2021-09-13 12:45:18 PDT
I just tried this on a Intel HD Graphics 630 1536 MB and after a few seconds the entire safari tab turns black, and the black persists even after clicking the "back" navigation button. I know that it did actually navigate back, though, because I had the web inspector open and it showed details of the previous page.
Comment 12 Myles C. Maxfield 2021-09-13 12:50:47 PDT
Because this is a bug in a lower-level framework, we're tracking this in rdar://82004473. I'll mark this WebKit bug as "moved."
Comment 13 george.pomas 2021-09-14 01:38:31 PDT
How can we see progress on this bug? You'll post here or we should look somewhere else?
Comment 14 Myles C. Maxfield 2021-09-14 14:12:28 PDT
On the same machine where I reproduced this problem before, I upgraded it to the latest beta of macOS Monterey (beta 6). I'm now no longer able to reproduce the problem.

Can you try on that OS and see if you're still seeing the problem?
Comment 15 george.pomas 2021-09-22 00:37:45 PDT
I have Monterey beta 12 installed on my Mac and turns out it actually did fix the issue. It's a great news! My only hope is for some kind of hotfix for Big Sur.