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
65c71d42
Unverified
Commit
65c71d42
authored
Oct 28, 2023
by
Polina Cherkasova
Committed by
GitHub
Oct 28, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instrument more disposables. (#137309)
parent
fea56130
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
3 deletions
+44
-3
animation_controller.dart
packages/flutter/lib/src/animation/animation_controller.dart
+6
-2
overlay.dart
packages/flutter/lib/src/widgets/overlay.dart
+23
-1
flutter_test_config.dart
packages/flutter/test/flutter_test_config.dart
+3
-0
overlay_test.dart
packages/flutter/test/widgets/overlay_test.dart
+12
-0
No files found.
packages/flutter/lib/src/animation/animation_controller.dart
View file @
65c71d42
...
...
@@ -246,7 +246,9 @@ class AnimationController extends Animation<double>
required
TickerProvider
vsync
,
})
:
assert
(
upperBound
>=
lowerBound
),
_direction
=
_AnimationDirection
.
forward
{
_maybeDispatchObjectCreation
();
if
(
kFlutterMemoryAllocationsEnabled
)
{
_maybeDispatchObjectCreation
();
}
_ticker
=
vsync
.
createTicker
(
_tick
);
_internalSetValue
(
value
??
lowerBound
);
}
...
...
@@ -278,7 +280,9 @@ class AnimationController extends Animation<double>
})
:
lowerBound
=
double
.
negativeInfinity
,
upperBound
=
double
.
infinity
,
_direction
=
_AnimationDirection
.
forward
{
_maybeDispatchObjectCreation
();
if
(
kFlutterMemoryAllocationsEnabled
)
{
_maybeDispatchObjectCreation
();
}
_ticker
=
vsync
.
createTicker
(
_tick
);
_internalSetValue
(
value
);
}
...
...
packages/flutter/lib/src/widgets/overlay.dart
View file @
65c71d42
...
...
@@ -14,6 +14,8 @@ import 'framework.dart';
import
'lookup_boundary.dart'
;
import
'ticker_provider.dart'
;
const
String
_flutterWidgetsLibrary
=
'package:flutter/widgets.dart'
;
// Examples can assume:
// late BuildContext context;
...
...
@@ -81,7 +83,11 @@ class OverlayEntry implements Listenable {
bool
opaque
=
false
,
bool
maintainState
=
false
,
})
:
_opaque
=
opaque
,
_maintainState
=
maintainState
;
_maintainState
=
maintainState
{
if
(
kFlutterMemoryAllocationsEnabled
)
{
_maybeDispatchObjectCreation
();
}
}
/// This entry will include the widget built by this builder in the overlay at
/// the entry's position.
...
...
@@ -140,6 +146,19 @@ class OverlayEntry implements Listenable {
/// The currently mounted `_OverlayEntryWidgetState` built using this [OverlayEntry].
ValueNotifier
<
_OverlayEntryWidgetState
?>?
_overlayEntryStateNotifier
=
ValueNotifier
<
_OverlayEntryWidgetState
?>(
null
);
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
/// Dispatches event of object creation to [MemoryAllocations.instance].
void
_maybeDispatchObjectCreation
()
{
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectCreated
(
library
:
_flutterWidgetsLibrary
,
className:
'
$OverlayEntry
'
,
object:
this
,
);
}
}
@override
void
addListener
(
VoidCallback
listener
)
{
assert
(!
_disposedByOwner
);
...
...
@@ -216,6 +235,9 @@ class OverlayEntry implements Listenable {
void
dispose
()
{
assert
(!
_disposedByOwner
);
assert
(
_overlay
==
null
,
'An OverlayEntry must first be removed from the Overlay before dispose is called.'
);
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectDisposed
(
object:
this
);
}
_disposedByOwner
=
true
;
if
(!
mounted
)
{
// If we're still mounted when disposed, then this will be disposed in
...
...
packages/flutter/test/flutter_test_config.dart
View file @
65c71d42
...
...
@@ -33,6 +33,9 @@ Future<void> testExecutable(FutureOr<void> Function() testMain) {
.
withTrackedAll
()
.
withIgnored
(
allNotGCed:
true
,
notDisposed:
<
String
,
int
?>{
'OverlayEntry'
:
null
,
},
);
// Enable golden file testing using Skia Gold.
...
...
packages/flutter/test/widgets/overlay_test.dart
View file @
65c71d42
...
...
@@ -10,6 +10,18 @@ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import
'semantics_tester.dart'
;
void
main
(
)
{
test
(
'OverlayEntry dispatches memory events'
,
()
async
{
await
expectLater
(
await
memoryEvents
(
()
=>
OverlayEntry
(
builder:
(
BuildContext
context
)
=>
Container
(),
).
dispose
(),
OverlayEntry
,
),
areCreateAndDispose
,
);
});
testWidgetsWithLeakTracking
(
'OverflowEntries context contains Overlay'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
overlayKey
=
GlobalKey
();
bool
didBuild
=
false
;
...
...
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