Closed RadoslawGorczyca closed 1 week ago
Are you able to reproduce this in telephoto's sample app? If not, please share a reproducer?
I wonder if this is happening because I'm not clearing the reference to the decoder after it's recycled. Can you try out https://github.com/saket/telephoto/commit/4dd6effd3f0e86d308f7372b32155dd65b0f90a6 by using 0.13.0-SNAPSHOT
?
I can't use this version, I believe it is not published?
You'll have to add maven's snapshot directory to your buildscript:
repositories {
google()
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots/")
}
If you cannot use snapshots, I'll publish a new version soon.
Fixed in version 0.13.0
: https://github.com/saket/telephoto/releases/tag/0.13.0. Please let me know if you still see any crashes?
It seems to be fixed, thank you very much!
@saket Unfortunately this bug still remains, with the same log.
Process: pl.bigstarltd.app.beta, PID: 7685
java.lang.IllegalStateException: getWidth called on recycled region decoder
at android.graphics.BitmapRegionDecoder.checkRecycled(BitmapRegionDecoder.java:303)
at android.graphics.BitmapRegionDecoder.getWidth(BitmapRegionDecoder.java:255)
at me.saket.telephoto.subsamplingimage.internal.AndroidImageRegionDecoder.size-YEO4UFw(AndroidImageRegionDecoder.kt:80)
at me.saket.telephoto.subsamplingimage.internal.AndroidImageRegionDecoder.decodeRegion(AndroidImageRegionDecoder.kt:50)
at me.saket.telephoto.subsamplingimage.internal.PooledImageRegionDecoder$decodeRegion$2.invokeSuspend(PooledImageRegionDecoder.kt:25)
at me.saket.telephoto.subsamplingimage.internal.PooledImageRegionDecoder$decodeRegion$2.invoke(Unknown Source:8)
at me.saket.telephoto.subsamplingimage.internal.PooledImageRegionDecoder$decodeRegion$2.invoke(Unknown Source:4)
at me.saket.telephoto.subsamplingimage.internal.ResourcePool.borrow(PooledImageRegionDecoder.kt:81)
at me.saket.telephoto.subsamplingimage.internal.ResourcePool$borrow$1.invokeSuspend(Unknown Source:15)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@e4b71ba, androidx.compose.runtime.BroadcastFrameClock@2a2486b, StandaloneCoroutine{Cancelling}@eeb9fc8, Dispatchers.IO]
Looks like I have a race condition in BitmapCache
. In the meantime, are you setting beyondBoundsPageCount
to a non-zero value in your pager?
I do not
HorizontalPager(
state = pagerState,
modifier = Modifier.fillMaxSize(),
userScrollEnabled = !zoomed,
) {
val page = mod(it, pagesCount)
Box(
modifier = Modifier.fillMaxSize(),
) {
when {
page < images.size || video == null -> imageComposable(page)
else -> VideoPlayer(
url = video,
modifier = Modifier.fillMaxSize(),
)
}
}
}
I'd suggest setting it to 1
if possible. It'll workaround this issue and offer a better scrolling experience to your users.
HorizontalPager(
state = pagerState,
modifier = Modifier.fillMaxSize(),
userScrollEnabled = !zoomed,
beyondViewportPageCount = 1,
) {
val page = mod(it, pagesCount)
Box(
modifier = Modifier.fillMaxSize(),
) {
when {
page < images.size || video == null -> imageComposable(page)
else -> VideoPlayer(
url = video,
modifier = Modifier.fillMaxSize(),
)
}
}
}
I was able to reproduce the same error multiple times with your suggested change.
🪦
I wonder what is different about your setup that's causing this issue vs the sample app. Can you help me find the differences so that I can write a regression test?
Additionally, a video would also be helpful.
I don't see major differences between implementations. I'm sorry, but it's extremely hard to record video of it, trying to reproduce the bug and avoid content hidden under NDA. Tried it for longer than I have time for, I'm sorry. But as I described it - you enter screen that have nothing more than fullscreen HorizontalPager with few pages which contains only image and indicators. You scroll to the second picture, then you scroll back to the first one and double tap it. Once in a while it crashes with said bug.
I also experience this issue with 0.13.0, also inside a HorizontalPager
This should be fixed with https://github.com/saket/telephoto/commit/ab1b5b51a3f7bb344f4dc3bf4db9af8f69aeccd0. I'll make a release soon!
0.14.0 is out: https://github.com/saket/telephoto/releases/tag/0.14.0. Please let me know if you continue seeing these crashes?
I have a HorizontalPager of zoomable pictures. I noticed that quite often when you swipe from first picture to the next, then back to the first picture and try to double-tap to zoom, you get this crash. It happens even in other situations when scrolling through pager and zooming. Would really appreciate some help :)
Log: