Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web] Fix HtmlImage state pollution due to image.clone optimization #17370

Merged
merged 12 commits into from
Mar 30, 2020

Conversation

ferhatb
Copy link
Contributor

@ferhatb ferhatb commented Mar 27, 2020

Related to issue flutter/flutter#52490. That issue, second sample reproduces this bug.

Golden test added to reproduce painting with same instance using dst < src rect and then dst = src rect.

Screenshot after fix:
Screen Shot 2020-03-26 at 2 19 25 PM

builder2.pushClipRect(
const Rect.fromLTRB(0, 0, 100, 100),
);
_drawTestPicture(builder2, 20, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This passes a smaller targetSize while claiming that the picture will be growing. Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment. Drawing the picture at actual size triggers new code path that reproduces the bug.

builder2.pop();

elm1.remove();
html.document.body.append(builder2.build().webOnlyRootElement);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should also verify that the element was reused. Otherwise, if the canvas does not reuse the image element it will "fix the bug" by virtue of creating a new element instead of reusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are reusing the ImageElement, not the canvas. I noticed we don't have such a test for canvas reuse, added one as part of #17378.

builder2.pop();

elm1.remove();
html.document.body.append(builder2.build().webOnlyRootElement);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

@ferhatb ferhatb merged commit 40931c8 into flutter:master Mar 30, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 31, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 31, 2020
goderbauer pushed a commit to goderbauer/engine that referenced this pull request Apr 16, 2020
…lutter#17370)

* fix drawImage style when destination width==source
* Add regression test
* dartfmt
* update golden lock
* Addressed review comment
* remove transform reset since _drawImage is called
@ferhatb ferhatb deleted the croprrect branch February 11, 2021 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants