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

AW: dump commandline state to logs for debugging

Similar to http://crrev/c/1266611, this dumps WebView's CommandLine
state (including the "--enable-features" and "--disable-features"
switches) to the log when the "dummy app"
("org.chromium.webview_log_verbosifier") is present.

Notably, this will give us an idea of whether the NetworkService is
enabled or not (FieldTrialList + CommandLine state + knowledge of
whether it is enabled-or-disabled-by-default should be sufficient).

This also adds a usage guide for the webview verbosifier app, including
the new commandline stuff.

Skipping presubmit for LOG(INFO).

NOPRESUBMIT=true

Bug: 929886, 918221
Test: Manual (following the steps in the new docs)
Test: Upload to gerrit > open file > click "gitiles"
Change-Id: I4c698d661c340f760e2a90da20439b44a56ea38b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1573087
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Reviewed-by: default avatarPaul Miller <paulmiller@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652642}
parent bb1b1e28
......@@ -13,6 +13,7 @@
#include "base/android/scoped_java_ref.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/task/post_task.h"
#include "components/google/core/common/google_util.h"
#include "components/security_interstitials/core/urls.h"
......@@ -133,6 +134,19 @@ void JNI_AwContentsStatics_SetCheckClearTextPermitted(
AwURLRequestContextGetter::set_check_cleartext_permitted(permitted);
}
// static
void JNI_AwContentsStatics_LogCommandLineForDebugging(JNIEnv* env) {
// Note: this should only be called for debugging purposes, since this is
// *very* spammy.
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
for (const auto& pair : command_line.GetSwitches()) {
const std::string& key = pair.first;
const base::CommandLine::StringType& value = pair.second;
LOG(INFO) << "WebViewCommandLine '" << key << "': '" << value << "'";
}
}
// static
jboolean JNI_AwContentsStatics_IsMultiProcessEnabled(JNIEnv* env) {
return !content::RenderProcessHost::run_renderer_in_process();
......
......@@ -462,7 +462,14 @@ public class WebViewChromiumAwInit {
return;
}
PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> FieldTrialList.logActiveTrials());
PostTask.postTask(UiThreadTaskTraits.BEST_EFFORT, () -> {
// TODO(ntfschr): CommandLine can change at any time. For simplicity, only log it
// once during startup.
AwContentsStatics.logCommandLineForDebugging();
// Field trials can be activated at any time. We'll continue logging them as they're
// activated.
FieldTrialList.logActiveTrials();
});
});
}
......
......@@ -123,6 +123,10 @@ public class AwContentsStatics {
nativeSetCheckClearTextPermitted(permitted);
}
public static void logCommandLineForDebugging() {
nativeLogCommandLineForDebugging();
}
/**
* Return the first substring consisting of the address of a physical location.
* @see {@link android.webkit.WebView#findAddress(String)}
......@@ -147,6 +151,7 @@ public class AwContentsStatics {
//--------------------------------------------------------------------------------------------
// Native methods
//--------------------------------------------------------------------------------------------
private static native void nativeLogCommandLineForDebugging();
private static native String nativeGetSafeBrowsingPrivacyPolicyUrl();
private static native void nativeClearClientCertPreferences(Runnable callback);
private static native String nativeGetUnreachableWebDataUrl();
......
WebView Log Verbosifier is an empty dummy app. If this app is installed, WebView
will log the active field trials, for debugging/QA purposes. A dummy app is used
because it can be installed on any device, unlike command-line flags.
# WebView Log Verbosifier
WebView Log Verbosifier is an empty dummy app (in fact, it cannot be launched).
However, if this app is installed, WebView will log the active field trials and
CommandLine flags, for debugging/QA purposes. A dummy app is used because it can
be installed on any device (including user builds, where field trials are still
relevant).
## Build and install
```shell
autoninja -C out/Default webview_log_verbosifier_apk
out/Default/bin/webview_log_verbosifier_apk install
```
## Searching logcat
You can `grep` the logcat like so:
```shell
adb logcat | grep -i 'Active field trial' # Field trials, one per line
adb logcat | grep -i 'WebViewCommandLine' # CommandLine switches, one per line
adb logcat | grep -iE 'Active field trial|WebViewCommandLine' # Both
```
Then just start up any WebView app.
## Uninstalling
When you're done investigating flags/field trials, you can disable the logging
by uninstalling the app:
```shell
out/Default/bin/webview_log_verbosifier_apk uninstall
```
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