Closed ganfra closed 1 year ago
Hi @ganfra. Can you share the full error stacktrace?
Can you also check what happens if you use SubSamplingImage()
directly with your URI?
val zoomableState = rememberZoomableState()
val imageState = rememberSubSamplingImageState(
zoomableState = zoomableState,
imageSource = ImageSource.contentUri(…)
)
SubSamplingImage(
modifier = Modifier
.fillMaxSize()
.zoomable(zoomableState),
state = imageState,
contentDescription = …,
)
Hi, sorry for the late reply. Here is the stacktrace :
0 = {StackTraceElement@30479} "android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2013)"
1 = {StackTraceElement@30480} "android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1842)"
2 = {StackTraceElement@30481} "android.content.ContentResolver.openInputStream(ContentResolver.java:1518)"
3 = {StackTraceElement@30482} "me.saket.telephoto.subsamplingimage.UriImageSource.decoder(SubSamplingImageSource.kt:136)"
4 = {StackTraceElement@30483} "me.saket.telephoto.subsamplingimage.internal.AndroidImageRegionDecoder$Companion$Factory$1.create(AndroidImageRegionDecoder.kt:47)"
5 = {StackTraceElement@30484} "me.saket.telephoto.subsamplingimage.internal.PooledImageRegionDecoder$Companion$Factory$1$create$decoders$1.invokeSuspend(PooledImageRegionDecoder.kt:52)"
6 = {StackTraceElement@30485} "kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)"
7 = {StackTraceElement@30486} "kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)"
8 = {StackTraceElement@30487} "kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)"
9 = {StackTraceElement@30488} "kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)"
10 = {StackTraceElement@30489} "kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)"
11 = {StackTraceElement@30490} "kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)"
And yes, it fails the same way using directly SubSamplingImage
And this is expected, because ContentResolver.openInputStream
only works with those defined schemes:
* <h5>Accepts the following URI schemes:</h5>
* <ul>
* <li>content ({@link #SCHEME_CONTENT})</li>
* <li>android.resource ({@link #SCHEME_ANDROID_RESOURCE})</li>
* <li>file ({@link #SCHEME_FILE})</li>
The URI I provide doesn't contain any scheme.
Like I said, Coil fixes this with his FileUriMapper
.
Gotcha. I don't mind supporting this, but is there a reason you're not specifying the file scheme? What's the benefit of writing "/path/to/file.jpg"
instead of "file:///path/to/file.jpg"
?
I can also try to convert my path to a uri at some point instead, of course.
It was more a question about having "parity" treatment with regular AsyncImage
, but it's up to you :P
I let you close the issue.
Yea that's a fair point. Regardless of their validity, I will probably have to support them if ZoomableAsyncImage
aims to be a drop-in. Let me sleep on this.
So, we are trying to use telephoto to render some images from internal storage.
Basically we were just using this with Coil, and it was working correctly :
And now we use the same way :
The uri has this form :
/data/user/0/appId/cache/.tmpy7ImGl.jpeg
After some investigation I found that this code is failing :
Where the imageSource is coming from this method :
So I guess we are missing some check on the RequestData.Uri so it can be used with
SubSamplingImageSource.file()
instead.Coil is doing some mapping internally like that :
Let me know if this is something you want to fix or if I've to do the conversion on my side. Thanks!