Bug 228747 - fast/canvas/canvas-crash.html doesn't test what it intends to on iOS
Summary: fast/canvas/canvas-crash.html doesn't test what it intends to on iOS
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Horton
URL:
Keywords: InRadar
Depends on: 228788
Blocks:
  Show dependency treegraph
 
Reported: 2021-08-03 12:10 PDT by Tim Horton
Modified: 2021-08-05 18:57 PDT (History)
12 users (show)

See Also:


Attachments
Patch (10.76 KB, patch)
2021-08-03 12:16 PDT, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (13.15 KB, patch)
2021-08-03 15:52 PDT, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (12.24 KB, patch)
2021-08-05 16:39 PDT, Tim Horton
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Horton 2021-08-03 12:10:16 PDT
fast/canvas/canvas-crash.html doesn't test what it intends to on iOS
Comment 1 Tim Horton 2021-08-03 12:16:51 PDT
Created attachment 434850 [details]
Patch
Comment 2 Tim Horton 2021-08-03 12:16:54 PDT
<rdar://problem/81423634>
Comment 3 Simon Fraser (smfr) 2021-08-03 12:52:50 PDT
Comment on attachment 434850 [details]
Patch

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

> Source/WebCore/html/HTMLCanvasElement.cpp:115
> +static size_t maxCanvasAreaForTesting;
> +static size_t maxActivePixelMemoryForTesting;

Could these be Markable<>?

> Source/WebCore/testing/Internals.cpp:604
> +    HTMLCanvasElement::setMaxPixelMemoryForTesting(0);
> +    HTMLCanvasElement::setMaxCanvasAreaForTesting(0);

Ideally these would take std::optionals
Comment 4 Tim Horton 2021-08-03 15:52:21 PDT
Created attachment 434868 [details]
Patch
Comment 5 Tim Horton 2021-08-03 15:58:58 PDT
windows newlines oO
Comment 6 Tim Horton 2021-08-04 02:30:34 PDT
Heh, I think the configuration of the stress bot means it runs the test in the same process multiple times, and we hit the limit after a few tries :|
Comment 7 EWS 2021-08-04 02:40:53 PDT
Committed r280630 (240243@main): <https://commits.webkit.org/240243@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 434868 [details].
Comment 8 WebKit Commit Bot 2021-08-04 11:37:58 PDT
Re-opened since this is blocked by bug 228788
Comment 9 Tim Horton 2021-08-04 11:38:16 PDT
(In reply to Tim Horton from comment #6)
> Heh, I think the configuration of the stress bot means it runs the test in
> the same process multiple times, and we hit the limit after a few tries :|

Except the same thing happens on the real testers too!
Comment 10 Sam Weinig 2021-08-04 11:47:30 PDT
(In reply to Tim Horton from comment #9)
> (In reply to Tim Horton from comment #6)
> > Heh, I think the configuration of the stress bot means it runs the test in
> > the same process multiple times, and we hit the limit after a few tries :|
> 
> Except the same thing happens on the real testers too!

Leak?
Comment 11 Sam Weinig 2021-08-04 11:47:58 PDT
(In reply to Sam Weinig from comment #10)
> (In reply to Tim Horton from comment #9)
> > (In reply to Tim Horton from comment #6)
> > > Heh, I think the configuration of the stress bot means it runs the test in
> > > the same process multiple times, and we hit the limit after a few tries :|
> > 
> > Except the same thing happens on the real testers too!
> 
> Leak?

(or rather, depending on GC to cleanup something big?)
Comment 12 Tim Horton 2021-08-04 11:50:48 PDT
Yes, that. And we reset the max down to the default between each test so it's immediately TOO MUCH CANVAS
Comment 13 Sam Weinig 2021-08-05 07:08:08 PDT
(In reply to Tim Horton from comment #12)
> Yes, that. And we reset the max down to the default between each test so
> it's immediately TOO MUCH CANVAS

There are two options I can see here.

1) Remove the canvas from the document and force a GC using GCController.collect() to ensure the canvas is full destroyed before moving on to the next test.
2) Implement ActiveDOMObject::stop() for HTMLCanvasElement, and ensure the ImageBuffer  is destroyed there.


Ideally, we would do #2, but it is a bit more risk, so doing #1 first, and then doing #2 in another change may be the best option here.
Comment 14 Tim Horton 2021-08-05 12:05:50 PDT
(In reply to Sam Weinig from comment #13)
> (In reply to Tim Horton from comment #12)
> > Yes, that. And we reset the max down to the default between each test so
> > it's immediately TOO MUCH CANVAS
> 
> There are two options I can see here.
> 
> 1) Remove the canvas from the document and force a GC using
> GCController.collect() to ensure the canvas is full destroyed before moving
> on to the next test.
> 2) Implement ActiveDOMObject::stop() for HTMLCanvasElement, and ensure the
> ImageBuffer  is destroyed there.
> 
> 
> Ideally, we would do #2, but it is a bit more risk, so doing #1 first, and
> then doing #2 in another change may be the best option here.

https://bugs.webkit.org/show_bug.cgi?id=224500 tracks #2
Comment 15 Tim Horton 2021-08-05 16:29:05 PDT
(In reply to Sam Weinig from comment #13)
> (In reply to Tim Horton from comment #12)
> > Yes, that. And we reset the max down to the default between each test so
> > it's immediately TOO MUCH CANVAS
> 
> There are two options I can see here.
> 
> 1) Remove the canvas from the document and force a GC using
> GCController.collect() to ensure the canvas is full destroyed before moving
> on to the next test.

Oddly, this did not work, but I found a similar-but-even-less-flaky solution that does: resize the canvas before ending the test.
Comment 16 Tim Horton 2021-08-05 16:31:33 PDT
(In reply to Tim Horton from comment #15)
> (In reply to Sam Weinig from comment #13)
> > (In reply to Tim Horton from comment #12)
> > > Yes, that. And we reset the max down to the default between each test so
> > > it's immediately TOO MUCH CANVAS
> > 
> > There are two options I can see here.
> > 
> > 1) Remove the canvas from the document and force a GC using
> > GCController.collect() to ensure the canvas is full destroyed before moving
> > on to the next test.
> 
> Oddly, this did not work, but I found a similar-but-even-less-flaky solution
> that does: resize the canvas before ending the test.

Oh, it's not odd: the test doesn't actually use its <canvas> at all, it uses getCSSCanvasContext()
Comment 17 Tim Horton 2021-08-05 16:39:32 PDT
Created attachment 435038 [details]
Patch
Comment 18 Sam Weinig 2021-08-05 17:38:21 PDT
(In reply to Tim Horton from comment #16)
> (In reply to Tim Horton from comment #15)
> > (In reply to Sam Weinig from comment #13)
> > > (In reply to Tim Horton from comment #12)
> > > > Yes, that. And we reset the max down to the default between each test so
> > > > it's immediately TOO MUCH CANVAS
> > > 
> > > There are two options I can see here.
> > > 
> > > 1) Remove the canvas from the document and force a GC using
> > > GCController.collect() to ensure the canvas is full destroyed before moving
> > > on to the next test.
> > 
> > Oddly, this did not work, but I found a similar-but-even-less-flaky solution
> > that does: resize the canvas before ending the test.
> 
> Oh, it's not odd: the test doesn't actually use its <canvas> at all, it uses
> getCSSCanvasContext()

Ah, that would makes sense. Those live for the lifetime of the document due to being "name" addressable. Your solution here seems great.
Comment 19 Tim Horton 2021-08-05 17:50:38 PDT
Stress bot is happy this time, I should have listened to it last time!!
Comment 20 EWS 2021-08-05 18:57:05 PDT
Committed r280715 (240306@main): <https://commits.webkit.org/240306@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 435038 [details].