bumptech / bumptech/glide

[Compose] GlideSubcomposition state is changing from Loading-Success-Loading

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

Description

I'm using the Glide Compose version, and the images were loading fine in the Alpha version. However, after switching to the Beta version, I started encountering this issue.

def glideComposeVersion = '1.0.0-alpha.3'
def glideComposeVersion = '1.0.0-beta01'

Older Alpha version code:
```
val placeholder = placeholder { CustomPlaceHolder(modifier = placeHolderModifier) }
GlideImage(
model = image?.image,
contentDescription = "image",
modifier = imageModifier,
contentScale = ContentScale.Fit,
alignment = Alignment.Center,
colorFilter = null,
alpha = DefaultAlpha,
loading = placeholder,
failure = placeholder
) {
it.diskCacheStrategy(DiskCacheStrategy.ALL)
}](url)
```

Newer Beta version code:
```
GlideSubcomposition(
image?.image,
imageModifier,
{ it.diskCacheStrategy(DiskCacheStrategy.ALL) }) {

if (state !is RequestState.Success) {
CustomPlaceHolder(modifier = placeHolderModifier)
} else {
Image(
painter,
contentDescription = "image",
imageModifier,
contentScale = ContentScale.Fit,
alignment = Alignment.Center,
colorFilter = null,
alpha = DefaultAlpha,
)
}
}
```

**Troubleshooting**
When I printed `state` in the Beta version, it first shows loading, then success, and then switches back to loading. As a result, the images on the UI flicker and disappear.

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.