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
Describe the bug
rememberAsyncImagePainterdoesn'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 validdrawSize, which is set inDrawScope.onDrawimmediately before the painter is then drawn.AsyncImageavoids this timing issue by usingConstraintsSizeResolverto listen to its own composable constraints, which are set before the draw stage.Interestingly, Paparazzi and Roborazzi both render
rememberAsyncImagePainterincorrectly, but differently. WhenintrinsicContentSizeis 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.rememberAsyncImagePainterandPaparazziTest.rememberAsyncImagePainterin this repository.Version
Reproduced with Coil
2.4.0, Roborazzi1.6.0, and Paparazzi1.3.1.Related: cashapp/paparazzi#1123