Skip to content

fix(connectivity_plus): Use serial queue for NWPathMonitor to prevent race condition crash#3752

Open
manuel-goester-n41 wants to merge 1 commit intofluttercommunity:mainfrom
manuel-goester-n41:fix/ios-connectivity-crash
Open

fix(connectivity_plus): Use serial queue for NWPathMonitor to prevent race condition crash#3752
manuel-goester-n41 wants to merge 1 commit intofluttercommunity:mainfrom
manuel-goester-n41:fix/ios-connectivity-crash

Conversation

@manuel-goester-n41
Copy link

@manuel-goester-n41 manuel-goester-n41 commented Feb 4, 2026

Description

This PR fixes a crash occurring on iOS/macOS when NWPathMonitor updates are processed concurrently while the monitor is being deallocated.

The crash manifests as swift::fatalError / swift_deallocPartialClassInstance / double free.

The NWPathMonitor was previously initialized on a global concurrent queue (DispatchQueue.global(qos: .utility)). This allowed race conditions where the pathUpdateHandler block could still be executing on one thread while stop() was setting pathMonitor = nil on another, leading to memory corruption.

Fix: Changed the queue to a private serial DispatchQueue. This ensures that start, stop, and update events are processed sequentially, preventing the race condition.

Related Issues

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the plugin version in pubspec.yaml files.
  • All existing and new tests are passing.
  • The analyzer (flutter analyze) does not report any problems on my PR.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate that with a ! in the title as explained in Conventional Commits).
  • No, this is not a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] connectivity_plus iOS Crash: swift::fatalError in NWPathMonitor (race condition)

1 participant