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 canvas z-index leaking across repaints when element is reused. #17378

Merged
merged 6 commits into from Mar 30, 2020

Conversation

ferhatb
Copy link
Contributor

@ferhatb ferhatb commented Mar 27, 2020

Related bug: flutter/flutter#51514

Added test that verifies canvas is reused and zindex is reset when paint order changes (similar to hover/repaint reproduced in related issue).

canvas.id = kTestId;

sceneElement.remove();
// Clear so resources are marked for reuse.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: move the comment one line down

// If a canvas is the first element we set z-index = -1 to workaround
// blink compositing bug. To make sure this does not leak when reused
// reset z-index.
_canvas.style.removeProperty('z-index');
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't the effect be the same if you put this into an else branch of the if (isFirstChildElement) check below? Just so we have all the z-index related code together in one spot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No since it never reaches that code when you reuse from reuse_pool

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm referring to line 127. It does reach it. I don't see any early return statement. 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.

Ah got it. So yes thats a good option as well. But this way we are executing the removeProperty call only if we reuse instead of doing it at startup as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, makes sense.

@ferhatb ferhatb merged commit c779894 into flutter:master Mar 30, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 30, 2020
goderbauer pushed a commit to goderbauer/engine that referenced this pull request Apr 16, 2020
…ed. (flutter#17378)

* Fix z-index leak. Add test for canvas reuse
* add regression test
* update golden locks
* fix analysis errors
@ferhatb ferhatb deleted the zindex_leak branch August 10, 2020 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants