Bug 266473

Summary: Performance severely degraded when drawing a canvas into another canvas while Advanced Tracking and Fingerprinting Protection is enabled
Product: WebKit Reporter: Paul Neave <paul.neave>
Component: CanvasAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: ap, dino, m_finkel, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 17   
Hardware: All   
OS: Unspecified   
Attachments:
Description Flags
Example HTML file none

Description Paul Neave 2023-12-15 04:56:29 PST
Created attachment 469061 [details]
Example HTML file

When using context.drawImage() to draw a 2D canvas into another 2D canvas, performance is severely degraded when the Advanced Tracking and Fingerprinting Protection settings is enabled in Safari 17.

Please try this following example is Safari 17 in a private tab (HTML file attached to this report).

`
<html>
<body>
<canvas id="canvas"></canvas>
<script>

const width = 800;
const height = 800;

const canvas = document.getElementById('canvas');
canvas.width = width;
canvas.height = height;
const context = canvas.getContext('2d');

const imageCanvas = document.createElement('canvas');
imageCanvas.width = width;
imageCanvas.height = height;
const imageContext = imageCanvas.getContext('2d');
imageContext.fillStyle = 'red';
imageContext.fillRect(0, 0, width, height);

console.time('drawImage');
context.drawImage(imageCanvas, 0, 0);
console.timeEnd('drawImage');

</script>
</body>
</html>
`

Open the JavaScript console in Safari to see the timings for the operation. Then toggle the "Use advanced tracking and fingerprinting protection" setting, under Settings > Advanced > Privacy, and reload the page.

On my Mac I see ~0.015 ms with Advanced Tracking and Fingerprinting Protection disabled. When it is enabled, I see the operation takes ~90 ms, a 6000x performance regression. Websites that use this technique are now unusable.

This issue is affecting many users since Advanced Tracking and Fingerprinting Protection is now enabled by default for private tabs in Safari 17.
Comment 1 Alexey Proskuryakov 2023-12-16 16:28:35 PST
Please let us know if this still reproduces with Safari 17.2 (I cannot reproduce).

*** This bug has been marked as a duplicate of bug 263129 ***
Comment 2 Paul Neave 2023-12-18 06:31:32 PST
No, this is not fixed in iOS 17.2. Running the example shows:

Normal tab: ~0.05 ms
Private tab: ~60 ms
Comment 3 Alexey Proskuryakov 2023-12-18 10:14:08 PST
Hmm, I don't know what I did wrong, but now I'm reproducing this on macOS, even though I'm performing the same steps as the other day, and didn't change any preferences.

Re-opening.
Comment 4 Radar WebKit Bug Importer 2023-12-18 10:14:27 PST
<rdar://problem/119821737>
Comment 5 Matthew Finkel 2024-01-12 10:47:30 PST
Thanks for reporting this issue. I'm duping it to a slightly older bug for resolution.

*** This bug has been marked as a duplicate of bug 266181 ***