MKMapView crashes when clustering enabled.

Hi everyone,


We are using Mapkit + Realm + WebSockets to make our app with live updates, but unfortunately when updating happens with clustering enabled it crashes from time to time. Does clustering support live updates?


Here is annotation code

class VehicleAnnotation: NSObject, MKAnnotation {
    @objc dynamic var coordinate: CLLocationCoordinate2D
    var title: String?
    let id: Int
    let vehicleItem: BehaviorRelay<VehicleItemUI>
    
    private let disposeBag = DisposeBag()
    
    init(_ vehicleItem: BehaviorRelay<VehicleItemUI>) {
        self.coordinate = vehicleItem.value.coordinate
        self.title = vehicleItem.value.number
        self.vehicleItem = vehicleItem
        self.id = vehicleItem.value.id
        super.init()
        observeChanges()
    }
    
    
    func observeChanges() {
        vehicleItem.asObservable()
            .subscribe(onNext: { [weak self] item in
                self?.coordinate = item.coordinate
            })
            .disposed(by: disposeBag)
    }
    
}



And the crash

019-11-11 12:37:07.490604+0200 AppName[797:166859] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <NSConcreteHashTable: 0x2804fe800> was mutated while being enumerated.'

*** First throw call stack:

(0x1c01f580c 0x1bff1dfa4 0x1c01f51cc 0x1c04db8ac 0x1cd939b40 0x1c05a0850 0x1c05a28ac 0x1c05a00b0 0x1c059c44c 0x1c01f9a00 0x1c01fba6c 0x104b35488 0x104b354ec 0x10a119758 0x10a119b64 0x10a051720 0x10a1218cc 0x10a121c30 0x10a052fb4 0x10a05af74 0x10a05b5ac 0x10a05d3b4 0x10a063640 0x10a065b50 0x10a121e54 0x109c63b70 0x104995f6c 0x104995fb8 0x104997618 0x1cd58d410 0x1049958dc 0x10499652c 0x10a119758 0x10a119b64 0x10a051720 0x10a1218cc 0x10a121c30 0x10a172934 0x10a0f85ec 0x10a0f9318 0x10a172934 0x10a0b8e98 0x10a0b9378 0x10a052fb4 0x10a052470 0x10a0524ec 0x10a121e54 0x10a0062b8 0x109ab0238 0x109a6b8e4 0x108427574 0x10842715c 0x1082d79ac 0x1082d7908 0x1082bef24 0x1082bee94 0x108391190 0x1085e8524 0x1086dddd4 0x1086df88c 0x1086df864 0x1c01737c4 0x1c017371c 0x1c0172eb4 0x1c016e000 0x1c016d8a0 0x1ca0c5328 0x1c425e768 0x104d8df50 0x1bfff8360)

libc++abi.dylib: terminating with uncaught exception of type NSException



P.S.

I guess this happens when i'm trying to update annotation using info from socket's and mapkit are changing clusters.


Anyone has any ideas, is it an MapKit bug or something wrong with my code?

Thanks in advance,Alina A.