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
6b680373
Unverified
Commit
6b680373
authored
Dec 14, 2017
by
xster
Committed by
GitHub
Dec 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more checks to scheduleWarmUpFrame (#13552)
* Add more checks to scheduleWarmUpFrame * review * add test
parent
20fb6621
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
binding.dart
packages/flutter/lib/src/scheduler/binding.dart
+6
-1
scheduler_test.dart
packages/flutter/test/scheduler/scheduler_test.dart
+27
-1
No files found.
packages/flutter/lib/src/scheduler/binding.dart
View file @
6b680373
...
...
@@ -669,9 +669,14 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding {
/// If a frame has already been scheduled with [scheduleFrame] or
/// [scheduleForcedFrame], this call may delay that frame.
///
/// If any scheduled frame has already begun or if another
/// [scheduleWarmUpFrame] was already called, this call will be ignored.
///
/// Prefer [scheduleFrame] to update the display in normal operation.
void
scheduleWarmUpFrame
()
{
assert
(!
_warmUpFrame
);
if
(
_warmUpFrame
||
schedulerPhase
!=
SchedulerPhase
.
idle
)
return
;
final
bool
hadScheduledFrame
=
_hasScheduledFrame
;
_warmUpFrame
=
true
;
// We use timers here to ensure that microtasks flush in between.
...
...
packages/flutter/test/scheduler/scheduler_test.dart
View file @
6b680373
// Copyright 2015 The Chromium 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:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/scheduler.dart'
;
...
...
@@ -18,8 +19,12 @@ class TestStrategy {
}
void
main
(
)
{
SchedulerBinding
scheduler
;
setUpAll
(()
{
scheduler
=
new
TestSchedulerBinding
();
});
test
(
'Tasks are executed in the right order'
,
()
{
final
SchedulerBinding
scheduler
=
new
TestSchedulerBinding
();
final
TestStrategy
strategy
=
new
TestStrategy
();
scheduler
.
schedulingStrategy
=
strategy
.
shouldRunTaskWithPriority
;
final
List
<
int
>
input
=
<
int
>[
2
,
23
,
23
,
11
,
0
,
80
,
3
];
...
...
@@ -84,4 +89,25 @@ void main() {
expect
(
executedTasks
,
hasLength
(
1
));
expect
(
executedTasks
[
0
],
equals
(
0
));
});
test
(
'2 calls to scheduleWarmUpFrame just schedules it once'
,
()
{
final
List
<
VoidCallback
>
timerQueueTasks
=
<
VoidCallback
>[];
runZoned
(
()
{
// Run it twice without processing the queued tasks.
scheduler
.
scheduleWarmUpFrame
();
scheduler
.
scheduleWarmUpFrame
();
},
zoneSpecification:
new
ZoneSpecification
(
createTimer:
(
Zone
self
,
ZoneDelegate
parent
,
Zone
zone
,
Duration
duration
,
void
f
())
{
// Don't actually run the tasks, just record that it was scheduled.
timerQueueTasks
.
add
(
f
);
return
null
;
},
),
);
// A single call to scheduleWarmUpFrame queues up 2 Timer tasks.
expect
(
timerQueueTasks
.
length
,
2
);
});
}
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