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
cfe7afdc
Unverified
Commit
cfe7afdc
authored
Oct 02, 2023
by
Kostia Sokolovskyi
Committed by
GitHub
Oct 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix memory leaks in WidgetInspector and WidgetInspectorService. (#135828)
parent
71acf242
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
305 additions
and
205 deletions
+305
-205
widget_inspector.dart
packages/flutter/lib/src/widgets/widget_inspector.dart
+21
-4
widget_inspector_test.dart
packages/flutter/test/widgets/widget_inspector_test.dart
+284
-201
No files found.
packages/flutter/lib/src/widgets/widget_inspector.dart
View file @
cfe7afdc
...
...
@@ -372,6 +372,12 @@ class _ScreenshotData {
set
screenshotOffset
(
Offset
offset
)
{
containerLayer
.
offset
=
offset
;
}
/// Releases allocated resources.
@mustCallSuper
void
dispose
()
{
containerLayer
.
dispose
();
}
}
/// A place to paint to build screenshots of [RenderObject]s.
...
...
@@ -550,7 +556,7 @@ class _ScreenshotPaintingContext extends PaintingContext {
Rect
renderBounds
,
{
double
pixelRatio
=
1.0
,
bool
debugPaint
=
false
,
})
{
})
async
{
RenderObject
repaintBoundary
=
renderObject
;
while
(!
repaintBoundary
.
isRepaintBoundary
)
{
repaintBoundary
=
repaintBoundary
.
parent
!;
...
...
@@ -604,7 +610,15 @@ class _ScreenshotPaintingContext extends PaintingContext {
// been called successfully for all layers in the regular scene.
repaintBoundary
.
debugLayer
!.
buildScene
(
ui
.
SceneBuilder
());
return
data
.
containerLayer
.
toImage
(
renderBounds
,
pixelRatio:
pixelRatio
);
final
ui
.
Image
image
;
try
{
image
=
await
data
.
containerLayer
.
toImage
(
renderBounds
,
pixelRatio:
pixelRatio
);
}
finally
{
data
.
dispose
();
}
return
image
;
}
}
...
...
@@ -1285,6 +1299,7 @@ mixin WidgetInspectorService {
return
<
String
,
Object
?>{
'result'
:
null
};
}
final
ByteData
?
byteData
=
await
image
.
toByteData
(
format:
ui
.
ImageByteFormat
.
png
);
image
.
dispose
();
return
<
String
,
Object
>{
'result'
:
base64
.
encoder
.
convert
(
Uint8List
.
view
(
byteData
!.
buffer
)),
...
...
@@ -3141,7 +3156,7 @@ class _InspectorOverlayLayer extends Layer {
_InspectorOverlayRenderState
?
_lastState
;
/// Picture generated from _lastState.
late
ui
.
Picture
_picture
;
ui
.
Picture
?
_picture
;
TextPainter
?
_textPainter
;
double
?
_textPainterMaxWidth
;
...
...
@@ -3150,6 +3165,7 @@ class _InspectorOverlayLayer extends Layer {
void
dispose
()
{
_textPainter
?.
dispose
();
_textPainter
=
null
;
_picture
?.
dispose
();
super
.
dispose
();
}
...
...
@@ -3184,9 +3200,10 @@ class _InspectorOverlayLayer extends Layer {
if
(
state
!=
_lastState
)
{
_lastState
=
state
;
_picture
?.
dispose
();
_picture
=
_buildPicture
(
state
);
}
builder
.
addPicture
(
Offset
.
zero
,
_picture
);
builder
.
addPicture
(
Offset
.
zero
,
_picture
!
);
}
ui
.
Picture
_buildPicture
(
_InspectorOverlayRenderState
state
)
{
...
...
packages/flutter/test/widgets/widget_inspector_test.dart
View file @
cfe7afdc
This diff is collapsed.
Click to expand it.
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