Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f2faeb01517c97a8ee551309aa97c3c9a4d7d271
      
https://github.com/WebKit/WebKit/commit/f2faeb01517c97a8ee551309aa97c3c9a4d7d271
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-08-23 (Sun, 23 Aug 2026)

  Changed paths:
    A 
LayoutTests/fast/canvas/canvas-noise-injection-transparent-dirty-rect-expected.txt
    A LayoutTests/fast/canvas/canvas-noise-injection-transparent-dirty-rect.html
    M Source/WebCore/html/CanvasNoiseInjection.cpp

  Log Message:
  -----------
  CanvasNoiseInjection dirty rect is never cleared when the dirty region is 
fully transparent
https://bugs.webkit.org/show_bug.cgi?id=322367
rdar://185653414

Reviewed by Gerald Squelart.

postProcessPixelBufferResults() only sets wasPixelBufferModified after the
`if (!alphaChannel) continue;` guard, so it returns false when every pixel in 
the
dirty rect is transparent. postProcessDirtyCanvasBuffer() gated both the
putPixelBuffer() write-back and the `m_postProcessDirtyRect = { }` reset on that
return value, so the dirty rect survived the readback. Nothing else clears it:
CanvasBase::didDraw() only calls clearDirtyRect() for a whole-canvas draw with
ShouldApplyPostProcessingToDirtyRect::No.

The stale rect makes every subsequent getImageData()/toDataURL()/toBlob() redo 
an
unpremultiplied RGBA8 getPixelBuffer() over it and throw the result away, and
leaves havePendingCanvasNoiseInjection() permanently true, forcing
drawImage(thatCanvas, ...) down the post-processing didDraw() path.

Skipping the write-back when nothing changed is still correct, so decouple the
two: reset the dirty rect once the pixel buffer has been processed, and only 
write
back when a pixel actually changed. The early returns for a missing image buffer
or a failed readback still preserve the rect.

Only reachable with a non-zero noise salt; salt 0 is the testing path and 
returns
true before the loop, which is why canvas-noise-injection.html misses this.

Test: fast/canvas/canvas-noise-injection-transparent-dirty-rect.html

* 
LayoutTests/fast/canvas/canvas-noise-injection-transparent-dirty-rect-expected.txt:
 Added.
* LayoutTests/fast/canvas/canvas-noise-injection-transparent-dirty-rect.html: 
Added.
* Source/WebCore/html/CanvasNoiseInjection.cpp:
(WebCore::CanvasNoiseInjection::postProcessDirtyCanvasBuffer):

Canonical link: https://commits.webkit.org/319682@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to