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
362b999b
Unverified
Commit
362b999b
authored
Jun 07, 2019
by
Amir Hardon
Committed by
GitHub
Jun 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Prevent exception being thrown on hasScrolledBody (#31485)" (#34061)
This reverts commit
ab707aca
.
parent
d2e6ab69
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
65 deletions
+41
-65
binding.dart
packages/flutter/lib/src/scheduler/binding.dart
+22
-26
scheduler_test.dart
packages/flutter/test/scheduler/scheduler_test.dart
+19
-39
No files found.
packages/flutter/lib/src/scheduler/binding.dart
View file @
362b999b
...
...
@@ -763,38 +763,34 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
_warmUpFrame
=
true
;
Timeline
.
startSync
(
'Warm-up frame'
);
final
bool
hadScheduledFrame
=
_hasScheduledFrame
;
final
Completer
<
void
>
_warmUpFrameCompleter
=
Completer
<
void
>();
// We use timers here to ensure that microtasks flush in between.
Timer
.
run
(()
{
assert
(
_warmUpFrame
);
handleBeginFrame
(
null
);
});
Timer
.
run
(()
{
assert
(
_warmUpFrame
);
handleDrawFrame
();
// We call resetEpoch after this frame so that, in the hot reload case,
// the very next frame pretends to have occurred immediately after this
// warm-up frame. The warm-up frame's timestamp will typically be far in
// the past (the time of the last real frame), so if we didn't reset the
// epoch we would see a sudden jump from the old time in the warm-up frame
// to the new time in the "real" frame. The biggest problem with this is
// that implicit animations end up being triggered at the old time and
// then skipping every frame and finishing in the new time.
resetEpoch
();
_warmUpFrame
=
false
;
if
(
hadScheduledFrame
)
scheduleFrame
();
});
// Lock events so touch events etc don't insert themselves until the
// scheduled frame has finished.
lockEvents
(()
async
{
await
_warmUpFrameCompleter
.
futur
e
;
await
endOfFram
e
;
Timeline
.
finishSync
();
});
// We use scheduleMicrotask here to ensure that microtasks flush in between.
scheduleMicrotask
(()
{
assert
(
_warmUpFrame
);
handleBeginFrame
(
null
);
scheduleMicrotask
(()
{
assert
(
_warmUpFrame
);
handleDrawFrame
();
// We call resetEpoch after this frame so that, in the hot reload case,
// the very next frame pretends to have occurred immediately after this
// warm-up frame. The warm-up frame's timestamp will typically be far in
// the past (the time of the last real frame), so if we didn't reset the
// epoch we would see a sudden jump from the old time in the warm-up frame
// to the new time in the "real" frame. The biggest problem with this is
// that implicit animations end up being triggered at the old time and
// then skipping every frame and finishing in the new time.
resetEpoch
();
_warmUpFrame
=
false
;
_warmUpFrameCompleter
.
complete
();
if
(
hadScheduledFrame
)
scheduleFrame
();
});
});
}
Duration
_firstRawTimeStampInEpoch
;
...
...
packages/flutter/test/scheduler/scheduler_test.dart
View file @
362b999b
...
...
@@ -19,26 +19,6 @@ class TestStrategy {
}
}
List
<
VoidCallback
>
runWithMicrotaskQueueSpy
(
VoidCallback
callback
)
{
final
List
<
VoidCallback
>
microtaskQueue
=
<
VoidCallback
>[];
runZoned
<
void
>(
()
{
callback
();
},
zoneSpecification:
ZoneSpecification
(
scheduleMicrotask:
(
Zone
self
,
ZoneDelegate
parent
,
Zone
zone
,
void
f
())
{
// Don't actually run the tasks, just record that it was scheduled.
microtaskQueue
.
add
(
f
);
self
.
parent
.
scheduleMicrotask
(()
{
f
();
microtaskQueue
.
remove
(
f
);
});
},
),
);
return
microtaskQueue
;
}
void
main
(
)
{
SchedulerBinding
scheduler
;
setUpAll
(()
{
...
...
@@ -112,27 +92,27 @@ void main() {
});
test
(
'2 calls to scheduleWarmUpFrame just schedules it once'
,
()
{
final
List
<
VoidCallback
>
microtaskQueue
=
runWithMicrotaskQueueSpy
(()
{
scheduler
.
scheduleWarmUpFrame
();
scheduler
.
scheduleWarmUpFrame
();
});
// scheduleWarmUpFrame scheduled 1 microtask
expect
(
microtaskQueue
.
length
,
1
);
});
test
(
'Tasks are not executed before scheduleWarmUpFrame finishes'
,
()
async
{
final
List
<
VoidCallback
>
timerQueueTasks
=
<
VoidCallback
>[];
bool
taskExecuted
=
false
;
final
List
<
VoidCallback
>
microtaskQueue
=
runWithMicrotaskQueueSpy
(()
{
scheduler
.
scheduleTask
(()
{
taskExecuted
=
true
;
},
Priority
.
touch
);
Timer
.
run
(()
{
taskExecuted
=
true
;
});
runZoned
<
void
>(
()
{
// Run it twice without processing the queued tasks.
scheduler
.
scheduleWarmUpFrame
();
});
expect
(
microtaskQueue
.
isNotEmpty
,
true
);
await
scheduler
.
endOfFrame
;
expect
(
scheduler
.
schedulerPhase
,
SchedulerPhase
.
idle
);
scheduler
.
scheduleWarmUpFrame
();
scheduler
.
scheduleTask
(()
{
taskExecuted
=
true
;
},
Priority
.
touch
);
},
zoneSpecification:
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
;
},
),
);
// scheduleWarmUpFrame scheduled 2 Timers, scheduleTask scheduled 0 because
// events are locked.
expect
(
timerQueueTasks
.
length
,
2
);
expect
(
taskExecuted
,
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