Skip to content

Conversation

@zanderso
Copy link
Member

@zanderso zanderso commented Jun 7, 2022

@zanderso zanderso requested review from dnfield and jonahwilliams June 7, 2022 02:14
@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Jun 7, 2022
@jonahwilliams
Copy link
Contributor

RIP

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@jonahwilliams
Copy link
Contributor

It seems like we might not be doing the peephole optimization if we don't end up compositing the opacity layer, though @flar would be the expert here

@fluttergithubbot fluttergithubbot merged commit ac7e29a into master Jun 7, 2022
@fluttergithubbot fluttergithubbot deleted the revert-105334-remove_opacity_forced_compositing branch June 7, 2022 07:43
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 7, 2022
@flar
Copy link
Contributor

flar commented Jun 7, 2022

DLs only currently check if they can accept an external opacity. They also check each internal saveLayer if it could also accept one - as an implementation detail for detecting the external acceptance criteria - but they don't check to see if they are themselves the source of an "opacity saveLayer".

It looks like they do check for an "opacity saveLayer", but it looks like it doesn't trigger for some reason:

https://github.com/flutter/engine/blob/02590c79ad4c53b4d939fb0f9a54839cb675d4d0/display_list/display_list_canvas_dispatcher.cc#L60

@flar
Copy link
Contributor

flar commented Jun 7, 2022

It looks like the grid of opacity benchmark is failing to distribute opacity because the conservative tests in the saveLayer dispatch method linked above will refuse to propagate the opacity if a bounds is supplied for the saveLayer. This is "safe", but unnecessary if the bounds for the saveLayer are large enough to hold all of the children. For OpacityLayer, the bounds of the saveLayer are known to contain all of the children because the bounds are provided by child_layer_bounds, so it can more aggressively apply this optimization. For DL, unfortunately, the bounds are not known while the DL is being constructed so this information cannot be used to gate the optimization.

Other peephole benchmarks that try to apply opacity to a number of overlapping children take advantage of the overlap testing inside ContainerLayer::PrerollChildren which is also missing from DL.

A quick test of commenting out the bounds check inside the saveLayer dispatch method above shows that performance not only improves, it beats the previous benchmark results by a wide margin.

In order to enable equal conditions for the saveLayer dispatch method compared to the OpacityLayer conditions we will need to fix the following issues (the RTree stuff will enable better overlap testing, but a simple overlap condition similar to what is done in the PrerollChildren code can be done by only fixing the first 2 issues):

camsim99 pushed a commit to camsim99/flutter that referenced this pull request Aug 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants