Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@mklim
Copy link
Contributor

@mklim mklim commented Oct 25, 2019

Previously the cache was disabled on whether or not PlatformViews were
globally enabled. Instead track their existence in the view hierarchy
and only disable RasterCache if a PlatformView is actually present.

Fixes flutter/flutter#38903

root_layer_->Preroll(&preroll_context, root_surface_transformation);
// The needs painting flag may be set after the preroll. So check it after.
if (root_layer_->needs_painting()) {
paint_context.has_platform_view = preroll_context.has_platform_view;
Copy link
Contributor Author

@mklim mklim Oct 25, 2019

Choose a reason for hiding this comment

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

Is this necessary? None of the other variables from preroll_context are copied over here. I wasn't sure if this root_layer_ was guaranteed to be a single node with no children at this point or not.

Previously the cache was disabled on whether or not PlatformViews were
globally enabled. Instead track their existence in the view hierarchy
and only disable RasterCache if a PlatformView is actually present.
@mklim mklim requested a review from amirh October 25, 2019 21:56
@amirh
Copy link
Contributor

amirh commented Oct 25, 2019

IIUC the current code splits the tree into 2 parts (before and after hitting the first platform view) and raster cache is disabled for the later part?

I'm thinking we should probably set has_platform_view to false before visiting each child here

layer->Preroll(context, child_matrix);
and at the end of the loop set it to true if it was true after prerolling one or more children?

@mklim
Copy link
Contributor Author

mklim commented Oct 25, 2019

I'm thinking we should probably set has_platform_view to false before visiting each child here

Good catch, I tested this out with a demo app and a sibling of a PlatformView was also having its RasterCache disabled. This should be fixed now. I didn't set it to false but instead set it to whatever the ContainerLayer already had. My reasoning was that if the ContainerLayer itself was somehow a child of a PlatformView, then all its children should have it disabled.

@amirh
Copy link
Contributor

amirh commented Oct 25, 2019

I'm thinking we should probably set has_platform_view to false before visiting each child here

Good catch, I tested this out with a demo app and a sibling of a PlatformView was also having its RasterCache disabled. This should be fixed now. I didn't set it to false but instead set it to whatever the ContainerLayer already had. My reasoning was that if the ContainerLayer itself was somehow a child of a PlatformView, then all its children should have it disabled.

Thanks. Not sure it matters as a platform view layer has no children flow layers.

TextureRegistry& texture_registry;
const RasterCache* raster_cache;
const bool checkerboard_offscreen_layers;
bool has_platform_view;
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why this new field is necessary. If the raster cache needs to be disabled, the raster_cache pointer can just not be supplied in the paint context. There is nothing more to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not necessary, removed.

void ContainerLayer::PrerollChildren(PrerollContext* context,
const SkMatrix& child_matrix,
SkRect* child_paint_bounds) {
const bool had_platform_view = context->has_platform_view;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd keep the simpler version of this where we assume platform view has no children (it is a leaf layer)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I did put in a debug assert just to try and catch in case this assumption ever changes in the future.

@amirh
Copy link
Contributor

amirh commented Oct 28, 2019

I'm thinking we should probably set has_platform_view to false before visiting each child here

Good catch, I tested this out with a demo app and a sibling of a PlatformView was also having its RasterCache disabled. This should be fixed now. I didn't set it to false but instead set it to whatever the ContainerLayer already had. My reasoning was that if the ContainerLayer itself was somehow a child of a PlatformView, then all its children should have it disabled.

We should probably add a test for the case we're using raster cache after a platform view

- Test for platform view layer as a sibling of layers that need to be
  cached to make sure the context is being reset between children.
- Minor code cleanup.
@mklim
Copy link
Contributor Author

mklim commented Oct 29, 2019

We should probably add a test for the case we're using raster cache after a platform view

Done. I converted the previous test case instead of adding an entirely separate one. I think testing that the platform view layer isn't cached but sibling layers are also covers the case of checking that platform views aren't cached in general.

Copy link
Contributor

@amirh amirh left a comment

Choose a reason for hiding this comment

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

LGTM

(assuming that Chinmay approves the changes to shell and embedder_engine)

layer->Paint(paintContext);
}
});
entry.image = Rasterize(
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the formatting of this file is going to depend on the last editor? 😝
@chinmaygarde

[not blocking this PR]

Copy link
Contributor Author

@mklim mklim Oct 29, 2019

Choose a reason for hiding this comment

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

The actual change here is that paintContext.rasterCache is getting set to context->has_platform_view ? nullptr : context->raster_cache instead of just context->raster_cache. That statement is so long that clang-format decided to move this whole block further to the left to make room for it. I'm not sure why it was moved further to the right to start with, but it should be consistent between editors and CI.

Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

Some nits but looks good overall. Thanks!


setup.Wait();
const flutter::Shell& shell =
reinterpret_cast<flutter::EmbedderEngine*>(engine.get())->shell();
Copy link
Member

Choose a reason for hiding this comment

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

This reinterpret cast depends on an implementation detail in embedder.cc. Please add a method to any file other than embedder.h that basically does just this cast. The implmentation of the method itself can be in embedder.cc though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to embedder_assertions.h with the other utility conversion methods.

@mklim mklim merged commit 3ad3bc7 into flutter:master Oct 30, 2019
@mklim mklim deleted the raster_cache branch October 30, 2019 17:45
mklim pushed a commit that referenced this pull request Oct 30, 2019
This caused EmbedderTest.VerifyB143464703 to fail after merging into
master.

```
../../flutter/shell/platform/embedder/tests/embedder_unittests.cc:3111: Failure
Value of: ImageMatchesFixture("verifyb143464703.png", renderered_scene)
  Actual: false
Expected: true
[  FAILED  ] EmbedderTest.VerifyB143464703 (2507 ms)
```

This reverts commit 3ad3bc7.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 30, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 30, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 30, 2019
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Oct 30, 2019
[email protected]:flutter/engine.git/compare/5051bef17bdc...e609577

git log 5051bef..e609577 --no-merges --oneline
2019-10-30 [email protected] Revert "Turn on RasterCache based on view hierarchy (#13360)" (flutter/engine#13442)
2019-10-30 [email protected] Turn on RasterCache based on view hierarchy (flutter/engine#13360)
2019-10-30 [email protected] Roll src/third_party/dart d3a5b82355..f30b494035 (9 commits)


If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
mklim pushed a commit that referenced this pull request Nov 9, 2019
This is a duplicate of #13360 with the test switched to use the software backend instead of the GL backend.

After some debugging and testing on another GL embedder I think the issue with the test is some bug having to do with the GL implementation in the test harness specifically. 

Fixes flutter/flutter#38903
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Nov 26, 2019
[email protected]:flutter/engine.git/compare/5051bef17bdc...e609577

git log 5051bef..e609577 --no-merges --oneline
2019-10-30 [email protected] Revert "Turn on RasterCache based on view hierarchy (flutter#13360)" (flutter/engine#13442)
2019-10-30 [email protected] Turn on RasterCache based on view hierarchy (flutter/engine#13360)
2019-10-30 [email protected] Roll src/third_party/dart d3a5b82355..f30b494035 (9 commits)


If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use RasterCache where possible even when we have embedded views enabled.

4 participants