Skip to content

Commit 05a50f3

Browse files
fix(connectivity_plus): Use serial queue for NWPathMonitor to prevent race condition crash (#3752)
1 parent 81771c9 commit 05a50f3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/connectivity_plus/connectivity_plus/ios/connectivity_plus/Sources/connectivity_plus/PathMonitorConnectivityProvider.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import Network
33

44
public class PathMonitorConnectivityProvider: NSObject, ConnectivityProvider {
55

6-
// Use .utility, as it is intended for tasks that the user does not track actively.
7-
// See: https://developer.apple.com/documentation/dispatch/dispatchqos
8-
private let queue = DispatchQueue.global(qos: .utility)
6+
// Use a serial queue to ensure that all network updates and monitor events happen
7+
// sequentially, preventing race conditions during deallocation.
8+
private let queue = DispatchQueue(label: "dev.fluttercommunity.plus.connectivity")
99

1010
private var pathMonitor: NWPathMonitor?
1111

packages/connectivity_plus/connectivity_plus/macos/connectivity_plus/Sources/connectivity_plus/PathMonitorConnectivityProvider.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import Network
33

44
public class PathMonitorConnectivityProvider: NSObject, ConnectivityProvider {
55

6-
// Use .utility, as it is intended for tasks that the user does not track actively.
7-
// See: https://developer.apple.com/documentation/dispatch/dispatchqos
8-
private let queue = DispatchQueue.global(qos: .utility)
6+
// Use a serial queue to ensure that all network updates and monitor events happen
7+
// sequentially, preventing race conditions during deallocation.
8+
private let queue = DispatchQueue(label: "dev.fluttercommunity.plus.connectivity")
99

1010
private var pathMonitor: NWPathMonitor?
1111

0 commit comments

Comments
 (0)