Describe the bug
Composable functions (and properties) returning null cause crash
Affected platforms
Select one of the platforms below:
iOS
Versions
Kotlin version*: 1.9.20
Compose Multiplatform version*: 1.5.10
OS version(s) : Simulator 17.0
To Reproduce
@Composable
fun test() : Int? = null //crash when called
Should be p:high i think as it can result in unexpected random EXC_BREAKPOINT crashes without normal description (I personally spend a long time finding a reason)
@Composable
fun test(condition : Boolean) : Int? {
return if (condition)
1337
else null // crash
}
There is no such rule, it is valid to return a value from Composable. But these kind of Composables have different semantics and different code style rules
Describe the bug Composable functions (and properties) returning null cause crash
Affected platforms Select one of the platforms below:
Versions
To Reproduce
Should be p:high i think as it can result in unexpected random EXC_BREAKPOINT crashes without normal description (I personally spend a long time finding a reason)
Trace
``` ------------------------------------- Translated Report (Full Report Below) ------------------------------------- Incident Identifier: 7973F156-D0E1-4D97-910E-D105B607813A CrashReporter Key: 34688A7D-090D-0E5E-A740-0E61C6315293 Hardware Model: MacBookAir10,1 Process: My application [17024] Path: /Users/USER/Library/Developer/CoreSimulator/Devices/A2FE2CCC-44AF-4EFC-9646-3D0DC306E624/data/Containers/Bundle/Application/2D813892-654E-48A6-9F1D-31789E9343E3/My application.app/My application Identifier: com.example Version: 1.0 (1) Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd_sim [1054] Coalition: com.apple.CoreSimulator.SimDevice.A2FE2CCC-44AF-4EFC-9646-3D0DC306E624 [63477] Responsible Process: SimulatorTrampoline [97317] Date/Time: 2023-11-04 02:35:13.5597 +0300 Launch Time: 2023-11-04 02:35:13.2732 +0300 OS Version: macOS 14.0 (23A344) Release Type: User Report Version: 104 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000001050734a4 Termination Reason: SIGNAL 5 Trace/BPT trap: 5 Terminating Process: exc handler [17024] Triggered by Thread: 0 Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 shared 0x1050734a4 kfun:#test(androidx.compose.runtime.Composer?;kotlin.Int){}kotlin.Int? + 372 1 shared 0x10502419c kfun:#App(androidx.compose.runtime.Composer?;kotlin.Int){} + 916 (App.kt:110) 2 shared 0x105073874 kfun:ComposableSingletons$Main_iosKt.S u r e
Isn't reproducible on desktop
Reproducer on iOS:
There is no such rule, it is valid to return a value from Composable. But these kind of Composables have different semantics and different code style rules
Btw, this was not my comment xD. Original one was deleted
I ran into the same issue. Very unexpected.
I noticed, it doesn't seem deterministic. I have two code paths that lead to the Composable Function that triggers the iOS crash.
{ null }
and crashes.The fix is on its way. The workaround for now:
We've released org.jetbrains.compose.compiler:compiler:1.5.4. It contains a fix. It requires kotlin 1.9.21.
https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compatibility-and-versioning.html#use-a-developer-version-of-compose-multiplatform-compiler
By default this compiler plugin will be applied for projects with kotlin 1.9.21 in the future build 1.5.11
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.