Fix iOS AppHang: dispatch getNetworkInfo off main thread#12
Merged
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses an iOS UI stall (AppHang) by moving synchronous, XPC-backed network info lookups off the main thread in the iOS plugin, and aligns the Dart method-channel wrapper with safer “empty map” fallbacks for null/error cases. It also bumps the package version and documents the release.
Changes:
- iOS: dispatch
getNetworkInfoResult()to a backgroundDispatchQueueto avoid blocking the main thread; fix WiFi subtype typo (unknwon→unknown). - Dart: return an empty map when the method-channel result is
nullor an exception occurs; add tests for these scenarios. - Release: bump
pubspec.yamlversion to0.0.3and add aCHANGELOG.mdentry.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/flutter_network_capabilities_method_channel_test.dart | Adds unit tests for null and exception behavior from the native channel. |
| pubspec.yaml | Bumps package version 0.0.2 → 0.0.3. |
| lib/flutter_network_capabilities_method_channel.dart | Adds try/catch + null handling to return {} for failure cases. |
| ios/Classes/FlutterNetworkCapabilitiesPlugin.swift | Moves network info computation off the main thread; fixes "unknown" subtype typo for WiFi. |
| CHANGELOG.md | Documents the new 0.0.3 changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rmorbach
reviewed
Jun 11, 2026
rmorbach
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On iOS, both
CTTelephonyNetworkInfo()andSCNetworkReachabilityGetFlagsperform synchronous XPC calls to system daemons under the hood. When invoked on the main thread, they block it until the system responds — which can take hundreds of milliseconds or longer under network or system load.This was surfacing as AppHang PROD-APP-E37G: the Flutter method channel handler was calling
getNetworkInfoResult()directly on the main thread, stalling the UI.Fix
Wrap the
getNetworkInfoResult()call inDispatchQueue.global(qos: .utility).async { ... }so the XPC-backed lookups happen off the main thread. Theresultcallback is@escaping, so it is safe to call from a background queue.Also fixed a long-standing typo:
transport_subtypefor WiFi connections was returning"unknwon"instead of"unknown".Changes
ios/Classes/FlutterNetworkCapabilitiesPlugin.swiftgetNetworkInfoResult()to a utility background queue; fix"unknwon"→"unknown"typopubspec.yaml0.0.2→0.0.3CHANGELOG.md0.0.3