RESOLVED FIXED278454
CanvasRenderingContext2D globalAlpha property is ignored for some values of globalCompositeOperation
https://bugs.webkit.org/show_bug.cgi?id=278454
Summary CanvasRenderingContext2D globalAlpha property is ignored for some values of g...
Alf Eaton
Reported 2024-08-21 01:39:26 PDT
Created attachment 472255 [details] Screenshot of demo in Safari When drawing in a canvas, some values of globalCompositeOperation (source-in, source-out, destination-in, destination-atop) cause the current globalAlpha value to be ignored, which results in transparency being lost. This bug is preventing PDF.js from rendering soft masks in PDF images, when used in Safari (unlike both Chrome and Firefox, which handle this correctly). https://github.com/mozilla/pdf.js/issues/18634 A demonstration of all the globalCompositeOperation values: https://codepen.io/invisiblecomma/pen/poXLPaZ Minimal code to reproduce: const canvas = document.createElement("canvas"); canvas.width = "40"; canvas.height = "60"; document.body.append(canvas); const ctx = canvas.getContext("2d"); ctx.font = "50px Impact"; ctx.fillStyle = "#777777"; ctx.fillText("A", 10, 40); ctx.globalCompositeOperation = 'destination-atop'; ctx.globalAlpha = 0.5; ctx.fillStyle = "#ff0000"; ctx.fillText("B", 10, 60);
Attachments
Screenshot of demo in Safari (73.71 KB, image/png)
2024-08-21 01:39 PDT, Alf Eaton
no flags
rendering in safari, firefox, chrome (632.18 KB, image/png)
2024-08-22 00:59 PDT, Karl Dubost
no flags
test case (1.14 KB, text/html)
2024-08-28 16:30 PDT, Said Abou-Hallawa
no flags
Karl Dubost
Comment 1 2024-08-22 00:59:51 PDT
Created attachment 472262 [details] rendering in safari, firefox, chrome Safari Technology Preview 201 20620.1.2 Firefox Nightly 131.0a1 13124.8.19 Google Chrome Canary 130.0.6670.0 6670.0
Karl Dubost
Comment 2 2024-08-22 01:03:43 PDT
This is a duplicate of Bug 209802 *** This bug has been marked as a duplicate of bug 209802 ***
Karl Dubost
Comment 3 2024-08-22 17:40:53 PDT
I will reopen here. Alex noticed rightly that this is different. Bug 209802 is about performance.
Radar WebKit Bug Importer
Comment 4 2024-08-28 01:40:14 PDT
Said Abou-Hallawa
Comment 5 2024-08-28 12:15:13 PDT
Said Abou-Hallawa
Comment 6 2024-08-28 16:30:55 PDT
Created attachment 472336 [details] test case
EWS
Comment 7 2024-08-30 07:15:54 PDT
Committed 282965@main (40b19269f440): <https://commits.webkit.org/282965@main> Reviewed commits have been landed. Closing PR #32845 and removing active labels.
Said Abou-Hallawa
Comment 8 2024-08-30 12:04:17 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/47906
Said Abou-Hallawa
Comment 9 2024-08-30 15:32:14 PDT
EWS
Comment 10 2024-08-30 15:38:01 PDT
Committed 282996@main (1e29db507d16): <https://commits.webkit.org/282996@main> Reviewed commits have been landed. Closing PR #32966 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.