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

Crash when using 2+ nested HazeState #443

Closed
Plovotok opened this issue Dec 13, 2024 · 2 comments
Closed

Crash when using 2+ nested HazeState #443

Plovotok opened this issue Dec 13, 2024 · 2 comments

Comments

@Plovotok
Copy link

Plovotok commented Dec 13, 2024

Information

  • Haze version: 1.1.1
  • Platform: Android
  • Platform version: [Android 12+]

Expected Behavior

Actual Behavior

Crash with stack trace:

java.lang.IllegalStateException: Recording currently in progress - missing #endRecording() call?
at android.graphics.RenderNode.beginRecording(RenderNode.java:484)
at android.graphics.RenderNode.beginRecording(RenderNode.java:503)
...

Steps to Reproduce the Problem

   val hazeState = remember {
        HazeState()
    }
    Scaffold(
        bottomBar = {
            Box(modifier = Modifier
                .fillMaxWidth()
                .height(80.dp)
                .hazeChild(hazeState)
            )
        }
    ) { paddings ->
        Box(modifier = Modifier.fillMaxSize().haze(hazeState)) {

            val contentHazeState = remember {
                HazeState()
            }

            Box(
                modifier = Modifier.fillMaxSize(),
                contentAlignment = Alignment.Center
            ) {

                val items = remember {
                    listOf(
                        "Item 1",
                        "Item 2",
                        "Item 3",
                        "Item 4",
                        "Item 5",
                    )
                }

                Box(
                    modifier = Modifier.fillMaxSize().haze(contentHazeState)
                ) {
                    LazyRow {
                        items(items) {
                            val itemHaze = remember {
                                HazeState()
                            }
                            Box(modifier = Modifier.size(76.dp)) {
                                Text(text = it)
                                IconButton(
                                    onClick = {},
                                    modifier = Modifier.hazeChild(itemHaze)
                                ) {
                                    Icon(
                                        imageVector = Icons.Default.MoreHoriz,
                                        contentDescription = null
                                    )
                                }
                            }
                        }
                    }
                }
            }

            Box(modifier = Modifier.fillMaxWidth().height(70.dp).hazeChild(contentHazeState))
        }
    }
@chrisbanes
Copy link
Owner

Yes, currently expected.

I don't know what your use case is, but being able to have nested blurring is being worked on in #441

@Plovotok
Copy link
Author

Thx!)

chrisbanes added a commit that referenced this issue Dec 18, 2024
This PR adds in support for multiple `Modifier.haze` nodes attached to a
`HazeState`. This means that there can be N haze nodes, and M hazeChild
nodes attached to a state.

This has a number of use cases which I'll document, but the main one is
the overlapping area use case:


https://github.com/user-attachments/assets/e7c71898-4988-47f1-b094-c43e6bce7422

- [x] Benchmark performance
- [x] Write docs

Fixes #425, #443
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

2 participants