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

Blurred dialog not updating when source changes #511

Open
VadimZhuk0v opened this issue Feb 16, 2025 · 1 comment
Open

Blurred dialog not updating when source changes #511

VadimZhuk0v opened this issue Feb 16, 2025 · 1 comment
Labels
android bug Something isn't working

Comments

@VadimZhuk0v
Copy link

Information

  • Haze version: 1.3.1
  • Platform: Android
  • Platform version: Android 15
  • Specific device: Samsung Galaxy S25 Ultra

Expected Behavior

I want to create a blurred dialog

Actual Behavior

The code below makes the dialog blurred, but blur is't dynamic.

Steps to Reproduce the Problem

val LocalHaze = staticCompositionLocalOf<HazeState?> { null }

@Composable
fun ComposeApp() {
    AppTheme {
        val navController = rememberNavController()
        val hazeState = remember { HazeState() }
        CompositionLocalProvider(
            LocalNavController provides navController,
            LocalHaze provides hazeState,
        ) {
            Box(
                modifier = Modifier.hazeSource(hazeState)
            ) {
                NavHost(
                    navController = navController,
                    startDestination = HomeScreenArgs,
                ) {
                    homeScreenComposable()
                }
            }
        }
    }
}

fun SampleDialog(
    visible: MutableState<Boolean>,
) {
    if (visible.value) {
        Dialog(
            onDismissRequest = { visible.value = false },
            content = {
                Box(
                    modifier = Modifier
                        .size(300.dp)
                        .clip(RoundedCornerShape(16.dp))
                        .hazeEffect(
                            state = LocalHaze.current!!,
                            style = HazeMaterials.thin(
                                containerColor = Color.Blue.copy(alpha = 0.2f)
                            ),
                        ),
                )
            },
        )
}
@VadimZhuk0v VadimZhuk0v added the bug Something isn't working label Feb 16, 2025
@chrisbanes
Copy link
Owner

There's not much we can do here. GraphicsLayer repainting is done at the system level, and it seems that Android aggressively stops layer updates for obscured layers. This does not happen on Skiko (i.e. this would work there), so it's seems like an optimisation somewhere in Android's drawing pipeline.

This might be because Dialog in Compose does not use window flags such as windowIsTranslucent, but there's no way for us to change that.

@chrisbanes chrisbanes changed the title Blurred dialog Blurred dialog not updating when source changes Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants