Unverified Commit 362b999b authored by Amir Hardon's avatar Amir Hardon Committed by GitHub

Revert "Prevent exception being thrown on hasScrolledBody (#31485)" (#34061)

This reverts commit ab707aca.
parent d2e6ab69
......@@ -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.future;
await endOfFrame;
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;
......
......@@ -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);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment