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

Compose Bugfix: When requestBuilder not changed, GlideImage reset to display nothing or loadingPainter #5393

Conversation

hehua2008
Copy link

Compose Bugfix: If requestBuilder has not changed, the requestState, painter(State) and requestListener should not change either. Otherwise, the GlideImage will display nothing or loadingPainter. Since requestState will be reset to RequestState.Loading and GlideNode.launchRequest will not run due to requestBuilder not changed.

This may happen when the request model has not changed but the requestBuilderTransform has changed, and the change of requestBuilderTransform has not been detected in RequestBuilder.equals(). So requestBuilder is considered to have no change.

e.g:

    val transform1: RequestBuilderTransform<Drawable> = {
        val unused = "transform1"
        it
    }

    val transform2: RequestBuilderTransform<Drawable> = {
        val unused = "transform2"
        it
    }

    val switch = Random.nextBoolean()

    GlideImage(
        model = url,
        contentDescription = url,
        loading = placeholder(loadingPainter),
        modifier = modifier
            .fillMaxWidth()
            .aspectRatio(1f),
        requestBuilderTransform = if (switch) transform1 else transform2
    )

…painter(State) and requestListener should not change either. Otherwise, the GlideImage will display nothing or loadingPainter. Since requestState will be reset to RequestState.Loading and GlideNode.launchRequest will not run due to requestBuilder not changed.
Copy link

google-cla bot commented Apr 1, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@hehua2008
Copy link
Author

Give up struggling with glide compose and turn to coil which supports compose on multiple platforms💔

@hehua2008 hehua2008 closed this May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant