| Summary: | Decoded image data is not reused by canvas causing long task blocking on the main thread | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Xidorn Quan <xidorn-webkit> | ||||
| Component: | Canvas | Assignee: | Nobody <webkit-unassigned> | ||||
| Status: | NEW --- | ||||||
| Severity: | Normal | CC: | dino, kkinnunen, sabouhallawa, simon.fraser, tomac, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | CanvaBug, InRadar | ||||
| Version: | WebKit Nightly Build | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Attachments: |
|
||||||
|
Description
Xidorn Quan
2022-06-07 22:04:13 PDT
Thanks for the test-case! For WebKit internals: The long duration after initial decode() is due to the way WP transfers the data to GPUP the first time. The new NativeImage gets sent over to GPUP during this duration. There are at least 3 different undesirable behaviors in WebKit: 1. initial draw after decode() is slow 2. Multiple .src assignments and decode()s are slow for same url. 3. Big getImageData() is slow (10ms on WebKit, ~0ms on Firefox) See https://bugs.chromium.org/p/chromium/issues/detail?id=1334448#c9 for a hosted demo and https://bugs.chromium.org/p/chromium/issues/detail?id=1334448#c10 for a theory of why the seemingly double decoding might happen. Thomas suggested to us that for this testcase, we can set `image.decoding` to `async`, and that seems to help on Chrome (where `draw` call is now immediate most of time), but not on Safari. No, I was wrong. It didn't help on Chrome either. Chrome was to some extent cheating by somehow reusing a decoded image from a previous image load. If I randomize the URL by adding `?` with `Math.random()` to the end of the URL, double decoding happens every time again. |