We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9681807 commit 72a0d5bCopy full SHA for 72a0d5b
SwiftDraw/UIImage+SVG.swift
@@ -29,6 +29,7 @@
29
// 3. This notice may not be removed or altered from any source distribution.
30
//
31
32
+import Foundation
33
#if canImport(UIKit)
34
import UIKit
35
#if canImport(WatchKit)
@@ -126,7 +127,7 @@ extension SVG {
126
127
#if os(watchOS)
128
WKInterfaceDevice.current().screenScale
129
#else
- UIScreen.main.scale
130
+ MainActor.syncIsolated { UIScreen.main.scale }
131
#endif
132
}
133
@@ -140,3 +141,14 @@ extension SVG {
140
141
142
143
144
+
145
+private extension MainActor {
146
147
+ static func syncIsolated<T: Sendable>(operation: @MainActor () -> T) -> T {
148
+ if Thread.isMainThread {
149
+ return MainActor.assumeIsolated { operation() }
150
+ } else {
151
+ return DispatchQueue.main.sync { operation() }
152
+ }
153
154
+}
0 commit comments