-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request DartPerformanceMode.latency
during transitions
#110600
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fc08e0e
Request a [DartPerformanceMode.latency] during transitions.
iskakaushik 9b988da
address CR comments
iskakaushik 5042ced
add validation for performance mode disposal
iskakaushik 327c3ec
createPerformanceModeRequest returns a `PerformanceModeRequestHandle`
iskakaushik b65ce6e
fix docs
iskakaushik 47a31ce
fix test failures
iskakaushik a2c45fb
partially address code review comments
iskakaushik 59e57c5
fix more failures
iskakaushik 0a097d2
fix remaining threads
iskakaushik 6d2f821
Update packages/flutter/lib/src/scheduler/binding.dart
iskakaushik 317e22a
Update packages/flutter/lib/src/scheduler/binding.dart
iskakaushik 0ad9650
Update packages/flutter/lib/src/scheduler/binding.dart
iskakaushik af6b55e
address changes except for writing a test
iskakaushik 633d54c
change cleanup callback to private
iskakaushik 583eb78
add a test to check performance mode during transitions
iskakaushik File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/flutter/test/scheduler/performance_mode_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:ui'; | ||
iskakaushik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import 'package:flutter/scheduler.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
late SchedulerBinding binding; | ||
|
||
setUpAll(() { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
binding = SchedulerBinding.instance; | ||
}); | ||
|
||
test('PerformanceModeHandler make one request', () async { | ||
final PerformanceModeRequestHandle? requestHandle = binding.requestPerformanceMode(DartPerformanceMode.latency); | ||
expect(requestHandle, isNotNull); | ||
expect(binding.debugGetRequestedPerformanceMode(), equals(DartPerformanceMode.latency)); | ||
requestHandle?.dispose(); | ||
expect(binding.debugGetRequestedPerformanceMode(), isNull); | ||
}); | ||
|
||
test('PerformanceModeHandler make conflicting requests', () async { | ||
final PerformanceModeRequestHandle? requestHandle1 = binding.requestPerformanceMode(DartPerformanceMode.latency); | ||
expect(requestHandle1, isNotNull); | ||
|
||
final PerformanceModeRequestHandle? requestHandle2 = binding.requestPerformanceMode(DartPerformanceMode.throughput); | ||
expect(requestHandle2, isNull); | ||
|
||
expect(binding.debugGetRequestedPerformanceMode(), equals(DartPerformanceMode.latency)); | ||
|
||
requestHandle1?.dispose(); | ||
expect(binding.debugGetRequestedPerformanceMode(), isNull); | ||
}); | ||
|
||
test('PerformanceModeHandler revert only after last requestor disposed', | ||
() async { | ||
final PerformanceModeRequestHandle? requestHandle1 = binding.requestPerformanceMode(DartPerformanceMode.latency); | ||
expect(requestHandle1, isNotNull); | ||
|
||
expect(binding.debugGetRequestedPerformanceMode(), equals(DartPerformanceMode.latency)); | ||
|
||
final PerformanceModeRequestHandle? requestHandle2 = binding.requestPerformanceMode(DartPerformanceMode.latency); | ||
expect(requestHandle2, isNotNull); | ||
|
||
expect(binding.debugGetRequestedPerformanceMode(), equals(DartPerformanceMode.latency)); | ||
requestHandle1?.dispose(); | ||
expect(binding.debugGetRequestedPerformanceMode(), equals(DartPerformanceMode.latency)); | ||
requestHandle2?.dispose(); | ||
expect(binding.debugGetRequestedPerformanceMode(), isNull); | ||
}); | ||
} | ||
iskakaushik marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just delete this and use
VoidCallback
directly wherever_PerformanceModeCleaupCallback
is currently used.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's useful for the reader, makes it easy to understand that this type is called when the performance mode is resolved. Let me know if you feel strongly about it, and I can change it up in a follow-up PR.