Skip to content

Commit a454da0

Browse files
authored
Revert "[performance] Process dirty nodes from top to bottom during paint to avoid unnecessary layer tree walks" (#98520)
1 parent db4c98f commit a454da0

2 files changed

Lines changed: 8 additions & 87 deletions

File tree

packages/flutter/lib/src/rendering/object.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,8 @@ class PipelineOwner {
987987
try {
988988
final List<RenderObject> dirtyNodes = _nodesNeedingPaint;
989989
_nodesNeedingPaint = <RenderObject>[];
990-
for (final RenderObject node in dirtyNodes..sort((RenderObject a, RenderObject b) => a.depth - b.depth)) {
990+
// Sort the dirty nodes in reverse order (deepest first).
991+
for (final RenderObject node in dirtyNodes..sort((RenderObject a, RenderObject b) => b.depth - a.depth)) {
991992
assert(node._layerHandle.layer != null);
992993
if (node._needsPaint && node.owner == this) {
993994
if (node._layerHandle.layer!.attached) {
@@ -2364,8 +2365,12 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
23642365
return true;
23652366
}());
23662367
// If we still need layout, then that means that we were skipped in the
2367-
// layout phase and therefore don't need painting. This can happen when an
2368-
// error occurred prior to our paint and our layer wasn't properly detached.
2368+
// layout phase and therefore don't need painting. We might not know that
2369+
// yet (that is, our layer might not have been detached yet), because the
2370+
// same node that skipped us in layout is above us in the tree (obviously)
2371+
// and therefore may not have had a chance to paint yet (since the tree
2372+
// paints in reverse order). In particular this will happen if they have
2373+
// a different layer, because there's a repaint boundary between us.
23692374
if (_needsLayout)
23702375
return;
23712376
if (!kReleaseMode && debugProfilePaintsEnabled) {

packages/flutter/test/rendering/paint_order_test.dart

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)