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
cdcacd06
Unverified
Commit
cdcacd06
authored
Oct 31, 2023
by
Kostia Sokolovskyi
Committed by
GitHub
Oct 31, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PerformanceModeRequestHandle should dispatch creation and disposal events. (#137642)
parent
64d39370
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
binding.dart
packages/flutter/lib/src/scheduler/binding.dart
+16
-1
performance_mode_test.dart
packages/flutter/test/scheduler/performance_mode_test.dart
+11
-0
No files found.
packages/flutter/lib/src/scheduler/binding.dart
View file @
cdcacd06
...
...
@@ -196,7 +196,17 @@ typedef _PerformanceModeCleanupCallback = VoidCallback;
/// To create a [PerformanceModeRequestHandle], use [SchedulerBinding.requestPerformanceMode].
/// The component that makes the request is responsible for disposing the handle.
class
PerformanceModeRequestHandle
{
PerformanceModeRequestHandle
.
_
(
_PerformanceModeCleanupCallback
this
.
_cleanup
);
PerformanceModeRequestHandle
.
_
(
_PerformanceModeCleanupCallback
this
.
_cleanup
)
{
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectCreated
(
library
:
'package:flutter/scheduler.dart'
,
className:
'
$PerformanceModeRequestHandle
'
,
object:
this
,
);
}
}
_PerformanceModeCleanupCallback
?
_cleanup
;
...
...
@@ -206,6 +216,11 @@ class PerformanceModeRequestHandle {
/// This method must only be called once per object.
void
dispose
()
{
assert
(
_cleanup
!=
null
);
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectDisposed
(
object:
this
);
}
_cleanup
!();
_cleanup
=
null
;
}
...
...
packages/flutter/test/scheduler/performance_mode_test.dart
View file @
cdcacd06
...
...
@@ -7,6 +7,7 @@ import 'dart:ui';
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
void
main
(
)
{
late
SchedulerBinding
binding
;
...
...
@@ -53,4 +54,14 @@ void main() {
requestHandle2
?.
dispose
();
expect
(
binding
.
debugGetRequestedPerformanceMode
(),
isNull
);
});
test
(
'PerformanceModeRequestHandle dispatches memory events'
,
()
async
{
await
expectLater
(
await
memoryEvents
(
()
=>
binding
.
requestPerformanceMode
(
DartPerformanceMode
.
latency
)!.
dispose
(),
PerformanceModeRequestHandle
,
),
areCreateAndDispose
,
);
});
}
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