Skip to content

rememberAsyncImagePainter doesn't render correctly with Roborazzi/Paparazzi #1910

@colinrtwhite

Description

@colinrtwhite

Describe the bug
rememberAsyncImagePainter doesn't render properly when used with Roborazzi and Paparazzi. The issue appears to be related to the fact that it it needs to wait for a valid drawSize, which is set in DrawScope.onDraw immediately before the painter is then drawn. AsyncImage avoids this timing issue by using ConstraintsSizeResolver to listen to its own composable constraints, which are set before the draw stage.

Interestingly, Paparazzi and Roborazzi both render rememberAsyncImagePainter incorrectly, but differently. When intrinsicContentSize is set to a fixed value this fixes the issue on Roborazzi, but not Paparazzi. It's possible there are different root causes, but this needs to be debugged further.

Work-around
It's possible to work-around this issue by setting any custom size:

rememberAsyncImagePainter(
    model = ImageRequest.Builder(LocalContext.current)
        .data("https://www.example.com/image.jpg")
        .size(Size.ORIGINAL)
        .build(),
    contentDescription = null,
)

To Reproduce
See RoborazziComposeTest.rememberAsyncImagePainter and PaparazziTest.rememberAsyncImagePainter in this repository.

Version
Reproduced with Coil 2.4.0, Roborazzi 1.6.0, and Paparazzi 1.3.1.

Related: cashapp/paparazzi#1123

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedIssues that are up for grabs + are good candidates for community PRs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions