fix(trim): guard coerceIn to prevent crash on clips shorter than MIN_TRIM_DURATION#96
Closed
claude[bot] wants to merge 1 commit into
Closed
fix(trim): guard coerceIn to prevent crash on clips shorter than MIN_TRIM_DURATION#96claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
When a clip shorter than MIN_TRIM_DURATION (400 ms) reached the Trim screen, FilmstripTrimSelector called coerceIn(400, 335) — an inverted range — throwing IllegalArgumentException. Guard each arithmetically- derived bound before the call so the range is never inverted regardless of clip length. Adds Lesson 025. Fixes #95 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
13 tasks
Owner
|
Superseded by #97, which applies the same guard via a pure, JVM-testable Generated by Claude Code |
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.
Summary
Fixes #95
Crash:
java.lang.IllegalArgumentException: Cannot coerce value to an empty range: maximum 335 is less than minimum 400inFilmstripTrimSelector(Crashlytics issue7169b499fee6554684dba69b1ae1a8f0, first seen v1.0.27).Root cause: When a clip shorter than
MIN_TRIM_DURATION(400 ms) reached the Trim screen, the drag handler and accessibility callbacks called:Kotlin's
Long.coerceInthrowsIllegalArgumentExceptionon inverted ranges.Fix: Pre-clamp each derived bound so the range is always valid, regardless of clip length:
When the clip is shorter than
MIN_TRIM_DURATIONboth handles become immovable, which is correct — the NEXT button is already disabled bytrimValidinTrimScreen.kt.Also: Adds
docs/lessons_learned/025-trim-coercein-range-guard-short-clip.mddocumenting the pattern.Files changed
ui/components/TrimFilmstripControls.ktcoerceIncalls with inverted-range-safe boundsdocs/lessons_learned/025-trim-coercein-range-guard-short-clip.mddocs/lessons_learned/README.mdDEFINITION_OF_DONE — steps NOT run on CI
Per
docs/DEFINITION_OF_DONE.md, the following could not be verified in this automated triage:./gradlew :app:assembleRelease) — CI has no signing keys./gradlew :app:lintDebug) — not runDebug build and unit tests should pass in CI.
Manual QA checklist