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.28k stars 1.11k forks source link

SelectionContainer crashes on Compose for iOS #3718

Open StefanOltmann opened 9 months ago

StefanOltmann commented 9 months ago

Describe the bug I use the SelectionContainer Composable which works as expected for Android and JVM Desktop. On my iPhone 12 Mini the selection of text crashes the app.

See the crash log: 2023-09-2007-30-23.3605+0200-262104203cacf94f31579f9ab12f826c416bb0dc.crash.txt

Affected platforms Select one of the platforms below:

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

  1. Use a SelectionContainer Composable around a Text
  2. Start the app
  3. Select the text
  4. See error

Expected behavior No crash

dima-avdeev-jb commented 9 months ago

I was trying to reproduce on real iOS device iPhone13 mini and on simulator. But it works without any crash in my sample https://github.com/dima-avdeev-jb/issue-3718-ios-selection-container

Can you please try to check my sample too?

StefanOltmann commented 9 months ago

@dima-avdeev-jb Thank you. It took me some time to figure this out.

It crashes if empty text and/or spacers are involved.

Try this:

    SelectionContainer {

        Column {

            Text("Some")

            Spacer(Modifier.height(8.dp))

            Text("multiline")

            Spacer(Modifier.height(8.dp))

            Text("")

            Spacer(Modifier.height(8.dp))

            Text("text to select in SelectionContainer")
        }
    }

As a workaround I will see to avoid displaying empty text.

dima-avdeev-jb commented 9 months ago

Thanks! It reproduced

dima-avdeev-jb commented 8 months ago

This bug is also reproduced on Android here: https://github.com/dima-avdeev-jb/issue-3718-ios-selection-container

It is already fixed in Android JetPack Compose: https://android-review.googlesource.com/c/platform/frameworks/support/+/2616177