Skip to content

feat(network): implement Apple network monitoring#4263

Open
MohamadJaara wants to merge 3 commits into
developfrom
mo/feat/implement-apple-network-monitor
Open

feat(network): implement Apple network monitoring#4263
MohamadJaara wants to merge 3 commits into
developfrom
mo/feat/implement-apple-network-monitor

Conversation

@MohamadJaara

Copy link
Copy Markdown
Member

Replaces the Apple NetworkStateObserverImpl stub, which always reported “connected”, with a real iOS/macOS implementation using Apple’s Network.framework and nw_path_monitor.

What changed

  • The observer now watches the default network path on iOS and macOS.
  • nw_path_status_satisfied is mapped to ConnectedWithInternet.
  • All other states are treated as NotConnected, because the path is not currently usable.
  • observeCurrentNetwork() now reports:
    • network type: WIFI, CELLULAR, or OTHER
    • a stable network id based on the active interfaces
    • whether the network has internet access
  • Network updates are handled on a dedicated serial queue, so state changes are applied in order.
  • The mapping logic is covered by unit tests in appleTest.

This brings iOS/macOS closer to Android behavior and unblocks connectivity-aware sync and CallNetworkChangeManager.

Known limitation

The network id is based on the interface name and index. This means switching between two networks on the same interface, for example changing Wi-Fi SSID, will not be detected as a network change. @johnxnguyen how does the iOS app deal with this?

Detecting that would require reading the SSID, which needs location permission. We are intentionally not requesting that here.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Test Results

0 tests   - 5 822   0 ✅  - 5 679   0s ⏱️ - 4m 38s
0 suites  -   882   0 💤  -   143 
0 files    -   882   0 ❌ ±    0 

Results for commit d88fc2e. ± Comparison against base commit eb2534e.

♻️ This comment has been updated with latest results.

@codecov-commenter

codecov-commenter commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.31%. Comparing base (eb2534e) to head (d88fc2e).
⚠️ Report is 13 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #4263      +/-   ##
=============================================
- Coverage      61.47%   61.31%   -0.17%     
- Complexity      3988     4001      +13     
=============================================
  Files           2104     2135      +31     
  Lines          69070    69091      +21     
  Branches        6842     6854      +12     
=============================================
- Hits           42462    42363      -99     
- Misses         23862    23975     +113     
- Partials        2746     2753       +7     

see 67 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb2534e...d88fc2e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branch${GITHUB_HEAD_REF}
Testbedubuntu-latest

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymicroseconds (µs)
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInFiles📈 view plot
⚠️ NO THRESHOLD
865.64 µs
com.wire.kalium.benchmarks.logic.CoreLogicBenchmark.createObjectInMemory📈 view plot
⚠️ NO THRESHOLD
603,267.93 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.inboxPagingDeepPageBenchmark📈 view plot
⚠️ NO THRESHOLD
133,859.30 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.inboxPagingFirstPageBenchmark📈 view plot
⚠️ NO THRESHOLD
127,272.38 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.localMarkAsReadBenchmark📈 view plot
⚠️ NO THRESHOLD
4,183.60 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.messagePagingDeepPageBenchmark📈 view plot
⚠️ NO THRESHOLD
37,121.77 µs
com.wire.kalium.benchmarks.persistence.MessageReadBenchmark.messagePagingFirstPageBenchmark📈 view plot
⚠️ NO THRESHOLD
21,810.31 µs
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.messageInsertionBenchmark📈 view plot
⚠️ NO THRESHOLD
1,248,080.37 µs
com.wire.kalium.benchmarks.persistence.MessagesNoPragmaTuneBenchmark.queryMessagesBenchmark📈 view plot
⚠️ NO THRESHOLD
19,880.58 µs
🐰 View full continuous benchmarking report in Bencher

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the Apple (iOS/macOS) NetworkStateObserverImpl stub with a real implementation backed by Network.framework (nw_path_monitor), so Kalium can react to connectivity changes on Apple platforms similarly to Android and unblock connectivity-aware features (e.g., calling).

Changes:

  • Implement iOS/macOS network monitoring using nw_path_monitor, mapping nw_path_status_satisfied to ConnectedWithInternet and other states to NotConnected.
  • Populate observeCurrentNetwork() with network type, a derived network id, and internet-access flag.
  • Add appleTest unit tests covering status mapping and network-id construction.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
logic/src/appleMain/kotlin/com/wire/kalium/logic/network/NetworkStateObserverImpl.kt Implements Apple network monitoring via nw_path_monitor, plus mapping/id helpers.
logic/src/appleTest/kotlin/com/wire/kalium/logic/network/NetworkStateObserverImplTest.kt Adds unit tests for status→state mapping and network-id building logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

MohamadJaara and others added 2 commits July 7, 2026 16:29
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

@johnxnguyen johnxnguyen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

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.

4 participants