# multiplatform


12/01/2023, 1:47 PM
It appears there is some sort of issue in Kotlin 1.9.X re; the location manager updates suddenly stopping I've tried using Kotlin 1.9.20 and 1.9.21. It looks like this was working on Kotlin 1.8.X as confirmed by Charlie here
Copy code
internal actual class LocationMonitor {
    private val _clLocationManger = CLLocationManager()
    private class LocationDelegate(
        private val onLocationCallback: (CLLocation?) -> Unit,
    ) : NSObject(), CLLocationManagerDelegateProtocol {
        override fun locationManager(manager: CLLocationManager, didUpdateLocations: List<*>) {
            // This method stops getting invoked after around 5 updates are sent
            val location = (didUpdateLocations.lastOrNull()) as CLLocation?
        /*Other override methods here are also not called e.g. didFailWithError*/
    init {
        _clLocationManger.delegate = LocationDelegate(
            onLocationCallback = { location ->
                /*Some logic here...*/
        _clLocationManger.pausesLocationUpdatesAutomatically = false
        _clLocationManger.distanceFilter = kCLDistanceFilterNone
        _clLocationManger.desiredAccuracy = kCLLocationAccuracyBestForNavigation
    actual fun startMonitoring() {
    actual fun stopMonitoring() {
I haven't been able to check whether this is fixed in K2 yet, as that'll make my project fail to build due to some third party libraries I'm using.
I've opened an issue here KT-63992, here's to hoping this gets looked at soon
Disabling GC with freeCompilerArgs += "-Xgc=noop" fixes the issue. Not ideal but a temporary workaround while this gets fixed
👍 1