blob: 2de1b8832e2ba7e5d05af40e16a915a9e43d7fe5 [file] [log] [blame] [view]
Nate Fischerb8762b32019-02-12 00:14:411# Net debugging in WebView
2
3## Net log
4
5WebView supports the `kLogNetLog` flag to log debugging network info to a JSON
6file on disk.
7
8*** aside
9For more info on commandline flags, see
10[commandline-flags.md](./commandline-flags.md).
11***
12
13*** note
14**Note:** this requires either a `userdebug` or `eng` Android build (you can
15check with `adb shell getprop ro.build.type`). Flags cannot be enabled on
16production builds of Android.
17***
18
Nate Fischera5a89622019-04-17 01:05:08191. Figure out the app's data directory
20 ```sh
21 # appPackageName is the package name of whatever app you're interested (ex.
22 # WebView shell is "org.chromium.webview_shell").
23 appDataDir="$(adb shell dumpsys package ${appPackageName} | grep 'dataDir=' | sed 's/^ *dataDir=//')" && \
24 ```
251. Pick a name for the JSON file. This must be under the WebView folder in the
26 app's data directory (ex. `jsonFile="${appDataDir}/app_webview/foo.json"`).
27 **Note:** it's important this is inside the data directory, otherwise
28 multiple WebView apps might try (and succeed) to write to the file
29 simultaneously.
Nate Fischerb8762b32019-02-12 00:14:41301. Kill the app, if running
311. Set the netlog flag:
32 ```sh
33 build/android/adb_system_webview_command_line --log-net-log=${jsonFile}
34 ```
351. Restart the app. Reproduce whatever is of interest, and then kill the app
36 when finished
371. Get the netlog off the device:
38 ```sh
Nate Fischerb8762b32019-02-12 00:14:4139 adb pull "${appDataDir}/app_webview/${jsonFile}"
40 ```
411. Import the JSON file into [the NetLog
42 viewer](https://chromium.googlesource.com/catapult/+/master/netlog_viewer/)
43
44For more details, see the implementation in
45[AwUrlRequestContextGetter](/android_webview/browser/net/aw_url_request_context_getter.cc).
46For support in the network service code path, see http://crbug.com/902039.