Repository: flutter
Issue: Assertion Error on device with 120hz refresh rate "The following assertion was thrown during a scheduler callback: 'elapsedInSeconds >= 0.0': is not true."
Labels: e: device-specific,engine,a: animation,a: error message,P2,team-engine,triaged-engine

## Summary as of 2024-08:
* The issue appears on a wide range of devices and platforms, but only with a refresh rate of 120 Hz or greater. (https://github.com/flutter/flutter/issues/106277#issuecomment-2263813654)
* The impact of this issue is in debug builds only, but it's severe there: the app crashes, making it impossible to continue short of a restart. For apps where the issue triggers frequently, this can make it difficult to develop on a device with a ≥120 Hz refresh rate.
* Thumbs-up this issue if you run into it

Original report follows.

---

I have an issue that only arises on my S22 Ultra. It does not occur within Android emulator, iPhone simulator, or a physical iPhone X. I only have one physical android device to test on.

The issue is unpredictable, but usually occurs after tapping something with an InkWell. It occurs throughout my app. However, I believe the issue to be related to animations. While it usually occurs after tapping an InkWell, it also can occur doing any other animation, such as the animation closing a ModalBottomSheet.

Recreating the issue is challenging, as it is insanely unpredictable. I'll sit and tap on a few buttons with InkWell's repeatedly, trying to get the issue to arise... And nothing. Then I'll go about using my app... And the error will pop-up. It has been going on for nearly a month.

It can occur shortly after launch, or well into testing features. 

After closing a modalBottomSheet:
```
[  +53 ms] I/flutter (12013): ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
[        ] I/flutter (12013): The following assertion was thrown during a scheduler callback:
[        ] I/flutter (12013): 'package:flutter/src/animation/animation_controller.dart': Failed assertion: line 822 pos 12:
[        ] I/flutter (12013): 'elapsedInSeconds >= 0.0': is not true.
[        ] I/flutter (12013): 
[        ] I/flutter (12013): Either the assertion indicates an error in the framework itself, or we should provide substantially
[        ] I/flutter (12013): more information in this error message to help you determine and fix the underlying cause.
[        ] I/flutter (12013): In either case, please report this assertion by filing a bug on GitHub:
[        ] I/flutter (12013):   https://github.com/flutter/flutter/issues/new?template=2_bug.md
[        ] I/flutter (12013): 
[        ] I/flutter (12013): When the exception was thrown, this was the stack:
[        ] I/flutter (12013): #2      AnimationController._tick (package:flutter/src/animation/animation_controller.dart:822:12)
[        ] I/flutter (12013): #3      Ticker._tick (package:flutter/src/scheduler/ticker.dart:238:12)
[        ] I/flutter (12013): #4      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1146:15)
[        ] I/flutter (12013): #5      SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:1059:11)
[        ] I/flutter (12013): #6      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:614:13)
[        ] I/flutter (12013): #7      SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:1057:17)
[        ] I/flutter (12013): #8      SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:976:5)
[        ] I/flutter (12013): #12     _invoke1 (dart:ui/hooks.dart:170:10)
[  +18 ms] I/flutter (12013): #13     PlatformDispatcher._beginFrame (dart:ui/platform_dispatcher.dart:286:5)
[        ] I/flutter (12013): #14     _beginFrame (dart:ui/hooks.dart:104:31)
[        ] I/flutter (12013): (elided 5 frames from class _AssertionError and dart:async)
[        ] I/flutter (12013): 
[        ] I/flutter (12013): 
[        ] I/flutter (12013): This exception was thrown in the context of a scheduler callback. When the scheduler callback was _registered_ (as opposed to when the exception was thrown), this was the stack:
[        ] I/flutter (12013): #2      SchedulerBinding.scheduleFrameCallback (package:flutter/src/scheduler/binding.dart:529:49)
[        ] I/flutter (12013): #3      Ticker.scheduleTick (package:flutter/src/scheduler/ticker.dart:253:46)
[        ] I/flutter (12013): #4      Ticker.start (package:flutter/src/scheduler/ticker.dart:162:7)
[        ] I/flutter (12013): #5      AnimationController._startSimulation (package:flutter/src/animation/animation_controller.dart:745:42)
[        ] I/flutter (12013): #6      AnimationController._animateToInternal (package:flutter/src/animation/animation_controller.dart:612:12)
[        ] I/flutter (12013): #7      AnimationController.reverse (package:flutter/src/animation/animation_controller.dart:494:12)
[        ] I/flutter (12013): #8      TransitionRoute.didPop (package:flutter/src/widgets/routes.dart:262:18)
[        ] I/flutter (12013): #9      LocalHistoryRoute.didPop (package:flutter/src/widgets/routes.dart:670:18)
[        ] I/flutter (12013): #10     _RouteEntry.handlePop (package:flutter/src/widgets/navigator.dart:2896:16)
[        ] I/flutter (12013): #11     NavigatorState._flushHistoryUpdates (package:flutter/src/widgets/navigator.dart:3868:22)
[        ] I/flutter (12013): #12     NavigatorState.pop (package:flutter/src/widgets/navigator.dart:4910:7)
[        ] I/flutter (12013): #13     NavigatorState.maybePop (package:flutter/src/widgets/navigator.dart:4860:9)
[        ] I/flutter (12013): <asynchronous suspension>
[        ] I/flutter (12013): (elided 2 frames from class _FrameCallbackEntry)
[        ] I/flutter (12013): ════════════════════════════════════════════════════════════════════════════════════════════════════
```

After tapping an InkWell:

```
I/flutter (13227): ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (13227): The following assertion was thrown during a scheduler callback:
I/flutter (13227): 'package:flutter/src/animation/animation_controller.dart': Failed assertion: line 822 pos 12:
package:flutter/…/animation/animation_controller.dart:822
I/flutter (13227): 'elapsedInSeconds >= 0.0': is not true.
I/flutter (13227):
I/flutter (13227): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (13227): more information in this error message to help you determine and fix the underlying cause.
I/flutter (13227): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (13227):   https://github.com/flutter/flutter/issues/new?template=2_bug.md
I/flutter (13227):
I/flutter (13227): When the exception was thrown, this was the stack:
I/flutter (13227): #2      AnimationController._tick
package:flutter/…/animation/animation_controller.dart:822
I/flutter (13227): #3      Ticker._tick
package:flutter/…/scheduler/ticker.dart:238
I/flutter (13227): #4      SchedulerBinding._invokeFrameCallback
package:flutter/…/scheduler/binding.dart:1146
I/flutter (13227): #5      SchedulerBinding.handleBeginFrame.<anonymous closure>
package:flutter/…/scheduler/binding.dart:1059
I/flutter (13227): #6      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:614:13)
I/flutter (13227): #7      SchedulerBinding.handleBeginFrame
package:flutter/…/scheduler/binding.dart:1057
I/flutter (13227): #8      SchedulerBinding._handleBeginFrame
package:flutter/…/scheduler/binding.dart:976
I/flutter (13227): #12     _invoke1 (dart:ui/hooks.dart:170:10)
2
I/flutter (13227):
I/flutter (13227): This exception was thrown in the context of a scheduler callback. When the scheduler callback was _registered_ (as opposed to when the exception was thrown), this was the stack:
I/flutter (13227): #2      SchedulerBinding.scheduleFrameCallback
package:flutter/…/scheduler/binding.dart:529
I/flutter (13227): #3      Ticker.scheduleTick
package:flutter/…/scheduler/ticker.dart:253
I/flutter (13227): #4      Ticker.start
package:flutter/…/scheduler/ticker.dart:162
I/flutter (13227): #5      AnimationController._startSimulation
package:flutter/…/animation/animation_controller.dart:745
I/flutter (13227): #6      AnimationController._animateToInternal
package:flutter/…/animation/animation_controller.dart:612
I/flutter (13227): #7      AnimationController.forward
package:flutter/…/animation/animation_controller.dart:461
I/flutter (13227): #8      InkSplash.confirm
package:flutter/…/material/ink_splash.dart:178
I/flutter (13227): #9      _InkResponseState._handleTap
package:flutter/…/material/ink_well.dart:999
I/flutter (13227): #10     GestureRecognizer.invokeCallback
package:flutter/…/gestures/recognizer.dart:198
I/flutter (13227): #11     TapGestureRecognizer.handleTapUp
package:flutter/…/gestures/tap.dart:613
I/flutter (13227): #12     BaseTapGestureRecognizer._checkUp
package:flutter/…/gestures/tap.dart:298
I/flutter (13227): #13     BaseTapGestureRecognizer.acceptGesture
package:flutter/…/gestures/tap.dart:269
I/flutter (13227): #14     GestureArenaManager.sweep
package:flutter/…/gestures/arena.dart:157
I/flutter (13227): #15     GestureBinding.handleEvent
package:flutter/…/gestures/binding.dart:449
I/flutter (13227): #16     GestureBinding.dispatchEvent
package:flutter/…/gestures/binding.dart:425
I/flutter (13227): #17     RendererBinding.dispatchEvent
package:flutter/…/rendering/binding.dart:329
I/flutter (13227): #18     GestureBinding._handlePointerEventImmediately
package:flutter/…/gestures/binding.dart:380
I/flutter (13227): #19     GestureBinding.handlePointerEvent
package:flutter/…/gestures/binding.dart:344
I/flutter (13227): #20     GestureBinding._flushPointerEventQueue
package:flutter/…/gestures/binding.dart:302
I/flutter (13227): #21     GestureBinding._handlePointerDataPacket
package:flutter/…/gestures/binding.dart:285
I/flutter (13227): #25     _invoke1 (dart:ui/hooks.dart:170:10)
I/flutter (13227): #26     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:331:7)
I/flutter (13227): #27     _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)
I/flutter (13227): (elided 5 frames from class _FrameCallbackEntry and dart:async)
I/flutter (13227): ════════════════════════════════════════════════════════════════════════════════════════════════════
3
I/flutter (13227): Another exception was thrown: 'package:flutter/src/animation/animation_controller.dart': Failed assertion: line 822 pos 12: 'elapsedInSeconds >= 0.0': is not true.
package:flutter/…/animation/animation_contro
```

Flutter doctor:

```
[√] Flutter (Channel stable, 3.0.2, on Microsoft Windows [Version 10.0.22000.739], locale en-US)
    • Flutter version 3.0.2 at D:\Development\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cd41fdd495 (11 days ago), 2022-06-08 09:52:13 -0700
    • Engine revision f15f824b57
    • Dart version 2.17.3
    • DevTools version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at C:\Users\Colton\AppData\Local\Android\sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] VS Code (version 1.68.0)
    • VS Code at C:\Users\Colton\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.42.0

[√] VS Code, 64-bit edition (version 1.68.0)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.42.0

[√] Connected device (5 available)
    • SM S908U (mobile)                  • R5CT505PFPB   • android-arm64  • Android 12 (API 31)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)                  • windows       • windows-x64    • Microsoft Windows [Version 10.0.22000.739]
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome 101.0.4951.67
    • Edge (web)                         • edge          • web-javascript • Microsoft Edge 102.0.1245.44

[√] HTTP Host Availability
    • All required HTTP hosts are available
```

Thanks all!