Unverified Commit 499e900e authored by wangying's avatar wangying Committed by GitHub

Fix timer keeps active when resampling disabled in some cases (#97197)

parent 3669e366
......@@ -180,6 +180,7 @@ class _Resampler {
}
_resamplers.clear();
_frameTime = Duration.zero;
_timer?.cancel();
}
void _onSampleTimeChanged() {
......
......@@ -123,4 +123,20 @@ void main() {
expect(events[3].timeStamp, currentTestFrameTime() + kSamplingOffset);
expect(events[3], isA<PointerUpEvent>());
});
testWidgets('Timer should be canceled when resampling stopped', (WidgetTester tester) async {
// A timer will be started when event's timeStamp is larger than sampleTime.
final ui.PointerDataPacket packet = ui.PointerDataPacket(
data: <ui.PointerData>[
ui.PointerData(
timeStamp: Duration(microseconds: DateTime.now().microsecondsSinceEpoch),
),
],
);
GestureBinding.instance.resamplingEnabled = true;
ui.window.onPointerDataPacket!(packet);
// Expected to stop resampling, but the timer keeps active if _timer?.cancel() not be called.
GestureBinding.instance.resamplingEnabled = 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