Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4c31678fef6899bc5aa8db9efe5883e9b24db160
      
https://github.com/WebKit/WebKit/commit/4c31678fef6899bc5aa8db9efe5883e9b24db160
  Author: Matthew Finkel <sys...@apple.com>
  Date:   2024-01-22 (Mon, 22 Jan 2024)

  Changed paths:
    M LayoutTests/fast/canvas/canvas-noise-injection-expected.txt
    M LayoutTests/fast/canvas/canvas-noise-injection.html
    A LayoutTests/fast/canvas/webgl/resources/webgl-fingerprinting-support.js
    M Source/WebCore/html/CanvasBase.cpp
    M Source/WebCore/html/CanvasBase.h
    M Source/WebCore/html/CanvasNoiseInjection.cpp
    M Source/WebCore/html/CanvasNoiseInjection.h
    M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
    M Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

  Log Message:
  -----------
  Advanced tracking and fingerprinting protection performance issues with 
drawImage
https://bugs.webkit.org/show_bug.cgi?id=266181
rdar://problem/119783395

Reviewed by Kimmo Kinnunen.

In 270207@main, in the case when canvas noise injection is enabled, I added
exceptions where noise would not be applied to the canvas following
putImageData and drawImage commands. However, I excluded some cases which
weren't safe. One of those is applying noise to the source buffer of a canvas
when it is drawn onto another canvas.

This patch changes the above behavior by not applying any pending noise to the
source buffer, and instead the destination rect of the destination canvas is
marked as needing noise application. In order to accomplish this for both
canvas2d and webgl, this patch also stops tracking WebGL dirty rects that need
noise applied. The current mechanism for tracking was not sufficient and it
wasn't necessary. Instead, this patch now applies noise the the entire image
buffer if the rendering context is not 2D.

This patch adds tests that verify drawing one canvas from another accumulates
pending noise in the destination without applying noise to the source. It also
verifies that the noise application process does not change the image by
incorrectly placing the extracted pixelbuffer at the wrong offset of the image
buffer.

* LayoutTests/fast/canvas/canvas-noise-injection-expected.txt:
* LayoutTests/fast/canvas/canvas-noise-injection.html:
* LayoutTests/fast/canvas/webgl/resources/webgl-fingerprinting-support.js: 
Added.
(createMatrix):
(drawScene):
(setPositionAttribute):
(setColorAttribute):
(initBuffers):
(initPositionBuffer):
(initColorBuffer):
(initShaderProgram):
(loadShader):
(main):
* Source/WebCore/html/CanvasBase.cpp:
(WebCore::CanvasBase::makeRenderingResultsAvailable):
* Source/WebCore/html/CanvasBase.h:
* Source/WebCore/html/CanvasNoiseInjection.cpp:
(WebCore::CanvasNoiseInjection::postProcessDirtyCanvasBuffer):
(WebCore::CanvasNoiseInjection::postProcessPixelBufferResults const):
* Source/WebCore/html/CanvasNoiseInjection.h:
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::drawImage):
* Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::markContextChangedAndNotifyCanvasObserver):

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


_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to