saket / telephoto

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

Crash when opening portrait photos in landscape #49

Closed Level6LaserLotus closed 9 months ago

Level6LaserLotus commented 9 months ago

After updating from 0.5.0 to 0.6.1 I get crashes when opening portrait photos in landscape. Im using the following code (works with 0.5.0):

ZoomableAsyncImage(
    model = photoUrl,
    contentDescription = null,
    modifier = Modifier
        .fillMaxSize()
        .background(Color.Black)
)

The crash:

java.lang.IllegalArgumentException: Cannot coerce value to an empty range: maximum 1080 is less than minimum 1102.
at kotlin.ranges.RangesKt___RangesKt.coerceIn(_Ranges.kt:1413)
at me.saket.telephoto.subsamplingimage.internal.DimensKt.coerceIn-dFh3_74(dimens.kt:16)
at me.saket.telephoto.subsamplingimage.internal.TileGridGeneratorKt.generate-JPKKBEo(tileGridGenerator.kt:32)
at me.saket.telephoto.subsamplingimage.SubSamplingImageStateKt$rememberSubSamplingImageState$5$1$invokeSuspend$$inlined$flatMapLatest$1.invokeSuspend(Merge.kt:216)
at me.saket.telephoto.subsamplingimage.SubSamplingImageStateKt$rememberSubSamplingImageState$5$1$invokeSuspend$$inlined$flatMapLatest$1.invoke(Unknown Source:21)
at me.saket.telephoto.subsamplingimage.SubSamplingImageStateKt$rememberSubSamplingImageState$5$1$invokeSuspend$$inlined$flatMapLatest$1.invoke(Unknown Source:4)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(Merge.kt:34)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Unknown Source:8)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Unknown Source:4)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:44)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:112)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1.emit(Merge.kt:33)
at me.saket.telephoto.subsamplingimage.SubSamplingImageStateKt$rememberSubSamplingImageState$5$1$invokeSuspend$$inlined$filter$1$2.emit(Emitters.kt:223)
at kotlinx.coroutines.flow.FlowKt__TransformKt$filterNotNull$$inlined$unsafeTransform$1$2.emit(Emitters.kt:223)
at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:15)
at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:15)
at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:87)
at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:66)
at androidx.compose.runtime.SnapshotStateKt__SnapshotFlowKt$snapshotFlow$1.invokeSuspend(SnapshotFlow.kt:133)
at androidx.compose.runtime.SnapshotStateKt__SnapshotFlowKt$snapshotFlow$1.invoke(Unknown Source:8)
at androidx.compose.runtime.SnapshotStateKt__SnapshotFlowKt$snapshotFlow$1.invoke(Unknown Source:4)
at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61)
at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:230)
at kotlinx.coroutines.flow.FlowKt__TransformKt$filterNotNull$$inlined$unsafeTransform$1.collect(SafeCollector.common.kt:114)
at me.saket.telephoto.subsamplingimage.SubSamplingImageStateKt$rememberSubSamplingImageState$5$1$invokeSuspend$$inlined$filter$1.collect(SafeCollector.common.kt:113)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invokeSuspend(Merge.kt:27)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invoke(Unknown Source:8)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invoke(Unknown Source:4)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78)
at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest.flowCollect(Merge.kt:25)
at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo$suspendImpl(ChannelFlow.kt:157)
at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo(Unknown Source:0)
at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(ChannelFlow.kt:60)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@8f2a5b1, androidx.compose.runtime.BroadcastFrameClock@5b2aa96, StandaloneCoroutine{Cancelling}@3108617, AndroidUiDispatcher@3ae4a04]
saket commented 9 months ago

Thanks for reporting @Level6LaserLotus! You can unblock yourself by using 0.7.0-SNAPSHOT when this build finishes running. I'll also make a new release tomorrow.

saket commented 9 months ago

Actually, can you double check that this fixes the crash for your image/device before I publish the release?

Level6LaserLotus commented 9 months ago

The crash no longer happens with the 0.7.0-SNAPSHOT version. Thanks for fixing it so quickly. 👍

saket commented 9 months ago

Awesome! 0.6.2 is now available on maven central.