Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
fbeb5e0c
Unverified
Commit
fbeb5e0c
authored
Apr 11, 2019
by
chunhtai
Committed by
GitHub
Apr 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue 23527: Exception: RenderViewport exceeded its maximum number of layout cycles (#30809)
parent
8bea3fb2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
4 deletions
+88
-4
sliver.dart
packages/flutter/lib/src/rendering/sliver.dart
+4
-3
sliver_list.dart
packages/flutter/lib/src/rendering/sliver_list.dart
+2
-1
slivers_block_test.dart
packages/flutter/test/rendering/slivers_block_test.dart
+82
-0
No files found.
packages/flutter/lib/src/rendering/sliver.dart
View file @
fbeb5e0c
...
@@ -686,7 +686,8 @@ class SliverGeometry extends Diagnosticable {
...
@@ -686,7 +686,8 @@ class SliverGeometry extends Diagnosticable {
/// * [RenderViewport.cacheExtent] for a description of a viewport's cache area.
/// * [RenderViewport.cacheExtent] for a description of a viewport's cache area.
final
double
cacheExtent
;
final
double
cacheExtent
;
static
const
double
_epsilon
=
1
e
-
10
;
/// The epsilon of tolerable double precision error.
static
const
double
precisionErrorTolerance
=
1
e
-
10
;
/// Asserts that this geometry is internally consistent.
/// Asserts that this geometry is internally consistent.
///
///
...
@@ -719,8 +720,8 @@ class SliverGeometry extends Diagnosticable {
...
@@ -719,8 +720,8 @@ class SliverGeometry extends Diagnosticable {
}
}
verify
(
maxPaintExtent
!=
null
,
'The "maxPaintExtent" is null.'
);
verify
(
maxPaintExtent
!=
null
,
'The "maxPaintExtent" is null.'
);
// If the paintExtent is slightly more than the maxPaintExtent, but the difference is still less
// If the paintExtent is slightly more than the maxPaintExtent, but the difference is still less
// than
epsilon
, we will not throw the assert below.
// than
precisionErrorTolerance
, we will not throw the assert below.
if
(
paintExtent
-
maxPaintExtent
>
_epsilon
)
{
if
(
paintExtent
-
maxPaintExtent
>
precisionErrorTolerance
)
{
verify
(
false
,
verify
(
false
,
'The "maxPaintExtent" is less than the "paintExtent".
\n
'
+
'The "maxPaintExtent" is less than the "paintExtent".
\n
'
+
_debugCompareFloats
(
'maxPaintExtent'
,
maxPaintExtent
,
'paintExtent'
,
paintExtent
)
+
_debugCompareFloats
(
'maxPaintExtent'
,
maxPaintExtent
,
'paintExtent'
,
paintExtent
)
+
...
...
packages/flutter/lib/src/rendering/sliver_list.dart
View file @
fbeb5e0c
...
@@ -119,7 +119,8 @@ class RenderSliverList extends RenderSliverMultiBoxAdaptor {
...
@@ -119,7 +119,8 @@ class RenderSliverList extends RenderSliverMultiBoxAdaptor {
}
}
final
double
firstChildScrollOffset
=
earliestScrollOffset
-
paintExtentOf
(
firstChild
);
final
double
firstChildScrollOffset
=
earliestScrollOffset
-
paintExtentOf
(
firstChild
);
if
(
firstChildScrollOffset
<
0.0
)
{
// firstChildScrollOffset may contain double precision error
if
(
firstChildScrollOffset
<
-
SliverGeometry
.
precisionErrorTolerance
)
{
// The first child doesn't fit within the viewport (underflow) and
// The first child doesn't fit within the viewport (underflow) and
// there may be additional children above it. Find the real first child
// there may be additional children above it. Find the real first child
// and then correct the scroll position so that there's room for all and
// and then correct the scroll position so that there's room for all and
...
...
packages/flutter/test/rendering/slivers_block_test.dart
View file @
fbeb5e0c
...
@@ -3,7 +3,9 @@
...
@@ -3,7 +3,9 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/animation.dart'
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'../flutter_test_alternative.dart'
;
import
'../flutter_test_alternative.dart'
;
import
'rendering_tester.dart'
;
import
'rendering_tester.dart'
;
...
@@ -67,6 +69,49 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
...
@@ -67,6 +69,49 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
void
setDidUnderflow
(
bool
value
)
{
}
void
setDidUnderflow
(
bool
value
)
{
}
}
}
class
ViewportOffsetSpy
extends
ViewportOffset
{
ViewportOffsetSpy
(
this
.
_pixels
);
double
_pixels
;
@override
double
get
pixels
=>
_pixels
;
bool
corrected
=
false
;
@override
bool
applyViewportDimension
(
double
viewportDimension
)
=>
true
;
@override
bool
applyContentDimensions
(
double
minScrollExtent
,
double
maxScrollExtent
)
=>
true
;
@override
void
correctBy
(
double
correction
)
{
_pixels
+=
correction
;
corrected
=
true
;
}
@override
void
jumpTo
(
double
pixels
)
{
// Do nothing, not required in test.
}
@override
Future
<
void
>
animateTo
(
double
to
,
{
@required
Duration
duration
,
@required
Curve
curve
,
})
async
{
// Do nothing, not required in test.
}
@override
ScrollDirection
get
userScrollDirection
=>
ScrollDirection
.
idle
;
@override
bool
get
allowImplicitScrolling
=>
false
;
}
void
main
(
)
{
void
main
(
)
{
test
(
'RenderSliverList basic test - down'
,
()
{
test
(
'RenderSliverList basic test - down'
,
()
{
RenderObject
inner
;
RenderObject
inner
;
...
@@ -254,6 +299,43 @@ void main() {
...
@@ -254,6 +299,43 @@ void main() {
expect
(
inner
.
geometry
.
scrollOffsetCorrection
,
isNull
);
expect
(
inner
.
geometry
.
scrollOffsetCorrection
,
isNull
);
});
});
test
(
'SliverList - no correction when tiny double precision error'
,
()
{
RenderSliverList
inner
;
RenderBox
a
;
final
TestRenderSliverBoxChildManager
childManager
=
TestRenderSliverBoxChildManager
(
children:
<
RenderBox
>[
a
=
RenderSizedBox
(
const
Size
(
100.0
,
400.0
)),
RenderSizedBox
(
const
Size
(
100.0
,
400.0
)),
RenderSizedBox
(
const
Size
(
100.0
,
400.0
)),
RenderSizedBox
(
const
Size
(
100.0
,
400.0
)),
RenderSizedBox
(
const
Size
(
100.0
,
400.0
)),
],
);
inner
=
childManager
.
createRenderObject
();
final
RenderViewport
root
=
RenderViewport
(
axisDirection:
AxisDirection
.
down
,
crossAxisDirection:
AxisDirection
.
right
,
offset:
ViewportOffset
.
zero
(),
children:
<
RenderSliver
>[
inner
,
],
);
layout
(
root
);
final
SliverMultiBoxAdaptorParentData
parentData
=
a
.
parentData
;
// Simulate double precision error.
parentData
.
layoutOffset
=
-
0.0000000000001
;
root
.
offset
=
ViewportOffset
.
fixed
(
900.0
);
pumpFrame
();
final
ViewportOffsetSpy
spy
=
ViewportOffsetSpy
(
0.0
);
root
.
offset
=
spy
;
pumpFrame
();
expect
(
spy
.
corrected
,
false
);
});
test
(
'SliverMultiBoxAdaptorParentData.toString'
,
()
{
test
(
'SliverMultiBoxAdaptorParentData.toString'
,
()
{
final
SliverMultiBoxAdaptorParentData
candidate
=
SliverMultiBoxAdaptorParentData
();
final
SliverMultiBoxAdaptorParentData
candidate
=
SliverMultiBoxAdaptorParentData
();
expect
(
candidate
.
keepAlive
,
isFalse
);
expect
(
candidate
.
keepAlive
,
isFalse
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment