DEV Community

Your app works on office Wi-Fi. Here's how to test it on a bad network from your Mac.

Most networking bugs never show up at a desk. Office Wi-Fi answers in 10 ms, nothing drops, and every request finishes before you can tap twice. Then someone opens the app on a train and the spinner never stops, or the order goes through twice.

You don't need extra hardware to reproduce that. Everything below is free and runs on a Mac.

The tools

macOS: Network Link Conditioner. It ships in "Additional Tools for Xcode" (download it from the Apple Developer site, then open the Hardware folder). It installs a settings pane with profiles like 3G, Edge, Very Bad Network and 100% Loss, and you can make your own with bandwidth, delay, packet loss and DNS delay. It throttles the whole Mac, so the iOS Simulator and anything else on the Mac get it too. Remember to switch it off afterwards.

A real iPhone. Settings → Developer → Network Link Conditioner, with the same profiles. The Developer menu shows up once the phone has been used with Xcode and Developer Mode is on.

Android emulator. Start it with a slower network:

emulator -avd Pixel_8 -netdelay edge -netspeed edge

Both flags also take numbers: -netdelay 300:800 for a random delay in milliseconds, -netspeed 128:512 for upload:download in kbps. To change it while the emulator runs, send console commands through adb:

adb emu network delay gprs or adb emu network speed edge.

Browser and web views. Chrome DevTools → Network → the throttling dropdown. Add a custom profile with high latency, not only low bandwidth.

What to actually test

  1. Latency, not just bandwidth. Bandwidth limits make big downloads slow. Latency is what breaks interactions. With 500 ms+ round trips you'll find missing loading states, buttons that can be tapped twice, and screens that render with data from the previous request.
  2. Timeouts. Set a profile with heavy packet loss and see how long the user waits before something happens. The defaults are easy to forget:
  • URLSession: timeoutIntervalForRequest defaults to 60 seconds. timeoutIntervalForResource defaults to 7 days.
  • OkHttp: 10 seconds each for connect, read and write. There's no overall call timeout unless you set callTimeout.
  • fetch in the browser has no timeout of its own. Pass signal: AbortSignal.timeout(10_000).

If the answer is "a spinner for a minute", pick a timeout on purpose and show an error with a retry button.

  1. Retries and double submits. On a lossy link, a request can reach the server while the response gets lost. If the client retries, or the user taps again, a non-idempotent POST runs twice. Test the checkout or order flow with Very Bad Network turned on. The fix belongs on both sides: disable the button while the request runs, and send an idempotency key the server can deduplicate on.
  2. Going offline and coming back. Switch to 100% Loss in the middle of a flow, then switch back. Does the app recover by itself, or does it need a restart? Also note that "connected" isn't "working": NWPathMonitor or ConnectivityManager can report a usable path on a captive portal or a dead hotspot, so treat a failed request as the real signal.
  3. Large responses on slow links. A 4 MB JSON list or full-size images feel fine on Wi-Fi and take half a minute on Edge. Throttling makes it obvious which screens need pagination or smaller images.

A quick routine

Before a release, run the main flows twice: once on a custom profile with about 600 ms of delay and 5% loss, and once switching between that and 100% Loss in the middle. It takes about ten minutes and catches most of what users would otherwise report as "the app is broken sometimes".

This article was created with the help of AI.

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.