Repository navigation
Prevent frame-time regressions from crashing scene transitions - #228
Merged
isaac-udy merged 1 commit intoOct 1, 2026
Merged
Conversation
Some devices (observed on Huawei and Honor) occasionally deliver a Choreographer frame time earlier than the previous frame's. SeekableTransitionState does not tolerate this: while animating a transition whose total duration is zero (a scene change with no enter/exit animations), the negative frame delta produces a NaN fraction and the next seek crashes with "IllegalArgumentException: Cannot round NaN value" from SeekableTransitionState.seekToFraction. In NavigationDisplay this fires when a predictive-back gesture settles. NavigationDisplay now drives its SeekableTransitionState through a NonDecreasingFrameTime guard: a MonotonicFrameClock wrapper that clamps frame times to be non-decreasing. One instance is shared across the seek, animate and settle phases, so a regression across a phase boundary (a predictive-back seek handing over to the settle animation) is caught too. Same class of fix as arkivanov/Decompose#1022 for the identical crash; upstream report: https://issuetracker.google.com/issues/540477169 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Crash
Fatal on Android, reported through Crashlytics from production Game Locker builds:
Root cause
Some devices (observed in the wild on Huawei and Honor) occasionally deliver a Choreographer frame time earlier than the previous frame's.
SeekableTransitionStatedoesn't tolerate that: while animating a transition whose total duration is zero β a scene change with no enter/exit animations β the negative frame delta feedslerp(0f, 1f, -Infinity)-style math, the internal fraction becomes NaN, and the nextseekToFraction()throwsCannot round NaN value. InNavigationDisplaythis fires when a predictive-back gesture settles (theanimateToafter the gesture completes or cancels).This is the same crash Decompose diagnosed and fixed in arkivanov/Decompose#1022 (report: arkivanov/Decompose#1012); the underlying androidx report is issuetracker.google.com/issues/540477169. No released compose-animation version guards against it (checked 1.12.0 β
seekToFractionis unchanged).Fix
NavigationDisplaynow drives itsSeekableTransitionStatethrough a smallNonDecreasingFrameTimeguard: aMonotonicFrameClockwrapper that clamps frame times to be non-decreasing before they reach the animation. A single instance is shared across all three drive sites (the predictive-backseekTo, theanimateTo, and the settleseekTo/snapTo), so a regression across a phase boundary β e.g. a predictive-back seek handing over to the settle animation, which is where the zero-durationanimateToruns β is caught too. On well-behaved devices the clock is a pass-through.Tests
NonDecreasingFrameTimeTests(commonTest, passing on desktop): monotonic times pass through unchanged; a regression is clamped to the last seen frame time; the clamp is shared across separate invocations; and the guard degrades to a plaincoroutineScopewhen no frame clock is in the context.Note:
:enro-runtime:linkDebugFrameworkIosArm64currently fails onmainwithShouldn't be exposed: deserialized class MetadataKeyβ pre-existing (reproduced on a clean checkout of 4876fb3), unrelated to this change. Kotlin/Native klib compilation for iOS passes with this change.π€ Generated with Claude Code