RESOLVED FIXED259306
REGRESSION (Safari 17 beta): WebGL contexts drawn into canvas contexts are upside-down when premultipliedAlpha is false
https://bugs.webkit.org/show_bug.cgi?id=259306
Summary REGRESSION (Safari 17 beta): WebGL contexts drawn into canvas contexts are up...
Paul Neave
Reported 2023-07-18 06:16:10 PDT
Created attachment 467067 [details] Demo of Safari 17 upside-down webgl-canvas bug In Safari 17 (Mac TP and iOS 17 beta), when drawing a WebGL1 context into a 2D canvas context, pixels are flipped in the y-axis (upside-down) when 'premultipliedAlpha' is set to false. Please view the attachment in Safari 16 (or any other browser) and compare to Safari 17. The first rectangle is the WebGL canvas. The second rectangle is the 2D canvas. In Safari 17, the second image appears upside-down. This only occurs when premultipliedAlpha is set to false.
Attachments
Demo of Safari 17 upside-down webgl-canvas bug (2.50 KB, text/html)
2023-07-18 06:16 PDT, Paul Neave
no flags
Radar WebKit Bug Importer
Comment 1 2023-07-18 08:49:11 PDT
Dean Jackson
Comment 2 2023-07-18 17:35:53 PDT
Ouch!
Dean Jackson
Comment 3 2023-07-19 12:45:30 PDT
Note that the comments in the test case are slightly wrong. // 2D canvas is rendered upside-down if premultipliedAlpha is set to true above This should be "is set to false above". The description in this report is correct though. When premultipliedAlpha is false (not the default value), the render from GL into 2D is upside down.
Dean Jackson
Comment 4 2023-07-19 12:53:25 PDT
Copying from the internal analysis: https://commits.webkit.org/262518@main seems to be the cause. And I assume it is the call to `readCompositedResults()` or `paintRenderingResultsToPixelBuffer()` that produces a NativeImage that is a different orientation to the one we'd get otherwise. They are always flipped when rendering into the 2D canvas.
Paul Neave
Comment 5 2023-07-20 02:20:45 PDT
(In reply to Dean Jackson from comment #3) > Note that the comments in the test case are slightly wrong. > > // 2D canvas is rendered upside-down if premultipliedAlpha is set to true > above > > This should be "is set to false above". > > The description in this report is correct though. When premultipliedAlpha is > false (not the default value), the render from GL into 2D is upside down. Thanks Dean, yes that's correct - that was a typo.
Dan Glastonbury
Comment 6 2023-07-20 22:07:16 PDT
EWS
Comment 7 2023-07-21 20:43:40 PDT
Committed 266225@main (ae8167890120): <https://commits.webkit.org/266225@main> Reviewed commits have been landed. Closing PR #15970 and removing active labels.
Patrick Martin
Comment 8 2023-09-01 16:05:58 PDT
This may also be happening with WebGL 1 & OffscreenCanvas.toImageBitmap and bitmaprendererer contexts. I need to double check, but I'm definitely getting similar behavior with my library that uses that method.
Paul Neave
Comment 9 2023-09-02 12:45:52 PDT
(In reply to Patrick Martin from comment #8) > This may also be happening with WebGL 1 & OffscreenCanvas.toImageBitmap and > bitmaprendererer contexts. I need to double check, but I'm definitely > getting similar behavior with my library that uses that method. Oh no! Can you create a simple example to demonstrate this? It might be worth submitting a new bug report as this bug is regarding premultipliedAlpha, which is now fixed.
Patrick Martin
Comment 10 2023-09-02 16:59:09 PDT
(In reply to Paul Neave from comment #9) > (In reply to Patrick Martin from comment #8) > > This may also be happening with WebGL 1 & OffscreenCanvas.toImageBitmap and > > bitmaprendererer contexts. I need to double check, but I'm definitely > > getting similar behavior with my library that uses that method. > > Oh no! Can you create a simple example to demonstrate this? It might be > worth submitting a new bug report as this bug is regarding > premultipliedAlpha, which is now fixed. Bug 261069 has been submitted for that issue.
Note You need to log in before you can comment on or make changes to this bug.