Skip to content

Conversation

johnxnguyen
Copy link
Collaborator

@johnxnguyen johnxnguyen commented Sep 5, 2025

TaskWPB-20050 [iOS] Check backend reachability per account

Issue

This PR introduces a new NetworkReachability that makes use of NWPathMonitor to report whether the app has an internet connection. This is in contrast to the old ZMReachability which is written in Objective C, uses a lower level C style network API, and checks reachability of specific hosts.

A key difference between the two is that although NetworkReachability is much simpler, it only tells us if there is a connection available and not whether a connection to the Wire backends is available. However, I observed that we only use the existing reachability to hide and show the "no internet" banner, so I think this is fine. If we want to check host reachability, we could extend the code to also send pings to specific hosts.

Testing

  1. Enabled mutilbackend developer flag
  2. Log in
  3. For the phone in airplane mode, observe the "No internet" banner.
  4. Reconnect to the internet, observe the banner goes away.

Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Make sure you use the API for UI elements that support large fonts.
  • All colors are taken from WireDesign.ColorTheme or constructed using WireDesign.BaseColorPalette.
  • New UI elements have Accessibility strings for VoiceOver.

Copy link
Contributor

github-actions bot commented Sep 5, 2025

Test Results

3 498 tests   3 471 ✅  3m 50s ⏱️
  482 suites     27 💤
    3 files        0 ❌

Results for commit ed38504.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@samwyndham samwyndham left a comment

Choose a reason for hiding this comment

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

Nice. I'm pro moving to NWPathMonitor!

Copy link
Collaborator

@netbe netbe left a comment

Choose a reason for hiding this comment

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

@johnxnguyen I believe there might be other cases besides the internet banner:

  1. Looking atreachability.mayBeReachable in the code, we also used reachability to reopen the websocket. i believe we don't at the moment -> but that could go under -> https://wearezeta.atlassian.net/browse/WPB-19904
  2. ZMTransportRequestScheduler seems to change of status if we're offline

Comment on lines +496 to +499
self.isNetworkReachableCancellable = networkReachability.isReachablePublisher
.sink { [weak self] isReachable in
isReachable ? self?.didReceiveData() : self?.didGoOffline()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: do we need to shutdown ReachabilityWrapper if multibackend is on?

@johnxnguyen
Copy link
Collaborator Author

I'm not sure actually this PR is necessary for the initial release: the old ZMReachability should still work for individual accounts because there are separate instances configured with the selected backend. I'll leave this PR open to finish later.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants