From ae790f090706b38f9a42c79586f51b6af8d31484 Mon Sep 17 00:00:00 2001 From: Ian Wagner Date: Tue, 3 Dec 2024 11:35:13 +0900 Subject: [PATCH] Fixes modifying state during view update (#63) * Fixes modifying state during view update * Update CHANGELOG --- CHANGELOG.md | 6 ++++++ Sources/MapLibreSwiftUI/MapViewCoordinator.swift | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d3d2d6..b27b024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Version 0.4.2 - 2024-12-03 + +### Fixed + +- Fixes a race modifying state during view update in rare cases + ## Version 0.4.1 - 2024-11-19 ### Fixed diff --git a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift index ee5c93c..304f985 100644 --- a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift +++ b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift @@ -357,7 +357,9 @@ public class MapViewCoordinator: NSObject, MLNMapV direction: mapView.direction, reason: CameraChangeReason(reason)) snapshotCamera = newCamera - parent.camera = newCamera + DispatchQueue.main.async { + self.parent.camera = newCamera + } } /// The MapView's region has changed with a specific reason.