Takeaway: Check One Layer at a Time, and Test Each Guess with the Right Tool
The mobile debugging series in one diagram and two tables: which tool sees and changes each layer of a phone, what goes wrong there, and what to do first.
On the web, one tool, DevTools, shows you everything. On a phone, each layer needs its own tool. This essay sums up the series in one diagram and two tables: which tool sees each layer, what can go wrong there, and what to do first.
Layer to tool
The OSI model (a reference model that splits network traffic into seven layers) covers only the network. On a phone, more layers sit above it. Layer 5 (session) rarely causes a problem in app debugging, so the diagram skips it.
- The HAR records everything that the phone sends over the network, as the proxy sees it.
- The device log records what the phone does without the network, for example when it opens an app. A universal link (a web link that opens an app) or a deep link (a link like
myapp://that opens an app) can open an app with no HTTP request, so only the device log shows it (the device log and the HAR each see half). - To test the OS step alone, open the link from the computer. On Android, run
adb shell am start -a android.intent.action.VIEW -d "myapp://path". On the iOS Simulator, runxcrun simctl openurl booted "myapp://path". On a real iPhone, tap the link in the Notes app. Install or remove the app to see both outcomes. - A proxy script (for example a mitmproxy addon) is not a layer. It sits in the proxy at L7 and changes responses on the way. Its effect shows one layer up, in the page (patch the code on the way to the phone).
Layer to what can go wrong
| Layer | What can go wrong | Essays |
|---|---|---|
| OS | A universal link or a deep link does not open the app, or the app opens with no network request | 04, 06 |
| Host app and SDK | The app blocks window.open(), or the app picks where a link opens |
03, 09 |
| WebView and page | A click handler cancels the link, or the code behaves differently than in a browser | 03, 07, 10 |
| L7 HTTP, DNS | A request is not sent, a header is wrong, or a 304 response keeps an old file | 02, 05, 07 |
| L6 TLS | The app trusts only its own certificate (certificate pinning), so the proxy breaks the connection | Not in this series |
| L3-L4 IP, TCP | The connection starts (a CONNECT line in the proxy), but no page loads |
05 |
| L1-L2 Wi-Fi, USB | A network route on the computer, for example a USB Ethernet adapter, breaks the phone’s proxy | Not in this series |
| Data from real users (outside the phone) | Results differ by ad network, country, or IP address | 08 |
What to do first, by situation
| Situation | Do this first | Essays |
|---|---|---|
| The data shows clicks, the user says nothing happened | Treat “record the tap” and “open the page” as two events, and check each one | 01, 02 |
| The same code works in a browser and fails in an app | Find which browser behavior the app changed, for example window.open() |
03 |
| You do not know where the link opened | Read Sec-Fetch-Mode and the UA in the HAR |
04 |
| The HAR shows nothing, but the screen switched away | Read the device log | 06 |
| You must change code that you do not own | Rewrite the response through the proxy, and avoid the 304 cache trap | 07 |
| The problem went away after a rewrite | This proves only the phone side. Check data from real users too | 08 |
| You do not know which layer stops the tap | One control per layer, and remove one layer per test | 09 |
Pitfalls
- HAR times are in UTC. The device log uses the computer’s time zone. Convert them before you match a tap to a log line.
- Rewrite the file that the server sends, which is often minified, not your source code.
- Read the SDK version in the request before you read SDK documents.
- Compare items of the same type. A native ad that opens says nothing about an HTML ad.
- Change one thing per test (try to disprove your own guess first).
On a phone, ask which layer first. Then ask which tool can see it.
References
- mitmproxy documentation
- WebKit: Enabling the inspection of web content in apps
- Chrome DevTools: Remote debug Android WebViews
Related: revisit how to record and read phone traffic, why the device log and the HAR each see half, how to patch the code on the way to the phone, how to remove one layer per test, and why you try to disprove your own guess first. Or go Back to the series overview.