Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash: IllegalStateException Invalid velocity = (NaN, NaN) px/sec #97

Closed
SimonMarquis opened this issue Aug 12, 2024 · 6 comments
Closed

Comments

@SimonMarquis
Copy link
Contributor

This crash (2,038 crash events affecting 1,235 users) is very similar to this issue that was fixed:

The difference is in the values (±Infinity vs NaN).

It is happening in versions 0.11.2 and 0.12.0 (0.12.1 was not tested), no specific Android version or manufacturer.

@saket
Copy link
Owner

saket commented Aug 15, 2024

Huh. Can you share the full stacktrace?

@SimonMarquis
Copy link
Contributor Author

me.saket.telephoto.zoomable.RealZoomableState.fling-BMRW4eQ$zoomable_release (RealZoomableState.java:152)
me.saket.telephoto.zoomable.ZoomableNode$onTransformStopped$1$1.invokeSuspend (Zoomable.kt:152)
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:9)
kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:93)
androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch (AndroidUiDispatcher.android.kt:15)
androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch (AndroidUiDispatcher.android.kt:15)
androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run (AndroidUiDispatcher.android.kt:3)
android.os.Handler.handleCallback (Handler.java:907)
android.os.Handler.dispatchMessage (Handler.java:105)
android.os.Looper.loop (Looper.java:216)
android.app.ActivityThread.main (ActivityThread.java:7625)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:987)

@irinamankov
Copy link

We also experience this bug in our project, but I have some additional info:

  1. Firstly we had compose-ui:1.6.4 and telephoto:0.7.1 and everything was fine
  2. Then we updated compose-ui up to 1.7.0-beta01 and started to receive this crash
  3. Finally, we decided to rollback compose-ui to 1.6.4 and update telephoto to 1.12.1 and crashes stopped to occur.

I was able to reproduce crash by zooming and tapping for a long time, but it is very difficult to catch. But users experienced it quite often.

So, in my case the reason was in 1.7.0 compose-ui version. I compared VelocityTracker's source code and saw that it was the same in 1.6.4-1.6.8 versions, but changed in 1.7.0, so may be problem is here

@SimonMarquis
Copy link
Contributor Author

I was wondering if we could try to detect (and drop) invalid Velocity earlier and not send them to prevent crashes in consumer code?

val maximumVelocity = currentValueOf(LocalViewConfiguration).let {
Velocity(it.maximumFlingVelocity, it.maximumFlingVelocity)
}
val velocity = if (wasCancelled) Velocity.Zero else velocityTracker.calculateVelocity(maximumVelocity)
channel.trySend(TransformStopped(velocity))

@saket
Copy link
Owner

saket commented Sep 14, 2024

Yep let's do that. VelocityTracker#calculateVelocity() only protects from large values, but not NaN.

@saket saket closed this as completed in d39c7b7 Sep 14, 2024
@saket
Copy link
Owner

saket commented Nov 13, 2024

0.14.0 is out with a fix: https://github.com/saket/telephoto/releases/tag/0.14.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants