JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.9k stars 1.16k forks source link

iOS. Animation crashes with OOM inside bottom sheet #5000

Open logutenko opened 2 months ago

logutenko commented 2 months ago

When playing an animation inside bottom sheet, a large amount of memory is allocated. This causes an application to crash with OOM error.

Affected platforms

Versions

To Reproduce Steps to reproduce the behavior:

  1. In the example graphics-2d replace Scaffold with ModalBottomSheet:

    @OptIn(ExperimentalMaterial3Api::class)
    @Composable
    fun Graphics2D(requestWindowSize: ((width: Dp, height: Dp) -> Unit) = EMPTY_WINDOW_RESIZER) {
    val exampleState: MutableState<Example?> = remember { mutableStateOf(null) }
    val example = exampleState.value
    
    MaterialTheme(
        colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()
    ) {
        ModalBottomSheet(onDismissRequest = {}) {
            if (example == null) {
                LazyColumn(Modifier.padding(horizontal = 16.dp)) {
                    items(examples) {
                        Button(onClick = {
                            exampleState.value = it
                        }) {
                            Text(it.name)
                        }
                    }
                }
            } else {
                example.content { w, h ->
                    requestWindowSize(w, h + TOP_APP_BAR_HEIGHT)
                }
            }
        }
    }
    }
  2. Run an app and click on RotatingWords button
  3. OS terminates app

According to the profiler, memory consumption is over 3 GiB

Снимок экрана 2024-06-20 в 13 05 27

okushnikov commented 2 weeks ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.