Commit f9806134 authored by Nate Fischer's avatar Nate Fischer Committed by Commit Bot

AW docs: expand on commandline docs

No change to logic, only docs.

This expands on commandline docs for WebView, to clarify that all
WebView providers support commandline flags in the same way, and to
advise how to properly use tooling (since some tools treat Monochrome
more like Chrome than like WebView).

This has a minor modification to remove --log-net-log as an example
flag, because we prefer users follow
https://chromium.googlesource.com/chromium/src/+/HEAD/android_webview/docs/net-debugging.md
instead of applying this flag themselves.

This is inspired by the comment raised in https://crbug.com/977784#c19.

Bug: 918221
Test: tools/md_browser/md_browser.py
Test: Upload to gerrit > open file > click "gitiles"
Change-Id: I090c27082d072b8ad434702e19efea8d525a6aa8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1674445
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Auto-Submit: Nate Fischer <ntfschr@chromium.org>
Reviewed-by: default avatarShimi Zhang <ctzsm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#671787}
parent 2aae1629
...@@ -8,43 +8,68 @@ check with `adb shell getprop ro.build.type`). Flags cannot be enabled on ...@@ -8,43 +8,68 @@ check with `adb shell getprop ro.build.type`). Flags cannot be enabled on
production builds of Android. production builds of Android.
*** ***
WebView reads flags from a specific file during startup. To enable flags, write WebView reads flags from a specific file on the device as part of the startup
to the file with: sequence. Therefore, it's important to always **kill the WebView-based app**
you're examining after modifying commandline flags, to ensure the flags are
picked up during the next app restart.
WebView always looks for the same file on the device
(`/data/local/tmp/webview-command-line`), regardless of which package is the
[the WebView provider](prerelease.md).
### Python script
The simplest way to set WebView flags is with the dedicated python script. This
works regardless of which package is the WebView provider:
```sh ```sh
# Overwrite flags (supports multiple) # Overwrite flags (supports multiple)
build/android/adb_system_webview_command_line \ build/android/adb_system_webview_command_line --show-composited-layer-borders --webview-log-js-console-messages
--show-composited-layer-borders \
--log-net-log=foo.json
# Clear flags # Clear flags
build/android/adb_system_webview_command_line "" build/android/adb_system_webview_command_line ""
# Print flags # Print flags
build/android/adb_system_webview_command_line build/android/adb_system_webview_command_line
``` ```
Or, for a locally compiled APK: ### Generated Wrapper Script
If you have a locally compiled APK, you may instead set flags using the
Generated Wrapper Script like so:
```sh ```sh
autoninja -C out/Default system_webview_apk autoninja -C out/Default system_webview_apk
# Overwrite flags (supports multiple) # Overwrite flags (supports multiple)
out/Default/bin/system_webview_apk argv --args='--show-composited-layer-borders --log-net-log=foo.json' out/Default/bin/system_webview_apk argv --args='--show-composited-layer-borders --webview-log-js-console-messages'
# Clear flags # Clear flags
out/Default/bin/system_webview_apk argv --args='' out/Default/bin/system_webview_apk argv --args=''
# Print flags # Print flags
out/Default/bin/system_webview_apk argv out/Default/bin/system_webview_apk argv
``` ```
*** note
**Note:** be careful if using a `monochrome_*` target, as the Generated Wrapper
Script writes to Chrome browser's flags file, and WebView **will not pick up
these flags**. If using Monochrome, you can set flags with the
`system_webview_*` Generated Wrapper Scripts, or use one of the other methods
in this doc.
***
### Manual
Or, you can use the `adb` in your `$PATH` like so: Or, you can use the `adb` in your `$PATH` like so:
```sh ```sh
FLAG_FILE=/data/local/tmp/webview-command-line FLAG_FILE=/data/local/tmp/webview-command-line
# Overwrite flags # Overwrite flags (supports multiple). The first token is ignored. We use '_'
adb shell "echo '_ --show-composited-layer-borders' > ${FLAG_FILE}" # as a convenient placeholder, but any token is acceptable.
# The first token is ignored. We use '_' as a convenient placeholder, but any adb shell "echo '_ --show-composited-layer-borders --webview-log-js-console-messages' > ${FLAG_FILE}"
# token is acceptable. # Clear flags
adb shell "rm ${FLAG_FILE}"
# Print flags
adb shell "cat ${FLAG_FILE}"
``` ```
### Applying Features with flags ## Applying Features with flags
WebView supports the same `--enable-features=feature1,feature2` and WebView supports the same `--enable-features=feature1,feature2` and
`--disable-features=feature3,feature4` syntax as the rest of Chromium. You can `--disable-features=feature3,feature4` syntax as the rest of Chromium. You can
...@@ -59,7 +84,7 @@ Some interesting flags and Features: ...@@ -59,7 +84,7 @@ Some interesting flags and Features:
* `--show-composited-layer-borders` * `--show-composited-layer-borders`
* `--enable-features=NetworkService,NetworkServiceInProcess` * `--enable-features=NetworkService,NetworkServiceInProcess`
* `--log-net-log=<filename.json>` * `--webview-log-js-console-messages`
WebView also defines its own flags and Features: WebView also defines its own flags and Features:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment