Skip to content

Fix AsyncImagePainter not updating placeholder/error/fallback when transform changes#3510

Open
shamana-s wants to merge 1 commit into
coil-kt:mainfrom
shamana-s:fix-3477-fallback-painter-update
Open

Fix AsyncImagePainter not updating placeholder/error/fallback when transform changes#3510
shamana-s wants to merge 1 commit into
coil-kt:mainfrom
shamana-s:fix-3477-fallback-painter-update

Conversation

@shamana-s

Copy link
Copy Markdown

Summary

Fixes an issue where updating the placeholder, error, or fallback painter after AsyncImagePainter has already entered the corresponding state does not update the displayed painter.

The root cause is that the transform callback is updated during recomposition, but it is only applied when a new image loading state is emitted. If only the transform changes, the current state is never re-transformed.

This change stores the latest untransformed state and reapplies the transform whenever the transform callback changes, without restarting the image request.

Reproduction

var fallback by remember {
    mutableStateOf<Painter>(ColorPainter(Color.Red))
}

LaunchedEffect(Unit) {
    delay(2.seconds)
    fallback = ColorPainter(Color.Blue)
}

AsyncImage(
    model = null,
    fallback = fallback,
    contentDescription = null,
)

Before

The displayed fallback painter remained red indefinitely.

After

The displayed fallback painter updates to blue immediately after recomposition.

Visual demonstration

The video below shows the fallback painter updating from red to blue after the fallback parameter changes, without restarting the image request.

Screen_recording_20260716_144515.mp4

Fixes #1908

Related: #3477

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.

AsyncImagePainter's placeholder/fallback/error is only updated when a state transition occurs

1 participant