bumptech / bumptech/glide

Inconsistent screenshot-testing with paparazzi and GlideImage composable

Open
#5,402 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

**Glide Version**: 1.0.0-beta01

**Integration libraries**: Not relevant

**Device/Android Version**: Ran tests on multiple emulators.

**Issue details / Repro steps / Use case background**:
The issue involves inconsistent loading of images in a screenshot test with Paparazzi using the `GlideImage` composable. Sometimes the image from a URL loads successfully, other times the image is blank, and occasionally, only the loading placeholder is shown. This inconsistency is problematic for reliable UI testing and screenshot generation.

**Composable**
```java
val adImageSize = 50.dp
val requestSize = with(LocalDensity.current) { adImageSize.toPx().toInt() }

Box {
GlideImage(
model = ad?.image.orEmpty(),
contentDescription = stringResource(R.string.content_description_adimage),
contentScale = ContentScale.FillBounds,
loading = placeholder(painterResource(id = R.drawable.placeholder)),
failure = placeholder(painterResource(id = R.drawable.ad_placeholder)),
modifier = Modifier
.size(adImageSize)
.align(Alignment.Center)
.clip(shapes.roundedCornerExtraSmall),
requestBuilderTransform = {
it.apply(RequestOptions().override(requestSize))
},
)
}
```

**Test**
```
@RunWith(TestParameterInjector::class)
class ChatScreenshotTest(
@TestParameter
nightMode: NightMode,
) {
@get:Rule
val paparazzi = Paparazzi(
deviceConfig = DeviceConfig.PIXEL_6_PRO.copy(
nightMode = nightMode,
),
theme = "android:Theme.Material.ActionBar",
snapshotHandler = if (PaparazziConfig.isVerifying) {
SnapshotVerifier(
maxPercentDifference = PaparazziConfig.maxPercentDifference,
rootDirectory = PaparazziConfig.dir
)
} else {
HtmlReportWriter(snapshotRootDirectory = PaparazziConfig.dir)
}
)

@Test
fun textMessages() {
paparazzi.snapshot {
CompositionLocalProvider(
LocalInspectionMode provides true,
) {
Theme {
ConversationPreview(createPreviewTextMessages())
}
}
}
}
}
```
I also reaised an issue on Paparazzi since I am uncertain where the bug recides at this point: https://github.com/cashapp/paparazzi/issues/1396

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.