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

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

Open
colinrtwhite opened this issue Oct 30, 2023 · 0 comments

Comments

@colinrtwhite
Copy link
Member

Describe the bug
AsyncImagePainter's placeholder/fallback/error values are only updated when a state transition occurs. This is currently semi by design as those values are only used to overwrite the values provided by ImageRequest's placeholder/fallback/error, however in practice this can be unexpected. To figure out:

  • If we can update those values outside of state transitions caused by ImageLoader how does this affect onState and when it's called? Do we re-invoke the callback with Loading a second time if placeholder is updated?

To Reproduce
The following composable won't update to blue:

AsyncImage(
    model = Unit, // Pass a value that errors immediately.
    error = changingPainter(),
    contentDescription = null,
)

@Composable
fun changingPainter(): Painter {
    val painter by remember { mutableStateOf<Painter>(ColorPainter(Color.Red)) }
    LaunchedEffect(Unit) {
        delay(1_000)
        painter = ColorPainter(Color.Blue)
    }
    return painter
}

Version
Reproduced on 2.4.0.

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

No branches or pull requests

1 participant