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

Remote Image Not Displaying in Showcase Using Coil's AsyncImage #374

Closed
narayan07feb opened this issue Jan 24, 2024 · 5 comments
Closed

Comments

@narayan07feb
Copy link

In my component, I am using Coil's AsyncImage. However, everything except for the image appears in the Showcase. I have tried the same component in my code, and it displays everything correctly. Does the Showcase support AsyncImage?

@sjaramillo10
Copy link

A little bit more information here. Android Studio's preview does not load the image from the network (which is kinda expected) but it shows AsyncImage's placeholder correctly. The placeholder is a local drawable.

Showkase does not load the image from the network, but it also does not show the placeholder.

@vinaygaba
Copy link
Collaborator

@narayan07feb @sjaramillo10 I suspect this might be because internet permission isn't added to the ShowkaseBrowserActivity manifest by the library. However, you can solve this on your end by making sure internet permissions are added to your manifest. There's an example of this available where the sample app actually has a network based image that loads correctly in the Showkase Browser. It's because the sample module adds the permission correctly - https://github.com/airbnb/Showkase/blob/master/sample/src/main/AndroidManifest.xml#L4. Let me know if this makes sense

Screenshot 2024-05-22 at 12 33 23 AM

@sjaramillo10
Copy link

Thanks for the suggestion @vinaygaba, however we had already configured the internet permission in the Manifest and the issue persists. Not sure if the issue is with Showkase itself, or with how Coil works that is not compatible with how we are using Showkase.

Not sure if there is any value in keeping this issue open, so feel free to close it out if you prefer. Thanks again!

@vinaygaba
Copy link
Collaborator

@sjaramillo10 Can you fork this repo and swap out the picasso dependencies from the sample module to Coil - https://github.com/airbnb/Showkase/blob/master/sample/build.gradle#L113

If there's issue with the library, it should be a straightforward repro and then I can investigate more to root cause it.

@vinaygaba
Copy link
Collaborator

@narayan07feb @sjaramillo10 I was able to investigate and I think I know what's going on -

Showkase ensures that it conveys that it's a preview environment here (Correct/Intended behavior) -

It seems like Coil doesn't work as well in preview environment based on this issue - coil-kt/coil#1915.

However, it looks like progress is being made to fix it - coil-kt/coil#2266

As a temporary workaround, you can wrap your AsyncImage with this CompositionLocal and that should fix the issue -

CompositionLocalProvider(
    LocalInspectionMode provides false,
) {
    AsyncImage(
        model = imageUrl,
        contentDescription = null,
        modifier = Modifier
            .fillMaxWidth()
            .height(200.dp)
    )
}

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