saket / telephoto

Building blocks for designing media experiences in Compose UI
https://saket.github.io/telephoto/
Apache License 2.0
1k stars 33 forks source link

Crash when refreshContentTransformation is called #36

Closed pawelcala closed 1 year ago

pawelcala commented 1 year ago

Using ZoomableAsyncImages inside HorizontalPager. If I use animateScrollToPage on PagerState to second next page (suppose not loaded yet) i get crash:

java.lang.IllegalStateException: Check failed.
    at me.saket.telephoto.zoomable.ZoomableState.refreshContentTransformation$zoomable_release(ZoomableState.kt:367)
    at me.saket.telephoto.zoomable.ZoomableStateKt$rememberZoomableState$1$1.invokeSuspend(ZoomableState.kt:82)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
    at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
    at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
    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:7839)
    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@c0693d9, androidx.compose.runtime.BroadcastFrameClock@2af419e, StandaloneCoroutine{Cancelling}@8d1447f, AndroidUiDispatcher@d330c4c]

Occurs every time.

saket commented 1 year ago

I've been trying to investigate this for many weeks but it has proved difficult to reproduce! If you're able to consistently run into this, could you please share a reproducer project or a fork branch?

pawelcala commented 1 year ago

https://gist.github.com/pawelcala/68fa20a41e37c1868a81f16bfea81856

if you go few times between first and last item the crash will eventually occur.

MV-GH commented 1 year ago

Also had this happen but not in a horizontalpager. Just inside a box with .fillMaxSize(), (v1.0.0-alpha02)

I cant' reliable reproduce it, but I had this happen by opening a image (which opens a imageviewer and creates a ZoomableAsyncImage) And quickly double tapping on the image. Basically as soon as I see the image come in view.

stacktrace but its the same as above FATAL EXCEPTION: main Process: com.jerboa.debug, PID: 8556 java.lang.IllegalStateException: Check failed. at me.saket.telephoto.zoomable.ZoomableState.refreshContentTransformation$zoomable_release(ZoomableState.kt:355) at me.saket.telephoto.zoomable.ZoomableStateKt$rememberZoomableState$1$1.invokeSuspend(ZoomableState.kt:72) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81) at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41) at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:236) at android.app.ActivityThread.main(ActivityThread.java:8061) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@9f866f1, androidx.compose.runtime.BroadcastFrameClock@d8772d6, StandaloneCoroutine{Cancelling}@f2d4957, AndroidUiDispatcher@2eaec44] getRecentTasks: taskId=12048 userId=0 baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.jerboa.debug/com.jerboa.MainActivity }
saket commented 1 year ago

Whoops I misread the original stacktrace and confused it with a different bug. This one is already fixed on trunk. Would either of you two mind using 0.5.0-SNAPSHOT until I'm able to make a stable release?

MV-GH commented 1 year ago

How can I use 5.0.0-SNAPSHOT ? I used v1.0.0-alpha02 because that was the latest I could find. I have included the snapshots url https://oss.sonatype.org/content/repositories/snapshots/ in my repositories.

image

saket commented 1 year ago

Snapshot versions are hosted on a separate maven repository which will need to be added to your buildscript:

repositories {
  google()
  mavenCentral()
  maven {
    url 'https://oss.sonatype.org/content/repositories/snapshots/'
  }
}

1.0.0-alpha02 is actually older than 0.1.0. I was originally planning to use 1.0.0 as telephoto's first version but I realized I should iron out any bugs first. Sorry for the confusion!

MV-GH commented 1 year ago

nvm, had settings.gradle overriding everything

saket commented 1 year ago

Lol yea sorry I meant 0.5.0 and not 5.0.0. I'm going ahead and closing this issue. Please re-open if you continue to see it?