Bug 224500 - Have HTMLCanvasElement clear its buffer as soon as its script execution context goes away
Summary: Have HTMLCanvasElement clear its buffer as soon as its script execution conte...
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-13 12:20 PDT by Chris Dumez
Modified: 2022-04-11 07:03 PDT (History)
11 users (show)

See Also:


Attachments
Patch (2.12 KB, patch)
2021-04-13 12:21 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (2.04 KB, patch)
2021-04-13 13:10 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2021-04-13 12:20:06 PDT
Have HTMLCanvasElement clear its buffer as soon as its script execution context goes away. We used to do this only in the destructor, which would only get called after GC of the JS wrapper, which may delay release of the ImageBuffer and its memory.
Comment 1 Chris Dumez 2021-04-13 12:21:55 PDT
Created attachment 425896 [details]
Patch
Comment 2 Chris Dumez 2021-04-13 13:10:01 PDT
Created attachment 425906 [details]
Patch
Comment 3 Chris Dumez 2021-04-13 15:35:31 PDT
This is web-observable.
Comment 4 Tim Horton 2021-08-05 12:05:36 PDT
Comment on attachment 425906 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=425906&action=review

Additional motivation: https://bugs.webkit.org/show_bug.cgi?id=228747

> Source/WebCore/html/HTMLCanvasElement.cpp:1028
> +    setImageBuffer(nullptr);

I'm guessing we'd need to slurp some more code from the destructor to fix the assertions.
Comment 5 Tim Horton 2021-08-05 13:02:07 PDT
Reopening because Sam and Chris and I all think we should try this again when we have lots of bake time :)

(Also, we already do it for WebGL)
Comment 6 Radar WebKit Bug Importer 2022-04-11 07:03:03 PDT
<rdar://problem/91563038>