telephoto icon indicating copy to clipboard operation
telephoto copied to clipboard

IllegalStateException: maximumVelocity should be a positive value

Open SimonMarquis opened this issue 2 months ago • 16 comments

We are seeing a pretty substantial amount of errors in the latest version (0.9.0) that leads to this method:

https://github.com/saket/telephoto/blob/3e0c5573151e64908a024425bda9cd0be19f4d68/zoomable/src/commonMain/kotlin/me/saket/telephoto/zoomable/internal/transformable.kt#L152

And all the stacktraces look like this (with value 0.0):

Fatal Exception: java.lang.IllegalStateException
maximumVelocity should be a positive value. You specified=0.0
androidx.compose.ui.input.pointer.util.VelocityTracker1D.calculateVelocity (VelocityTracker.kt:283)
androidx.compose.ui.input.pointer.util.VelocityTracker.calculateVelocity-AH228Gc (VelocityTracker.kt:102)
me.saket.telephoto.zoomable.internal.TransformableNode$pointerInputNode$1$1$2.invokeSuspend (transformable.kt:152)
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
kotlinx.coroutines.DispatchedTaskKt.resume (DispatchedTask.kt:175)
kotlinx.coroutines.DispatchedTaskKt.dispatch (DispatchedTask.kt:164)

or this (with a tiny value, that looks like a 0 approximation in float):

Fatal Exception: java.lang.IllegalStateException
maximumVelocity should be a positive value. You specified=-1.3029473E-34
androidx.compose.ui.input.pointer.util.VelocityTracker1D.calculateVelocity (VelocityTracker.kt:283)
androidx.compose.ui.input.pointer.util.VelocityTracker.calculateVelocity-AH228Gc (VelocityTracker.kt:102)
me.saket.telephoto.zoomable.internal.TransformableNode$pointerInputNode$1$1$2.invokeSuspend (transformable.kt:152)
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
kotlinx.coroutines.DispatchedTaskKt.resume (DispatchedTask.kt:175)
kotlinx.coroutines.DispatchedTaskKt.dispatch (DispatchedTask.kt:164)

I'm not sure why it would throw here to be honest, since we always provide sane values Velocity(Int.MAX_VALUE.toFloat(), Int.MAX_VALUE.toFloat()). Could this be an issue with the devices packing floats incorrectly?

The device repartition is as follow:

  • 70% Huawei
  • 20% Samsung
  • 6% Xiaomi
  • 1% Hisense
  • 3% Other (6)

SimonMarquis avatar Apr 09 '24 08:04 SimonMarquis