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

AsyncImage inside LazyColumn doesn't render #1087

Closed
ben-gooding-sky opened this issue Sep 14, 2023 · 2 comments
Closed

AsyncImage inside LazyColumn doesn't render #1087

ben-gooding-sky opened this issue Sep 14, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ben-gooding-sky
Copy link

ben-gooding-sky commented Sep 14, 2023

Description
When putting an AsyncImage inside a LazyColumn, causes it not to paint.
It goes away if you put it in a regular Column

Steps to Reproduce

LazyColumn {
   items(listOf(1,2,3)) {
      AsyncImage(...)
   }
}

Expected behavior
Image gets rendered in snapshot

Additional information:

  • Paparazzi Version: 1.3.1
  • OS: MacOS (Apple Silicon)
  • Compile SDK: 17.0.7
  • Gradle Version: 8.3
  • Android Gradle Plugin Version:
@ben-gooding-sky ben-gooding-sky added the bug Something isn't working label Sep 14, 2023
@gamepro65
Copy link
Collaborator

gamepro65 commented Sep 20, 2023

Is this referring to coil.compose.AsyncImage?

When Paparazzi takes a snapshot of a ComposeView, we first run a composition when attaching ComposeView to the hierarchy, then execute any pending Handler callbacks, and finally tell Layoutlib to take a snapshot which internally calls measure / draw.

If we look at AsyncImagePainter, we see they update their internal painter with Dispatchers.Main.immediate which is backed by a Handler. In the case of Column, this call to Dispatchers.Main.immediate will be queued during that initial composition and will then run when we execute pending Handler callbacks. However, with LazyColumn items are not composed until the measure pass so it can figure out how many items to render. In this case, unfortunately, we cannot force the Handler to execute any pending callbacks before drawing and so the painter misses the first draw call. If you call the gif API with the same setup, I'd imagine the 2nd frame would show the image.

I'd suggest opening an issue with Coil to expose a configuration option for that Dispatcher so you can seed Dispatchers.Unconfined which will synchronously set the painter in time for the first draw.

@jrodbx
Copy link
Collaborator

jrodbx commented Sep 23, 2023

Closing as the issue is unrelated to Paparazzi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants