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 { ...@@ -653,6 +653,9 @@ abstract class RenderBox extends RenderObject {
@override @override
BoxConstraints get constraints => super.constraints; BoxConstraints get constraints => super.constraints;
// We check the intrinsic sizes of each render box once by default.
bool _debugNeedsIntrinsicSizeCheck = true;
@override @override
void debugAssertDoesMeetConstraints() { void debugAssertDoesMeetConstraints() {
assert(constraints != null); assert(constraints != null);
...@@ -716,6 +719,7 @@ abstract class RenderBox extends RenderObject { ...@@ -716,6 +719,7 @@ abstract class RenderBox extends RenderObject {
'your fault. Contact support: https://github.com/flutter/flutter/issues/new' 'your fault. Contact support: https://github.com/flutter/flutter/issues/new'
); );
} }
if (_debugNeedsIntrinsicSizeCheck || debugCheckIntrinsicSizes) {
// verify that the intrinsics are also within the constraints // verify that the intrinsics are also within the constraints
assert(!RenderObject.debugCheckingIntrinsics); assert(!RenderObject.debugCheckingIntrinsics);
RenderObject.debugCheckingIntrinsics = true; RenderObject.debugCheckingIntrinsics = true;
...@@ -743,6 +747,7 @@ abstract class RenderBox extends RenderObject { ...@@ -743,6 +747,7 @@ abstract class RenderBox extends RenderObject {
failureCount += 1; failureCount += 1;
} }
RenderObject.debugCheckingIntrinsics = false; RenderObject.debugCheckingIntrinsics = false;
_debugNeedsIntrinsicSizeCheck = false;
if (failures.isNotEmpty) { if (failures.isNotEmpty) {
assert(failureCount > 0); assert(failureCount > 0);
throw new FlutterError( throw new FlutterError(
...@@ -754,6 +759,7 @@ abstract class RenderBox extends RenderObject { ...@@ -754,6 +759,7 @@ abstract class RenderBox extends RenderObject {
'your fault. Contact support: https://github.com/flutter/flutter/issues/new' 'your fault. Contact support: https://github.com/flutter/flutter/issues/new'
); );
} }
}
return true; return true;
}); });
} }
......
...@@ -68,6 +68,9 @@ bool debugPrintMarkNeedsPaintStacks = false; ...@@ -68,6 +68,9 @@ bool debugPrintMarkNeedsPaintStacks = false;
/// Log the call stacks that mark render objects as needing layout. /// Log the call stacks that mark render objects as needing layout.
bool debugPrintMarkNeedsLayoutStacks = false; bool debugPrintMarkNeedsLayoutStacks = false;
/// Check the intrinsic sizes of each [RenderBox] during layout.
bool debugCheckIntrinsicSizes = false;
List<String> debugDescribeTransform(Matrix4 transform) { List<String> debugDescribeTransform(Matrix4 transform) {
List<String> matrix = transform.toString().split('\n').map((String s) => ' $s').toList(); List<String> matrix = transform.toString().split('\n').map((String s) => ' $s').toList();
matrix.removeLast(); 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