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
e5194724
Unverified
Commit
e5194724
authored
Apr 24, 2019
by
liyuqian
Committed by
GitHub
Apr 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't add empty OpacityLayer to the engine (#31520)
Fixes
https://github.com/flutter/flutter/issues/31517
parent
d4e4726a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
layer.dart
packages/flutter/lib/src/rendering/layer.dart
+5
-2
opacity_test.dart
packages/flutter/test/widgets/opacity_test.dart
+10
-0
No files found.
packages/flutter/lib/src/rendering/layer.dart
View file @
e5194724
...
@@ -1242,6 +1242,9 @@ class TransformLayer extends OffsetLayer {
...
@@ -1242,6 +1242,9 @@ class TransformLayer extends OffsetLayer {
/// When debugging, setting [debugDisableOpacityLayers] to true will cause this
/// When debugging, setting [debugDisableOpacityLayers] to true will cause this
/// layer to be skipped (directly replaced by its children). This can be helpful
/// layer to be skipped (directly replaced by its children). This can be helpful
/// to track down the cause of performance problems.
/// to track down the cause of performance problems.
///
/// Try to avoid an [OpacityLayer] with no children. Remove that layer if
/// possible to save some tree walks.
class
OpacityLayer
extends
ContainerLayer
{
class
OpacityLayer
extends
ContainerLayer
{
/// Creates an opacity layer.
/// Creates an opacity layer.
///
///
...
@@ -1281,9 +1284,9 @@ class OpacityLayer extends ContainerLayer {
...
@@ -1281,9 +1284,9 @@ class OpacityLayer extends ContainerLayer {
@override
@override
ui
.
EngineLayer
addToScene
(
ui
.
SceneBuilder
builder
,
[
Offset
layerOffset
=
Offset
.
zero
])
{
ui
.
EngineLayer
addToScene
(
ui
.
SceneBuilder
builder
,
[
Offset
layerOffset
=
Offset
.
zero
])
{
bool
enabled
=
true
;
bool
enabled
=
firstChild
!=
null
;
// don't add this layer if there's no child
assert
(()
{
assert
(()
{
enabled
=
!
debugDisableOpacityLayers
;
enabled
=
enabled
&&
!
debugDisableOpacityLayers
;
return
true
;
return
true
;
}());
}());
if
(
enabled
)
if
(
enabled
)
...
...
packages/flutter/test/widgets/opacity_test.dart
View file @
e5194724
...
@@ -183,4 +183,14 @@ void main() {
...
@@ -183,4 +183,14 @@ void main() {
skip:
!
Platform
.
isLinux
,
skip:
!
Platform
.
isLinux
,
);
);
});
});
testWidgets
(
'empty opacity does not crash'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Opacity
(
opacity:
0.5
,
child:
Container
())),
);
final
Element
element
=
find
.
byType
(
RepaintBoundary
).
first
.
evaluate
().
single
;
// The following line will send the layer to engine and cause crash if an
// empty opacity layer is sent.
await
element
.
renderObject
.
layer
.
toImage
(
Rect
.
fromLTRB
(
0.0
,
0.0
,
1.0
,
1.0
));
});
}
}
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