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

Cloudy causes lags during animations #43

Open
frakc opened this issue Oct 1, 2024 · 1 comment
Open

Cloudy causes lags during animations #43

frakc opened this issue Oct 1, 2024 · 1 comment

Comments

@frakc
Copy link

frakc commented Oct 1, 2024

Please complete the following information:

  • Library Version [e.g. v0.2.3]
  • Affected Device(s) [e.g. Samsung Galaxy s10 with Android 9.0]

Cloudy redraw is triggered every time and layout change occurs. Eg on code below I anime box which has no relation to blured box. Hoever cloudy is redrawing multiple times per each animation. On pre android12 device it causes significant frame skipps

 Column {
            Box(Modifier.size(300.dp)) {
                val graphicsLayer = rememberGraphicsLayer()

                Box(
                    Modifier
                        .fillMaxSize()
                        .cloudy(
                            80,
                            graphicsLayer = graphicsLayer,
                            onStateChanged = { Timber.e("cloudy ${it.javaClass.simpleName}") })
                        .background(Color.Blue)
                )
            }
            Box(Modifier.size(300.dp)) {

                var satarget by remember { mutableStateOf(false) }
                val sa by animateFloatAsState(if (satarget) 1f else 0f)
                Box(
                    Modifier
                        .height(300.dp * sa)
                        .fillMaxWidth()
                        .background(Color.Red)
                )
                LaunchedEffect(Unit) {
                    while (true) {
                        delay(400)
                        satarget = !satarget
                    }
                }
            }
        }
@frakc frakc changed the title Bugs during animations Cloudy causes lags during animations Oct 1, 2024
@desugar-64
Copy link

It's a CPU-based blur that's executed in a blocking manner. The blur recalculates whenever the layout updates. I'm not sure if it updates multiple times per frame, but even if it only updates once per frame, it's still a slow CPU-based blurring process.
To make it work fast, it needs to be hardware accelerated.

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