
No change to logic, only docs. This clarifies that WebView requires debuggable Android images for all commandline flags, including netlog. This repeats a code snippet for checking if your device supports commandline flags. Bug: 918221 Test: tools/md_browser/md_browser.py Test: Upload to gerrit > open file > click "gitiles" Change-Id: I03ebc095ee78744e9dfdbf9c113b418c57a53e7e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2029190 Reviewed-by: Shimi Zhang <ctzsm@chromium.org> Commit-Queue: Nate Fischer <ntfschr@chromium.org> Cr-Commit-Position: refs/heads/master@{#736640}
3.0 KiB
3.0 KiB
Net debugging in WebView
Net log
WebView supports the kLogNetLog
flag to log debugging network info to a JSON
file on disk.
Please do not request netlogs from reporters
*** note Important: at the moment, WebView netlog requires applying commandline flags. It's not typically possible for external reporters to apply commandline flags, so please do not ask them to follow this guide.
This guide is only for chromium developers who are set up for WebView
development. Specifically, this guide requires the reader to use a userdebug
or eng
Android image, see device setup and commandline
flags for more information.
Python script
If you have a chromium checkout, the preferred way to set the netlog flag is to
use the record_netlog.py
script like so:
# Optional: set any flags of your choosing before running the script. Don't set
# --log-net-log though; this is set by record_netlog.py.
$ build/android/adb_system_webview_command_line --enable-features=MyFeature,MyOtherFeature
Wrote command line file. Current flags (in webview-command-line):
005d1ac915b0c7d6 (bullhead-userdebug 6.0 MDB08M 2353240 dev-keys): --enable-features=MyFeature,MyOtherFeature
# Replace "<app package name>" with your app's package name (ex. the
# WebView Shell is "org.chromium.webview_shell"). This script will set an
# appropriate value for --log-net-log and handle setup/cleanup.
$ android_webview/tools/record_netlog.py --package="<app package name>"
Netlog will start recording as soon as app starts up. Press ctrl-C to stop recording.
^C
Pulling netlog to "netlog.json"
Then import the JSON file (netlog.json
in the working directory) into the
NetLog viewer.
Manual steps
- Figure out the app's data directory
# appPackageName is the package name of whatever app you're interested (ex. # WebView shell is "org.chromium.webview_shell"). appDataDir="$(adb shell dumpsys package ${appPackageName} | grep 'dataDir=' | sed 's/^ *dataDir=//')" && \
- Pick a name for the JSON file. This must be under the WebView folder in the
app's data directory (ex.
jsonFile="${appDataDir}/app_webview/foo.json"
). Note: it's important this is inside the data directory, otherwise multiple WebView apps might try (and succeed) to write to the file simultaneously. - Kill the app, if running
- Set the netlog flag:
FLAG_FILE=/data/local/tmp/webview-command-line adb shell "echo '_ --log-net-log=${jsonFile}' > ${FLAG_FILE}"
- Restart the app. Reproduce whatever is of interest, and then kill the app when finished
- Get the netlog off the device:
adb pull "${appDataDir}/app_webview/${jsonFile}" adb shell "rm '${appDataDir}/app_webview/${jsonFile}'"
- Optional: view the data in the NetLog viewer
- Optional: clear the commandline flags:
FLAG_FILE=/data/local/tmp/webview-command-line adb shell "rm ${FLAG_FILE}"