-
Notifications
You must be signed in to change notification settings - Fork 6k
Share engine layers with the framework #6406
Conversation
chinmaygarde
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits. But lgtm otherwise.
lib/ui/painting/engine_layer.h
Outdated
|
|
||
| class EngineLayer; | ||
|
|
||
| using RetainedLayer = fml::RefPtr<EngineLayer>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this typedef does not add to the clarity of the code. fml::RefPtr<EngineLayer> reads clearer. We also haven't gotten into the habit of typedeffing such things in other parts of the engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| using RetainedLayer = fml::RefPtr<EngineLayer>; | ||
|
|
||
| class EngineLayer : public RefCountedDartWrappable<EngineLayer> { | ||
| DEFINE_WRAPPERTYPEINFO(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: These go at the bottom of the class definition. Though I always get confused with the code style in lib/ui as it was written in blink style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
liyuqian
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comments!
lib/ui/painting/engine_layer.h
Outdated
|
|
||
| class EngineLayer; | ||
|
|
||
| using RetainedLayer = fml::RefPtr<EngineLayer>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| using RetainedLayer = fml::RefPtr<EngineLayer>; | ||
|
|
||
| class EngineLayer : public RefCountedDartWrappable<EngineLayer> { | ||
| DEFINE_WRAPPERTYPEINFO(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
flutter/engine@f6af1f2...9ccc966 git log f6af1f2..9ccc966 --no-merges --oneline 9ccc966 Share engine layers with the framework (flutter/engine#6406) fa719e3 Roll src/third_party/skia cc4dbfcfbd8a..6719fcc43b1e (17 commits) (flutter/engine#6409) dc2634d Force lf-line endings for so that source offsets match across platforms. (flutter/engine#6408) 44a5149 Roll src/third_party/skia 7dae882574d2..cc4dbfcfbd8a (15 commits) (flutter/engine#6405) de32c65 Roll src/third_party/skia 3b8b11e1f912..7dae882574d2 (15 commits) (flutter/engine#6403) 3a9c22a Allow GetRectsForRange to provide more detailed/nuanced metrics through RectStyle enum. (flutter/engine#6335) b59c864 Rename the Android fragment support library JAR (flutter/engine#6400) 4213ac1 Add an Android fragment support library to third_party (flutter/engine#6384) a785b25 do not count Hidden nodes at the beginning of the scrollable (flutter/engine#6381) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
Reverts #6406 We need to fix the SkiaGPUObject issue of the raster cache SkImage before merging this PR.
flutter/engine@f6af1f2...2de87a8 git log f6af1f2..2de87a8 --no-merges --oneline 2de87a8 Roll src/third_party/skia 6719fcc43b1e..deb512045e6a (7 commits) (flutter/engine#6411) 68a42e3 Add nullability annotations to MethodChannel/MethodCall. (flutter/engine#6393) 71ba20a Dart SDK roll for 2018-10-02 to d2c5a24fd9ead97a7f18d02786e679293cc3709e (flutter/engine#6410) 9ccc966 Share engine layers with the framework (flutter/engine#6406) fa719e3 Roll src/third_party/skia cc4dbfcfbd8a..6719fcc43b1e (17 commits) (flutter/engine#6409) dc2634d Force lf-line endings for so that source offsets match across platforms. (flutter/engine#6408) 44a5149 Roll src/third_party/skia 7dae882574d2..cc4dbfcfbd8a (15 commits) (flutter/engine#6405) de32c65 Roll src/third_party/skia 3b8b11e1f912..7dae882574d2 (15 commits) (flutter/engine#6403) 3a9c22a Allow GetRectsForRange to provide more detailed/nuanced metrics through RectStyle enum. (flutter/engine#6335) b59c864 Rename the Android fragment support library JAR (flutter/engine#6400) 4213ac1 Add an Android fragment support library to third_party (flutter/engine#6384) a785b25 do not count Hidden nodes at the beginning of the scrollable (flutter/engine#6381) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
flutter/engine@f6af1f2...74662ab git log f6af1f2..74662ab --no-merges --oneline 74662ab Revert "Share engine layers with the framework" (flutter/engine#6412) 2de87a8 Roll src/third_party/skia 6719fcc43b1e..deb512045e6a (7 commits) (flutter/engine#6411) 68a42e3 Add nullability annotations to MethodChannel/MethodCall. (flutter/engine#6393) 71ba20a Dart SDK roll for 2018-10-02 to d2c5a24fd9ead97a7f18d02786e679293cc3709e (flutter/engine#6410) 9ccc966 Share engine layers with the framework (flutter/engine#6406) fa719e3 Roll src/third_party/skia cc4dbfcfbd8a..6719fcc43b1e (17 commits) (flutter/engine#6409) dc2634d Force lf-line endings for so that source offsets match across platforms. (flutter/engine#6408) 44a5149 Roll src/third_party/skia 7dae882574d2..cc4dbfcfbd8a (15 commits) (flutter/engine#6405) de32c65 Roll src/third_party/skia 3b8b11e1f912..7dae882574d2 (15 commits) (flutter/engine#6403) 3a9c22a Allow GetRectsForRange to provide more detailed/nuanced metrics through RectStyle enum. (flutter/engine#6335) b59c864 Rename the Android fragment support library JAR (flutter/engine#6400) 4213ac1 Add an Android fragment support library to third_party (flutter/engine#6384) a785b25 do not count Hidden nodes at the beginning of the scrollable (flutter/engine#6381) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
flutter/engine@f6af1f2...74662ab git log f6af1f2..74662ab --no-merges --oneline 74662ab Revert "Share engine layers with the framework" (flutter/engine#6412) 2de87a8 Roll src/third_party/skia 6719fcc43b1e..deb512045e6a (7 commits) (flutter/engine#6411) 68a42e3 Add nullability annotations to MethodChannel/MethodCall. (flutter/engine#6393) 71ba20a Dart SDK roll for 2018-10-02 to d2c5a24fd9ead97a7f18d02786e679293cc3709e (flutter/engine#6410) 9ccc966 Share engine layers with the framework (flutter/engine#6406) fa719e3 Roll src/third_party/skia cc4dbfcfbd8a..6719fcc43b1e (17 commits) (flutter/engine#6409) dc2634d Force lf-line endings for so that source offsets match across platforms. (flutter/engine#6408) 44a5149 Roll src/third_party/skia 7dae882574d2..cc4dbfcfbd8a (15 commits) (flutter/engine#6405) de32c65 Roll src/third_party/skia 3b8b11e1f912..7dae882574d2 (15 commits) (flutter/engine#6403) 3a9c22a Allow GetRectsForRange to provide more detailed/nuanced metrics through RectStyle enum. (flutter/engine#6335) b59c864 Rename the Android fragment support library JAR (flutter/engine#6400) 4213ac1 Add an Android fragment support library to third_party (flutter/engine#6384) a785b25 do not count Hidden nodes at the beginning of the scrollable (flutter/engine#6381) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
| /// | ||
| /// All the engine layers that are in the subtree of the retained layer will | ||
| /// be automatically appended to the current engine layer tree. Therefore, | ||
| /// once this is called, there's no need to call [addToScene] for its children |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioning addToScene here is a bit of a non-sequitur, since it's not part of this API. I think it's fine to mention it, but we'd have to add a lot more context, e.g. referring to "when implementing a subclass of the [Layer] concept defined in the rendering layer of Flutter's framework...".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
With this approach, the retained layer API doesn't provide much benefit for nodes far from the leaves (since there's no way to update a retained layer, as far as I can tell). Is that intentional? We could go much further and make the layer tree persistent and mutable, in the same way the RenderObject tree is. Or we could make it persistent and react-style, as in the widget tree. It's not entirely clear to me what is expensive here, so it's hard to precisely suggest the best API to unlock the most optimisation. |
|
@Hixie Yes, no way to update a retained layer is intentional in the current design: modifying or creating a new layer tree is cheap (this is probably not true for RenderObject tree) while rasterizing a layer tree is costly. The current retained rendering is trying to save the rasterization time with which mutating the layer tree can't help much: if a leaf node and its pixel changes, it will invalidate the raster cache of all its ancestors no matter whether we persist them or not. But I haven't had too much time to think about what the optimal solution is so there's likely a lot of room to improve over the current design. I hope that the current design is kept minimal and clean so we can easily incrementally improve it in the future. We can also have more discussions offline as this topic might be too big for just one or two Github comments. |
To make the PR minimal, we currently only share the engine layer when
pushPhysicalShape(for Fuchsia) orpushOffset(forRepaintBoundaryandOpacity) are called. They should be sufficient for our short-term perf goal. In the future, we can incrementally share more engine layers with the framework.flutter/flutter#21756