Merge "Rework WebView startup timestamp system API." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
99e37aca02
@@ -14733,7 +14733,7 @@ package android.webkit {
|
|||||||
method public String getDataDirectorySuffix();
|
method public String getDataDirectorySuffix();
|
||||||
method public String getErrorString(android.content.Context, int);
|
method public String getErrorString(android.content.Context, int);
|
||||||
method public int getPackageId(android.content.res.Resources, String);
|
method public int getPackageId(android.content.res.Resources, String);
|
||||||
method @NonNull public long[] getTimestamps();
|
method @NonNull public android.webkit.WebViewFactory.StartupTimestamps getStartupTimestamps();
|
||||||
method @Deprecated public void invokeDrawGlFunctor(android.view.View, long, boolean);
|
method @Deprecated public void invokeDrawGlFunctor(android.view.View, long, boolean);
|
||||||
method public boolean isMultiProcessEnabled();
|
method public boolean isMultiProcessEnabled();
|
||||||
method public boolean isTraceTagEnabled();
|
method public boolean isTraceTagEnabled();
|
||||||
@@ -14749,12 +14749,6 @@ package android.webkit {
|
|||||||
method public static android.content.pm.PackageInfo getLoadedPackageInfo();
|
method public static android.content.pm.PackageInfo getLoadedPackageInfo();
|
||||||
method public static int loadWebViewNativeLibraryFromPackage(String, ClassLoader);
|
method public static int loadWebViewNativeLibraryFromPackage(String, ClassLoader);
|
||||||
method public static void prepareWebViewInZygote();
|
method public static void prepareWebViewInZygote();
|
||||||
field public static final int ADD_ASSETS_END = 4; // 0x4
|
|
||||||
field public static final int ADD_ASSETS_START = 3; // 0x3
|
|
||||||
field public static final int CREATE_CONTEXT_END = 2; // 0x2
|
|
||||||
field public static final int CREATE_CONTEXT_START = 1; // 0x1
|
|
||||||
field public static final int GET_CLASS_LOADER_END = 6; // 0x6
|
|
||||||
field public static final int GET_CLASS_LOADER_START = 5; // 0x5
|
|
||||||
field public static final int LIBLOAD_ADDRESS_SPACE_NOT_RESERVED = 2; // 0x2
|
field public static final int LIBLOAD_ADDRESS_SPACE_NOT_RESERVED = 2; // 0x2
|
||||||
field public static final int LIBLOAD_FAILED_JNI_CALL = 7; // 0x7
|
field public static final int LIBLOAD_FAILED_JNI_CALL = 7; // 0x7
|
||||||
field public static final int LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES = 4; // 0x4
|
field public static final int LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES = 4; // 0x4
|
||||||
@@ -14765,11 +14759,20 @@ package android.webkit {
|
|||||||
field public static final int LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN = 8; // 0x8
|
field public static final int LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN = 8; // 0x8
|
||||||
field public static final int LIBLOAD_SUCCESS = 0; // 0x0
|
field public static final int LIBLOAD_SUCCESS = 0; // 0x0
|
||||||
field public static final int LIBLOAD_WRONG_PACKAGE_NAME = 1; // 0x1
|
field public static final int LIBLOAD_WRONG_PACKAGE_NAME = 1; // 0x1
|
||||||
field public static final int NATIVE_LOAD_END = 8; // 0x8
|
}
|
||||||
field public static final int NATIVE_LOAD_START = 7; // 0x7
|
|
||||||
field public static final int PROVIDER_CLASS_FOR_NAME_END = 10; // 0xa
|
public static class WebViewFactory.StartupTimestamps {
|
||||||
field public static final int PROVIDER_CLASS_FOR_NAME_START = 9; // 0x9
|
method public long getAddAssetsEnd();
|
||||||
field public static final int WEBVIEW_LOAD_START = 0; // 0x0
|
method public long getAddAssetsStart();
|
||||||
|
method public long getCreateContextEnd();
|
||||||
|
method public long getCreateContextStart();
|
||||||
|
method public long getGetClassLoaderEnd();
|
||||||
|
method public long getGetClassLoaderStart();
|
||||||
|
method public long getNativeLoadEnd();
|
||||||
|
method public long getNativeLoadStart();
|
||||||
|
method public long getProviderClassForNameEnd();
|
||||||
|
method public long getProviderClassForNameStart();
|
||||||
|
method public long getWebViewLoadStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface WebViewFactoryProvider {
|
public interface WebViewFactoryProvider {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package android.webkit;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.annotation.UptimeMillisLong;
|
|
||||||
import android.app.ActivityThread;
|
import android.app.ActivityThread;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.app.ResourcesManager;
|
import android.app.ResourcesManager;
|
||||||
@@ -221,14 +220,12 @@ public final class WebViewDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of startup timestamps. For the specification of array
|
* Get the timestamps at which various WebView startup events occurred in this process.
|
||||||
* see {@link WebViewFactory.Timestamp}.
|
|
||||||
* This method must be called on the same thread where the
|
* This method must be called on the same thread where the
|
||||||
* WebViewChromiumFactoryProvider#create method was invoked.
|
* WebViewChromiumFactoryProvider#create method was invoked.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
@UptimeMillisLong
|
public WebViewFactory.StartupTimestamps getStartupTimestamps() {
|
||||||
public long[] getTimestamps() {
|
return WebViewFactory.getStartupTimestamps();
|
||||||
return WebViewFactory.getTimestamps();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package android.webkit;
|
package android.webkit;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
|
import android.annotation.UptimeMillisLong;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.AppGlobals;
|
import android.app.AppGlobals;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
@@ -38,8 +38,6 @@ import android.util.ArraySet;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,44 +70,6 @@ public final class WebViewFactory {
|
|||||||
private static boolean sWebViewDisabled;
|
private static boolean sWebViewDisabled;
|
||||||
private static String sDataDirectorySuffix; // stored here so it can be set without loading WV
|
private static String sDataDirectorySuffix; // stored here so it can be set without loading WV
|
||||||
|
|
||||||
// Indices in sTimestamps array.
|
|
||||||
/** @hide */
|
|
||||||
@IntDef(value = {
|
|
||||||
WEBVIEW_LOAD_START, CREATE_CONTEXT_START, CREATE_CONTEXT_END,
|
|
||||||
ADD_ASSETS_START, ADD_ASSETS_END, GET_CLASS_LOADER_START, GET_CLASS_LOADER_END,
|
|
||||||
NATIVE_LOAD_START, NATIVE_LOAD_END,
|
|
||||||
PROVIDER_CLASS_FOR_NAME_START, PROVIDER_CLASS_FOR_NAME_END})
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
|
||||||
public @interface Timestamp {
|
|
||||||
}
|
|
||||||
|
|
||||||
/** When the overall WebView provider load began. */
|
|
||||||
public static final int WEBVIEW_LOAD_START = 0;
|
|
||||||
/** Before creating the WebView APK Context. */
|
|
||||||
public static final int CREATE_CONTEXT_START = 1;
|
|
||||||
/** After creating the WebView APK Context. */
|
|
||||||
public static final int CREATE_CONTEXT_END = 2;
|
|
||||||
/** Before adding WebView assets to AssetManager. */
|
|
||||||
public static final int ADD_ASSETS_START = 3;
|
|
||||||
/** After adding WebView assets to AssetManager. */
|
|
||||||
public static final int ADD_ASSETS_END = 4;
|
|
||||||
/** Before creating the WebView ClassLoader. */
|
|
||||||
public static final int GET_CLASS_LOADER_START = 5;
|
|
||||||
/** After creating the WebView ClassLoader. */
|
|
||||||
public static final int GET_CLASS_LOADER_END = 6;
|
|
||||||
/** Before preloading the WebView native library. */
|
|
||||||
public static final int NATIVE_LOAD_START = 7;
|
|
||||||
/** After preloading the WebView native library. */
|
|
||||||
public static final int NATIVE_LOAD_END = 8;
|
|
||||||
/** Before looking up the WebView provider class. */
|
|
||||||
public static final int PROVIDER_CLASS_FOR_NAME_START = 9;
|
|
||||||
/** After looking up the WebView provider class. */
|
|
||||||
public static final int PROVIDER_CLASS_FOR_NAME_END = 10;
|
|
||||||
private static final int TIMESTAMPS_SIZE = 11;
|
|
||||||
|
|
||||||
// WebView startup timestamps. To access elements use {@link Timestamp}.
|
|
||||||
private static long[] sTimestamps = new long[TIMESTAMPS_SIZE];
|
|
||||||
|
|
||||||
// Error codes for loadWebViewNativeLibraryFromPackage
|
// Error codes for loadWebViewNativeLibraryFromPackage
|
||||||
public static final int LIBLOAD_SUCCESS = 0;
|
public static final int LIBLOAD_SUCCESS = 0;
|
||||||
public static final int LIBLOAD_WRONG_PACKAGE_NAME = 1;
|
public static final int LIBLOAD_WRONG_PACKAGE_NAME = 1;
|
||||||
@@ -130,6 +90,97 @@ public final class WebViewFactory {
|
|||||||
// error for namespace lookup
|
// error for namespace lookup
|
||||||
public static final int LIBLOAD_FAILED_TO_FIND_NAMESPACE = 10;
|
public static final int LIBLOAD_FAILED_TO_FIND_NAMESPACE = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the timestamps at which various WebView startup events occurred in this process.
|
||||||
|
*/
|
||||||
|
public static class StartupTimestamps {
|
||||||
|
long mWebViewLoadStart;
|
||||||
|
long mCreateContextStart;
|
||||||
|
long mCreateContextEnd;
|
||||||
|
long mAddAssetsStart;
|
||||||
|
long mAddAssetsEnd;
|
||||||
|
long mGetClassLoaderStart;
|
||||||
|
long mGetClassLoaderEnd;
|
||||||
|
long mNativeLoadStart;
|
||||||
|
long mNativeLoadEnd;
|
||||||
|
long mProviderClassForNameStart;
|
||||||
|
long mProviderClassForNameEnd;
|
||||||
|
|
||||||
|
StartupTimestamps() {}
|
||||||
|
|
||||||
|
/** When the overall WebView provider load began. */
|
||||||
|
@UptimeMillisLong
|
||||||
|
public long getWebViewLoadStart() {
|
||||||
|
return mWebViewLoadStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Before creating the WebView APK Context. */
|
||||||
|
@UptimeMillisLong
|
||||||
|
public long getCreateContextStart() {
|
||||||
|
return mCreateContextStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** After creating the WebView APK Context. */
|
||||||
|
@UptimeMillisLong
|
||||||
|
public long getCreateContextEnd() {
|
||||||
|
return mCreateContextEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Before adding WebView assets to AssetManager. */
|
||||||
|
@UptimeMillisLong
|
||||||
|
public long getAddAssetsStart() {
|
||||||
|
return mAddAssetsStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** After adding WebView assets to AssetManager. */
|
||||||
|
@UptimeMillisLong
|
||||||
|
public long getAddAssetsEnd() {
|
||||||
|
return mAddAssetsEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Before creating the WebView ClassLoader. */
|
||||||
|
@UptimeMillisLong
|
||||||
|
public long getGetClassLoaderStart() {
|
||||||
|
return mGetClassLoaderStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** After creating the WebView ClassLoader. */
|
||||||
|
@UptimeMillisLong
|
||||||
|
public long getGetClassLoaderEnd() {
|
||||||
|
return mGetClassLoaderEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Before preloading the WebView native library. */
|
||||||
|
@UptimeMillisLong
|
||||||
|
public long getNativeLoadStart() {
|
||||||
|
return mNativeLoadStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** After preloading the WebView native library. */
|
||||||
|
@UptimeMillisLong
|
||||||
|
public long getNativeLoadEnd() {
|
||||||
|
return mNativeLoadEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Before looking up the WebView provider class. */
|
||||||
|
@UptimeMillisLong
|
||||||
|
public long getProviderClassForNameStart() {
|
||||||
|
return mProviderClassForNameStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** After looking up the WebView provider class. */
|
||||||
|
@UptimeMillisLong
|
||||||
|
public long getProviderClassForNameEnd() {
|
||||||
|
return mProviderClassForNameEnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static final StartupTimestamps sTimestamps = new StartupTimestamps();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
static StartupTimestamps getStartupTimestamps() {
|
||||||
|
return sTimestamps;
|
||||||
|
}
|
||||||
|
|
||||||
private static String getWebViewPreparationErrorReason(int error) {
|
private static String getWebViewPreparationErrorReason(int error) {
|
||||||
switch (error) {
|
switch (error) {
|
||||||
@@ -273,7 +324,7 @@ public final class WebViewFactory {
|
|||||||
// us honest and minimize usage of WebView internals when binding the proxy.
|
// us honest and minimize usage of WebView internals when binding the proxy.
|
||||||
if (sProviderInstance != null) return sProviderInstance;
|
if (sProviderInstance != null) return sProviderInstance;
|
||||||
|
|
||||||
sTimestamps[WEBVIEW_LOAD_START] = SystemClock.uptimeMillis();
|
sTimestamps.mWebViewLoadStart = SystemClock.uptimeMillis();
|
||||||
final int uid = android.os.Process.myUid();
|
final int uid = android.os.Process.myUid();
|
||||||
if (uid == android.os.Process.ROOT_UID || uid == android.os.Process.SYSTEM_UID
|
if (uid == android.os.Process.ROOT_UID || uid == android.os.Process.SYSTEM_UID
|
||||||
|| uid == android.os.Process.PHONE_UID || uid == android.os.Process.NFC_UID
|
|| uid == android.os.Process.PHONE_UID || uid == android.os.Process.NFC_UID
|
||||||
@@ -413,7 +464,7 @@ public final class WebViewFactory {
|
|||||||
|
|
||||||
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW,
|
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW,
|
||||||
"initialApplication.createApplicationContext");
|
"initialApplication.createApplicationContext");
|
||||||
sTimestamps[CREATE_CONTEXT_START] = SystemClock.uptimeMillis();
|
sTimestamps.mCreateContextStart = SystemClock.uptimeMillis();
|
||||||
try {
|
try {
|
||||||
// Construct an app context to load the Java code into the current app.
|
// Construct an app context to load the Java code into the current app.
|
||||||
Context webViewContext = initialApplication.createApplicationContext(
|
Context webViewContext = initialApplication.createApplicationContext(
|
||||||
@@ -422,7 +473,7 @@ public final class WebViewFactory {
|
|||||||
sPackageInfo = newPackageInfo;
|
sPackageInfo = newPackageInfo;
|
||||||
return webViewContext;
|
return webViewContext;
|
||||||
} finally {
|
} finally {
|
||||||
sTimestamps[CREATE_CONTEXT_END] = SystemClock.uptimeMillis();
|
sTimestamps.mCreateContextEnd = SystemClock.uptimeMillis();
|
||||||
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
|
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
|
||||||
}
|
}
|
||||||
} catch (RemoteException | PackageManager.NameNotFoundException e) {
|
} catch (RemoteException | PackageManager.NameNotFoundException e) {
|
||||||
@@ -448,26 +499,26 @@ public final class WebViewFactory {
|
|||||||
|
|
||||||
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getChromiumProviderClass()");
|
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getChromiumProviderClass()");
|
||||||
try {
|
try {
|
||||||
sTimestamps[ADD_ASSETS_START] = SystemClock.uptimeMillis();
|
sTimestamps.mAddAssetsStart = SystemClock.uptimeMillis();
|
||||||
for (String newAssetPath : webViewContext.getApplicationInfo().getAllApkPaths()) {
|
for (String newAssetPath : webViewContext.getApplicationInfo().getAllApkPaths()) {
|
||||||
initialApplication.getAssets().addAssetPathAsSharedLibrary(newAssetPath);
|
initialApplication.getAssets().addAssetPathAsSharedLibrary(newAssetPath);
|
||||||
}
|
}
|
||||||
sTimestamps[ADD_ASSETS_END] = sTimestamps[GET_CLASS_LOADER_START] =
|
sTimestamps.mAddAssetsEnd = sTimestamps.mGetClassLoaderStart =
|
||||||
SystemClock.uptimeMillis();
|
SystemClock.uptimeMillis();
|
||||||
ClassLoader clazzLoader = webViewContext.getClassLoader();
|
ClassLoader clazzLoader = webViewContext.getClassLoader();
|
||||||
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.loadNativeLibrary()");
|
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.loadNativeLibrary()");
|
||||||
sTimestamps[GET_CLASS_LOADER_END] = sTimestamps[NATIVE_LOAD_START] =
|
sTimestamps.mGetClassLoaderEnd = sTimestamps.mNativeLoadStart =
|
||||||
SystemClock.uptimeMillis();
|
SystemClock.uptimeMillis();
|
||||||
WebViewLibraryLoader.loadNativeLibrary(clazzLoader,
|
WebViewLibraryLoader.loadNativeLibrary(clazzLoader,
|
||||||
getWebViewLibrary(sPackageInfo.applicationInfo));
|
getWebViewLibrary(sPackageInfo.applicationInfo));
|
||||||
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
|
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
|
||||||
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "Class.forName()");
|
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "Class.forName()");
|
||||||
sTimestamps[NATIVE_LOAD_END] = sTimestamps[PROVIDER_CLASS_FOR_NAME_START] =
|
sTimestamps.mNativeLoadEnd = sTimestamps.mProviderClassForNameStart =
|
||||||
SystemClock.uptimeMillis();
|
SystemClock.uptimeMillis();
|
||||||
try {
|
try {
|
||||||
return getWebViewProviderClass(clazzLoader);
|
return getWebViewProviderClass(clazzLoader);
|
||||||
} finally {
|
} finally {
|
||||||
sTimestamps[PROVIDER_CLASS_FOR_NAME_END] = SystemClock.uptimeMillis();
|
sTimestamps.mProviderClassForNameEnd = SystemClock.uptimeMillis();
|
||||||
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
|
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
@@ -529,9 +580,4 @@ public final class WebViewFactory {
|
|||||||
return IWebViewUpdateService.Stub.asInterface(
|
return IWebViewUpdateService.Stub.asInterface(
|
||||||
ServiceManager.getService(WEBVIEW_UPDATE_SERVICE_NAME));
|
ServiceManager.getService(WEBVIEW_UPDATE_SERVICE_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
|
||||||
static long[] getTimestamps() {
|
|
||||||
return sTimestamps;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user