Commit 9157c164 authored by Adam Barth's avatar Adam Barth

The intrinsic size checks were very slow

Now we run them once per render object.

Fixes #2487
parent 992fc76e
......@@ -653,6 +653,9 @@ abstract class RenderBox extends RenderObject {
@override
BoxConstraints get constraints => super.constraints;
// We check the intrinsic sizes of each render box once by default.
bool _debugNeedsIntrinsicSizeCheck = true;
@override
void debugAssertDoesMeetConstraints() {
assert(constraints != null);
......@@ -716,6 +719,7 @@ abstract class RenderBox extends RenderObject {
'your fault. Contact support: https://github.com/flutter/flutter/issues/new'
);
}
if (_debugNeedsIntrinsicSizeCheck || debugCheckIntrinsicSizes) {
// verify that the intrinsics are also within the constraints
assert(!RenderObject.debugCheckingIntrinsics);
RenderObject.debugCheckingIntrinsics = true;
......@@ -743,6 +747,7 @@ abstract class RenderBox extends RenderObject {
failureCount += 1;
}
RenderObject.debugCheckingIntrinsics = false;
_debugNeedsIntrinsicSizeCheck = false;
if (failures.isNotEmpty) {
assert(failureCount > 0);
throw new FlutterError(
......@@ -754,6 +759,7 @@ abstract class RenderBox extends RenderObject {
'your fault. Contact support: https://github.com/flutter/flutter/issues/new'
);
}
}
return true;
});
}
......
......@@ -68,6 +68,9 @@ bool debugPrintMarkNeedsPaintStacks = false;
/// Log the call stacks that mark render objects as needing layout.
bool debugPrintMarkNeedsLayoutStacks = false;
/// Check the intrinsic sizes of each [RenderBox] during layout.
bool debugCheckIntrinsicSizes = false;
List<String> debugDescribeTransform(Matrix4 transform) {
List<String> matrix = transform.toString().split('\n').map((String s) => ' $s').toList();
matrix.removeLast();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment