Bug 266181 - Advanced tracking and fingerprinting protection performance issues with drawImage
Summary: Advanced tracking and fingerprinting protection performance issues with drawI...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Safari 17
Hardware: All iOS 17
: P2 Major
Assignee: Matthew Finkel
URL:
Keywords: InRadar
: 263013 266473 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-12-10 09:27 PST by Daniel Beauchamp
Modified: 2024-01-22 08:15 PST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Beauchamp 2023-12-10 09:27:10 PST
Description: 

In iOS 17 and mac OS Sonoma, using drawPixels performance is slowed when paired with webgl rendering.

It is a common technique to get around webgl context limitations to render a scene to an offscreen canvas, then output it to a desired 2d canvas using drawImage.
However with Advanced Tracking and Fingerprinting protection, framerate seems to decrease dramatically.

Version:
Latest: 271834@main



Reproduction steps:
- Open the following in latest: https://evanescent-traveling-radio.glitch.me/
- You should see a box that you can spin smoothly
- Now open it in Privacy mode (which has advanced fingerprinting protection turned on)
- Spinning the box is now sluggish and choppy

If you turn off advanced fingerprinting protection, then suddenly its fast again.

This is the same on iOS 17

The minimal test case code is here: https://gist.github.com/pushmatrix/bd72b5853b49ff217b0a780ea54e5bd5

My assumption is that advanced tracking protection has a false positive here and is introducing noise to the drawImage functionality that is slowing rendering to a crawl.


Impact:
Model viewer (https://modelviewer.dev/) uses this offscreen technique to allow for lots of 3D elements on a page. It is currently affected by this: https://github.com/google/model-viewer/issues/4587

Many sites rely on this technique.

Shopify relies on this viewer for displaying 3D models on hundreds of thousands of sites. Currently anyone viewing it in webkit in privacy mode has a very degraded experience.
Comment 1 Alexey Proskuryakov 2023-12-11 13:39:35 PST
This sounds like a duplicate of bug 263129. Does this still reproduce with iOS 17.2?
Comment 2 Alexey Proskuryakov 2023-12-11 13:40:29 PST
Please feel free to re-open if this still happens.

*** This bug has been marked as a duplicate of bug 263129 ***
Comment 3 Daniel Beauchamp 2023-12-16 23:13:34 PST
This is still happening in 17.2

I’ll be able to test on Mac this coming week, but it’s definitely still in 17.2 iOS 17.2 (21C62)
Comment 4 Radar WebKit Bug Importer 2023-12-17 09:28:13 PST
<rdar://problem/119783395>
Comment 5 Paul Neave 2023-12-18 06:32:50 PST
This is not fixed in iOS 17.2. Safari TP 17.4 still shows this issue too.
Comment 6 Daniel Beauchamp 2024-01-10 12:56:38 PST
Update on this. The issue seems to only persist when the source canvas is not in the DOM. Ex: if you just do document.createElement('canvas') to have function as an offscreen canvas, then the drawImage calls will be really slow.

If you however add the offscreen canvas to the DOM with appendChild, the problem goes away. Interestingly, if you do `display:none` on that canvas, the problem comes back. But if you set height to 0px to hide it, then everything is fine.

Here's an updated glitch with the offscreen canvas in the DOM and "hidden" with 0px height: https://common-teal-okapi.glitch.me
Comment 7 Matthew Finkel 2024-01-12 10:45:31 PST
Thanks for these details and providing the reduced test cases. I believe I see the issue.
Comment 8 Matthew Finkel 2024-01-12 10:47:30 PST
*** Bug 266473 has been marked as a duplicate of this bug. ***
Comment 9 Matthew Finkel 2024-01-12 23:30:24 PST
Pull request: https://github.com/WebKit/WebKit/pull/22746
Comment 10 Matthew Finkel 2024-01-13 13:31:35 PST
*** Bug 263013 has been marked as a duplicate of this bug. ***
Comment 11 EWS 2024-01-22 08:15:36 PST
Committed 273301@main (4c31678fef68): <https://commits.webkit.org/273301@main>

Reviewed commits have been landed. Closing PR #22746 and removing active labels.