telephoto: Crash while panning around

A user got a crash while panning around an image. I don’t have the image to reproduce it, but hopefully the crash logs will be enough :

Thread: main, Exception: java.lang.IllegalStateException: Size is unspecified
at androidx.compose.ui.geometry.Size.getWidth-impl(Size.kt:48)
at me.saket.telephoto.zoomable.internal.DimensKt.roundToIntSize-uvyYCjk(dimens.kt:13)
at me.saket.telephoto.zoomable.internal.ContentPlacementKt$calculateTopLeftToOverlapWith$alignedOffset$2.invoke-nOcc-ac(contentPlacement.kt:33)
at me.saket.telephoto.zoomable.internal.ContentPlacementKt$calculateTopLeftToOverlapWith$alignedOffset$2.invoke(contentPlacement.kt:28)
at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:81)
at me.saket.telephoto.zoomable.internal.ContentPlacementKt.calculateTopLeftToOverlapWith_x_KDEd0$lambda$1(contentPlacement.kt:28)
at me.saket.telephoto.zoomable.internal.ContentPlacementKt.calculateTopLeftToOverlapWith-x_KDEd0(contentPlacement.kt:45)
at me.saket.telephoto.zoomable.ZoomableState$coerceWithinBounds$1.invoke-MK-Hz9U(ZoomableState.kt:331)
at me.saket.telephoto.zoomable.ZoomableState$coerceWithinBounds$1.invoke(ZoomableState.kt:329)
at me.saket.telephoto.zoomable.internal.DimensKt.withZoomAndTranslate-aysBKyA(dimens.kt:54)
at me.saket.telephoto.zoomable.ZoomableState.coerceWithinBounds-8S9VItk(ZoomableState.kt:329)
at me.saket.telephoto.zoomable.ZoomableState.access$coerceWithinBounds-8S9VItk(ZoomableState.kt:88)
at me.saket.telephoto.zoomable.ZoomableState$transformableState$1.invoke-0DeBYlg(ZoomableState.kt:260)
at me.saket.telephoto.zoomable.ZoomableState$transformableState$1.invoke(ZoomableState.kt:197)
at me.saket.telephoto.zoomable.internal.DefaultTransformableState$transformScope$1.transformBy-0DeBYlg(transformableState.kt:111)
at me.saket.telephoto.zoomable.internal.TransformScope$-CC.transformBy-0DeBYlg$default(transformableState.kt:66)
at me.saket.telephoto.zoomable.ZoomableState$fling$2$1.invoke(ZoomableState.kt:470)
at me.saket.telephoto.zoomable.ZoomableState$fling$2$1.invoke(ZoomableState.kt:469)
at androidx.compose.animation.core.SuspendAnimationKt.doAnimationFrame(SuspendAnimation.kt:361)
at androidx.compose.animation.core.SuspendAnimationKt.doAnimationFrameWithScale(SuspendAnimation.kt:339)
at androidx.compose.animation.core.SuspendAnimationKt.access$doAnimationFrameWithScale(SuspendAnimation.kt:1)
at androidx.compose.animation.core.SuspendAnimationKt$animate$6.invoke(SuspendAnimation.kt:251)
at androidx.compose.animation.core.SuspendAnimationKt$animate$6.invoke(SuspendAnimation.kt:239)
at androidx.compose.animation.core.SuspendAnimationKt$callWithFrameNanos$2.invoke(SuspendAnimation.kt:304)
at androidx.compose.animation.core.SuspendAnimationKt$callWithFrameNanos$2.invoke(SuspendAnimation.kt:303)
at androidx.compose.runtime.BroadcastFrameClock$FrameAwaiter.resume(BroadcastFrameClock.kt:42)
at androidx.compose.runtime.BroadcastFrameClock.sendFrame(BroadcastFrameClock.kt:71)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:517)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:510)
at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34)
at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1035)
at android.view.Choreographer.doCallbacks(Choreographer.java:845)
at android.view.Choreographer.doFrame(Choreographer.java:775)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7870)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@b094cc0, androidx.compose.runtime.BroadcastFrameClock@4d85df9, StandaloneCoroutine{Cancelling}@458113e, AndroidUiDispatcher@2b46b9f]

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 23 (14 by maintainers)

Commits related to this issue

Most upvoted comments

No worries, I should have bumped up the snapshot version to avoid this confusion.

FWIW I was able to reproduce a situation where quick zooms would result in a division by zero error and it looks awfully similar to this crash. I’m not 100% sure it’s the same one because @igorilin13’s stacktrace in https://github.com/saket/telephoto/issues/41#issuecomment-1701315404 indicates that a fling was made before the crash occurred, but 🤞! I’ll make a new release soon.

0.7.1 should hopefully mark the end of this issue. I’ll keep this open for a few months just to be sure.

Huh these logs suggest that I’ve been investigating in the wrong direction all this time. The infinite offset isn’t being calculated by any division by zero errors, but rather an infinite velocity tracked by the gesture receiver. I’ve added a few more logs to confirm this. Please keep sending the stacktraces, and thanks again!

Interesting, can you include the full stacktrace? It is unclear where the crash is happening.

I edited the stacktrace above, but now that I look at it again this might be an actual bug in our code that I mistook for this issue. I saw IllegalArgumentException and coerceIn and I assumed it was the same issue, but looking at the previous stacktraces, it should be IllegalStateException and coerceWithingBounds instead.

it’s not in sonatype’s snapshot repository.

Hmmm that doesn’t sound right. Can you try again? You can find the snapshot artifacts here:

https://oss.sonatype.org/content/repositories/snapshots/me/saket/telephoto/zoomable-image-coil/0.6.0-SNAPSHOT/

allprojects {
  repositories {
    …
    maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
  }
}