Adds histogram to check whether asset path workaround is used
Bug: 400413041 Change-Id: I761adce0aaf703b3925bee5e87623c4c91d3a9f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6343457 Reviewed-by: Tomasz Wiszkowski <ender@google.com> Auto-Submit: Alex Mitra <alexmitra@chromium.org> Reviewed-by: Richard (Torne) Coles <torne@chromium.org> Commit-Queue: Alex Mitra <alexmitra@chromium.org> Cr-Commit-Position: refs/heads/main@{#1432147}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
594e0d244e
commit
00d4eb816d
android_webview/glue/java/src/com/android/webview/chromium
tools/metrics/histograms/metadata/android
@@ -85,6 +85,9 @@ public class WebViewChromiumAwInit {
|
|||||||
|
|
||||||
private static final String HTTP_AUTH_DATABASE_FILE = "http_auth.db";
|
private static final String HTTP_AUTH_DATABASE_FILE = "http_auth.db";
|
||||||
|
|
||||||
|
private static final String ASSET_PATH_WORKAROUND_HISTOGRAM_NAME =
|
||||||
|
"Android.WebView.AssetPathWorkaroundUsed.StartChromiumLocked";
|
||||||
|
|
||||||
public static class WebViewStartUpDiagnostics {
|
public static class WebViewStartUpDiagnostics {
|
||||||
private final Object mLock = new Object();
|
private final Object mLock = new Object();
|
||||||
|
|
||||||
@@ -336,7 +339,9 @@ public class WebViewChromiumAwInit {
|
|||||||
// mechanism might not help.
|
// mechanism might not help.
|
||||||
try {
|
try {
|
||||||
DeviceFormFactor.isTablet();
|
DeviceFormFactor.isTablet();
|
||||||
|
RecordHistogram.recordBooleanHistogram(ASSET_PATH_WORKAROUND_HISTOGRAM_NAME, false);
|
||||||
} catch (Resources.NotFoundException e) {
|
} catch (Resources.NotFoundException e) {
|
||||||
|
RecordHistogram.recordBooleanHistogram(ASSET_PATH_WORKAROUND_HISTOGRAM_NAME, true);
|
||||||
mFactory.addWebViewAssetPath(context);
|
mFactory.addWebViewAssetPath(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -129,6 +129,9 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
|
|||||||
private static final String SUPPORT_LIB_GLUE_AND_BOUNDARY_INTERFACE_PREFIX =
|
private static final String SUPPORT_LIB_GLUE_AND_BOUNDARY_INTERFACE_PREFIX =
|
||||||
"org.chromium.support_lib_";
|
"org.chromium.support_lib_";
|
||||||
|
|
||||||
|
private static final String ASSET_PATH_WORKAROUND_HISTOGRAM_NAME =
|
||||||
|
"Android.WebView.AssetPathWorkaroundUsed.FactoryInit";
|
||||||
|
|
||||||
// This is an ID hardcoded by WebLayer for resources stored in locale splits. See
|
// This is an ID hardcoded by WebLayer for resources stored in locale splits. See
|
||||||
// WebLayerImpl.java for more info.
|
// WebLayerImpl.java for more info.
|
||||||
private static final int SHARED_LIBRARY_MAX_ID = 36;
|
private static final int SHARED_LIBRARY_MAX_ID = 36;
|
||||||
@@ -433,12 +436,14 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
|
|||||||
int packageId;
|
int packageId;
|
||||||
try {
|
try {
|
||||||
packageId = webViewDelegate.getPackageId(ctx.getResources(), resourcePackage);
|
packageId = webViewDelegate.getPackageId(ctx.getResources(), resourcePackage);
|
||||||
|
RecordHistogram.recordBooleanHistogram(ASSET_PATH_WORKAROUND_HISTOGRAM_NAME, false);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
// We failed to find the package ID, which likely means this context's AssetManager
|
// We failed to find the package ID, which likely means this context's AssetManager
|
||||||
// doesn't have WebView loaded in it. This may be because WebViewFactory doesn't add
|
// doesn't have WebView loaded in it. This may be because WebViewFactory doesn't add
|
||||||
// the package persistently to ResourcesManager and the app's AssetManager has been
|
// the package persistently to ResourcesManager and the app's AssetManager has been
|
||||||
// recreated. Try adding it again using WebViewDelegate, which does add it
|
// recreated. Try adding it again using WebViewDelegate, which does add it
|
||||||
// persistently.
|
// persistently.
|
||||||
|
RecordHistogram.recordBooleanHistogram(ASSET_PATH_WORKAROUND_HISTOGRAM_NAME, true);
|
||||||
addWebViewAssetPath(ctx);
|
addWebViewAssetPath(ctx);
|
||||||
packageId = webViewDelegate.getPackageId(ctx.getResources(), resourcePackage);
|
packageId = webViewDelegate.getPackageId(ctx.getResources(), resourcePackage);
|
||||||
}
|
}
|
||||||
|
@@ -5778,6 +5778,40 @@ chromium-metrics-reviews@google.com.
|
|||||||
</summary>
|
</summary>
|
||||||
</histogram>
|
</histogram>
|
||||||
|
|
||||||
|
<histogram name="Android.WebView.AssetPathWorkaroundUsed.FactoryInit"
|
||||||
|
enum="Boolean" expires_after="2025-09-11">
|
||||||
|
<owner>alexmitra@chromium.org</owner>
|
||||||
|
<owner>src/android_webview/OWNERS</owner>
|
||||||
|
<summary>
|
||||||
|
In some cases, WebView is unable to find the package ID which usually means
|
||||||
|
that the AssetManager for the Context passed to WebView doesn't have WebView
|
||||||
|
loaded in it. We have a rudimentary workaround for this which is to add
|
||||||
|
WebView's asset path to the Context. Since writing this workaround, we
|
||||||
|
believe we've addressed the underlying problem. Therefore the workaround
|
||||||
|
should no longer be needed. This histogram logs whether the asset path
|
||||||
|
workaround was needed during startup so that we can determine if it's safe
|
||||||
|
to remove. This is logged once during
|
||||||
|
WebViewChromiumFactoryProvider#initialize.
|
||||||
|
</summary>
|
||||||
|
</histogram>
|
||||||
|
|
||||||
|
<histogram name="Android.WebView.AssetPathWorkaroundUsed.StartChromiumLocked"
|
||||||
|
enum="Boolean" expires_after="2025-09-11">
|
||||||
|
<owner>alexmitra@chromium.org</owner>
|
||||||
|
<owner>src/android_webview/OWNERS</owner>
|
||||||
|
<summary>
|
||||||
|
In some cases, WebView is unable to find its own Resources which usually
|
||||||
|
means that the host app is doing something unsupported with the Context
|
||||||
|
passed to WebView (or with the platform Resources class). We have a
|
||||||
|
rudimentary workaround for this which is to add WebView's asset path to the
|
||||||
|
Context. Since writing this workaround, we believe we've addressed the
|
||||||
|
underlying problem. Therefore the workaround should no longer be needed.
|
||||||
|
This histogram logs whether the asset path workaround was needed during
|
||||||
|
startup so that we can determine if it's safe to remove. This is logged once
|
||||||
|
during WebViewChromiumAwInit#startChromiumLocked.
|
||||||
|
</summary>
|
||||||
|
</histogram>
|
||||||
|
|
||||||
<histogram name="Android.WebView.AwContentsConstructorTime{IsFirst}" units="ms"
|
<histogram name="Android.WebView.AwContentsConstructorTime{IsFirst}" units="ms"
|
||||||
expires_after="2025-09-07">
|
expires_after="2025-09-07">
|
||||||
<owner>cduvall@chromium.org</owner>
|
<owner>cduvall@chromium.org</owner>
|
||||||
|
Reference in New Issue
Block a user