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

Issues leading to rebuilding more of the RenderObject and Layer trees than necessary #61651

Open
flar opened this issue Jul 16, 2020 · 0 comments
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list perf: speed Performance issues related to (mostly rendering) speed team-framework Owned by Framework team triaged-framework Triaged by Framework team

Comments

@flar
Copy link
Contributor

flar commented Jul 16, 2020

Flutter consists of a number of levels of trees (as described in the Mahogany Staircase talk). When a change is made to the Widget tree, those changes must be propagated into the Element, RenderObject, and Layer trees. Each level has code that attempts to reuse parts of the lower level trees on each pass to minimize the work. Unfortunately, there is still a lot of rebuilding going on for some simple changes to a tree, and a fair bit of developer involvement in minimizing the effect in their apps. In particular:

  • One of the few tools at the disposal of the developer for minimizing the scope of rebuilds is the RepaintBoundary which acts as a wall between parts of the tree to keep a change inside its children from causing a rebuild of any of the widgets outside of it (and vice versa).
  • Animating widgets don't protect their children or ancestors by default, but require the developer to insert a RepaintBoundary to keep their constant rebuilds from affecting the rest of the tree.
  • One of the most common inter-dependencies between RenderObjects is the sharing of paint commands being dealt to a single shared Picture object. The Picture object will be shared from the first RenderObject that issues a paint command all the way until the end of the tree or until the first RenderObject that requires an engine layer to be pushed to do its work. The Picture can be shared outside of the scope of the first RenderObject that initiated it as it is shared across any subset of the flattened tree traversal with no regard to scope. If any of these RenderObjects needs to change what it painted then all of them must repaint. If there is a RepaintBoundary somewhere in the list, then that will break the Picture into multiple Picture objects and reduce the scope of sharing and repainting, but this requires detection by the app developer and a change to their Widget hierarchy.

These are some of the issues discovered while attempting to minimize repaints at the engine level (see #33939) and represent areas where we could achieve better efficiency both for minimizing the work done at the framework level when a widget changes and, by extension, the work needed to repaint the scene.

@liyuqian liyuqian added perf: speed Performance issues related to (mostly rendering) speed c: performance Relates to speed or footprint issues (see "perf:" labels) labels Jul 16, 2020
@kf6gpe kf6gpe added the framework flutter/packages/flutter repository. See also f: labels. label Jul 22, 2020
@goderbauer goderbauer added the P2 Important issues not at the top of the work list label Aug 16, 2022
@flutter-triage-bot flutter-triage-bot bot added team-framework Owned by Framework team triaged-framework Triaged by Framework team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list perf: speed Performance issues related to (mostly rendering) speed team-framework Owned by Framework team triaged-framework Triaged by Framework team
Projects
None yet
Development

No branches or pull requests

6 participants