https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
p

Pavel Repkin

10/25/2023, 11:17 AM
Hi guys! Our multiplatform iOS app freezes when run from XCode after upgrading Kotlin to 1.9.2 (from 1.8.22) In 10 seconds iPhone CPU usage goes from 20% to 200% and then the app freezes completely. Looking into XCode CPU profiler, the source of the load is “GC finalizer processor” thread, which is loaded 200%. See profiler screenshot below. This happens only while development (the app launched from XCode). This happens on a physical iPhone only. No freeze on the simulator. No freeze, if the iPhone is NOT connected to Mac. No freeze on Kotlin 1.8.22. A really weird issue. I wonder if anyone has noticed a similar behavior after upgrading to Kotlin 1.9?
The same issue with 1.9.20 Anyone?
t

Timofey Solonin

11/02/2023, 8:53 AM
Hi! Is there any way you could you share a reproducer project?
p

Pavel Repkin

11/02/2023, 9:10 AM
Timofey, thank you for getting back. This happens in our production project. Unfortunately, It's huge and we are hesitant to open the code base to the world.
We have found the source of the problem and the solution. Since 1.9.0 Objective C objects are released on the main thread. For some reason this change made our app running very slow. Fortunately, there is an option to revert to the old GC behavior. Add this to gradle.properties
kotlin.native.binary.objcDisposeOnMain=false
Context https://kotlinlang.org/docs/whatsnew19.html#objective-c-or-swift-object-deallocation-hook-on-the-main-thread The issue https://youtrack.jetbrains.com/issue/KT-63232
5 Views