Skip to content

Commit

Permalink
Reverts "Prevent LayoutBuilder from rebuilding more than once (#147856)…
Browse files Browse the repository at this point in the history
…" (#149279)

Reverts: #147856
Initiated by: loic-sharma
Reason for reverting: tree is closed with errors like: 

```
test/integration.shard/break_on_framework_exceptions_test.dart: breaks when rebuilding dirty elements throws [E]
  Expected: <45>
    Actual: <2756>
  
  package:matcher                                                       expect
  test\integration.shard\break_on_framework_exceptions_test.dart 56:5   main.expectException
  ===== asynchronous gap ===
Original PR Author: LongCatIsLooong

Reviewed By: {goderbauer}

This change reverts the following previous change:
Fixes #146379: introduces `Element.buildScope` which `BuildOwner.buildScope` uses to identify subtrees that need skipping (those with different `BuildScope`s). If `Element.update` calls `updateChild` then dirty children will still be rebuilt regardless of their build scopes. 

This also introduces `LayoutBuilder.applyDoubleRebuildFix` migration flag which should only live for a week or less. 

Caveats: 

`LayoutBuilder`'s render object calls `markNeedsLayout` if a descendant Element is dirty. Since `markNeedsLayout` also implies `markNeedsPaint`, the render object is going to be very repaint/relayout-happy.

Tests: 

Presubmits with the migration flag set to true: https://github.com/flutter/flutter/pull/147856/checks?check_run_id=24629865893
  • Loading branch information
auto-submit[bot] committed May 29, 2024
1 parent 182c1e6 commit ebc4143
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 712 deletions.
9 changes: 6 additions & 3 deletions packages/flutter/lib/src/rendering/object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,8 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge
}

if (!activeLayoutRoot._debugMutationsLocked) {
activeLayoutRoot = activeLayoutRoot.debugLayoutParent;
final RenderObject? p = activeLayoutRoot.debugLayoutParent;
activeLayoutRoot = p is RenderObject ? p : null;
} else {
// activeLayoutRoot found.
break;
Expand Down Expand Up @@ -3003,7 +3004,7 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge
owner!._nodesNeedingPaint.add(this);
owner!.requestVisualUpdate();
}
} else if (parent != null) {
} else if (parent is RenderObject) {
parent!.markNeedsPaint();
} else {
assert(() {
Expand All @@ -3019,7 +3020,9 @@ abstract class RenderObject with DiagnosticableTreeMixin implements HitTestTarge
//
// Trees rooted at a RenderView do not go through this
// code path because RenderViews are repaint boundaries.
owner?.requestVisualUpdate();
if (owner != null) {
owner!.requestVisualUpdate();
}
}
}

Expand Down
Loading

0 comments on commit ebc4143

Please sign in to comment.