Skip to content

Commit

Permalink
webview: remove ActualUiThread metric.
Browse files Browse the repository at this point in the history
Remove the Android.WebView.ActualUiThread metric. The data shows the
case where the UI thread decision is deferred is extremely rare, and
when it is, it's virtually always ultimately the main looper. There's no
need to keep collecting it.

Fixed: 1178535
Bug: 1106486
Change-Id: Id71246a80134cb43bcb3797bee1294e05ef4950f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2698988
Reviewed-by: Mark Pearson <[email protected]>
Reviewed-by: Anna Malova <[email protected]>
Commit-Queue: Richard Coles <[email protected]>
Cr-Commit-Position: refs/heads/master@{#855767}
  • Loading branch information
tornewuff authored and Chromium LUCI CQ committed Feb 19, 2021
1 parent 043eddd commit 67f257d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,6 @@ public void init(final Map<String, Object> javaScriptInterfaces,
} else if (!mFactory.hasStarted()) {
if (Looper.myLooper() == Looper.getMainLooper()) {
mFactory.startYourEngines(true);
} else {
// Record which thread we're on now so we can track whether the final UI thread
// decision differed.
mFactory.getAwInit().setFirstWebViewConstructedOn(Looper.myLooper());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import android.webkit.WebStorage;
import android.webkit.WebViewDatabase;

import androidx.annotation.IntDef;

import org.chromium.android_webview.AwBrowserContext;
import org.chromium.android_webview.AwBrowserProcess;
import org.chromium.android_webview.AwContents;
Expand Down Expand Up @@ -94,7 +92,6 @@ public class WebViewChromiumAwInit {
private static final int INIT_FINISHED = 2;
// Read/write protected by mLock
private int mInitState;
private Looper mFirstWebViewConstructedOn;

private final WebViewChromiumFactoryProvider mFactory;

Expand Down Expand Up @@ -249,32 +246,6 @@ private void setUpResources(int packageId, Context context) {
}
}

// Only called for apps which target <JB MR2, and which construct WebView on a non-main thread.
void setFirstWebViewConstructedOn(Looper looper) {
synchronized (mLock) {
if (mInitState != INIT_FINISHED && mFirstWebViewConstructedOn == null) {
mFirstWebViewConstructedOn = looper;
}
}
}

// Used to record the UMA histogram Android.WebView.ActualUiThread. Since these values are
// persisted to logs, they should never be renumbered or reused.
@IntDef({ActualUiThread.FIRST_WEBVIEW_CONSTRUCTED, ActualUiThread.MAIN_LOOPER,
ActualUiThread.OTHER})
@interface ActualUiThread {
int FIRST_WEBVIEW_CONSTRUCTED = 0;
int MAIN_LOOPER = 1;
int OTHER = 2;

int COUNT = 3;
}

private static void recordActualUiThread(@ActualUiThread int value) {
RecordHistogram.recordEnumeratedHistogram(
"Android.WebView.ActualUiThread", value, ActualUiThread.COUNT);
}

boolean hasStarted() {
return mInitState == INIT_FINISHED;
}
Expand Down Expand Up @@ -347,23 +318,6 @@ private void setChromiumUiThreadLocked(boolean fromThreadSafeFunction) {
+ (Looper.getMainLooper().equals(looper) ? "main" : "background")
+ " looper " + looper);
ThreadUtils.setUiThread(looper);

// For apps targeting <JBMR2 which aren't required to commit to a thread in
// WebViewChromium.init, record a metric stating which thread we picked.
if (mFirstWebViewConstructedOn != null) {
if (looper == mFirstWebViewConstructedOn) {
// Using the same thread that the first WebView was constructed on.
recordActualUiThread(ActualUiThread.FIRST_WEBVIEW_CONSTRUCTED);
} else if (looper == Looper.getMainLooper()) {
// Using the main looper.
recordActualUiThread(ActualUiThread.MAIN_LOOPER);
} else {
// Using some other thread.
recordActualUiThread(ActualUiThread.OTHER);
}
// Reset to null to avoid leaking the app's looper.
mFirstWebViewConstructedOn = null;
}
}

private void initPlatSupportLibrary() {
Expand Down
3 changes: 3 additions & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,9 @@ Unknown properties are collapsed to zero. -->
</enum>

<enum name="AndroidWebViewActualUiThread">
<obsolete>
Removed 02/2020. The ActualUiThread metric has been removed.
</obsolete>
<int value="0" label="The thread on which the first WebView was constructed"/>
<int value="1" label="The main looper"/>
<int value="2" label="Some other thread"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2242,6 +2242,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.

<histogram name="Android.WebView.ActualUiThread"
enum="AndroidWebViewActualUiThread" expires_after="2021-03-31">
<obsolete>
Removed Feb 2021; they virtually always use the main thread.
</obsolete>
<owner>[email protected]</owner>
<owner>src/android_webview/OWNERS</owner>
<summary>
Expand Down

0 comments on commit 67f257d

Please sign in to comment.