Commit f67e7814 authored by Changwan Ryu's avatar Changwan Ryu Committed by Commit Bot

Add more trace events

There is some gap at the beginning of
WebViewChromiumFactoryProvider#initialize().

Also, the title 'loadPlatSupportLibrary' is somewhat misleading, so
splitting it up and renaming/refactoring them.

Finally, adding some comment about startup investigation.

Bug: 817644
Change-Id: Id0fa91a46f81c4a4bd43e9dbd8ecbcb70a658608
Reviewed-on: https://chromium-review.googlesource.com/1069248Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Changwan Ryu <changwan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560688}
parent d99dda01
......@@ -164,6 +164,34 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
return new WebViewChromiumAwInit(this);
}
private void deleteContentsOnPackageDowngrade(PackageInfo packageInfo) {
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try (ScopedSysTraceEvent e2 = ScopedSysTraceEvent.scoped(
"WebViewChromiumFactoryProvider.deleteContentsOnPackageDowngrade")) {
// Use shared preference to check for package downgrade.
// Since N, getSharedPreferences creates the preference dir if it doesn't exist,
// causing a disk write.
mWebViewPrefs = ContextUtils.getApplicationContext().getSharedPreferences(
CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE);
int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0);
int currentVersion = packageInfo.versionCode;
if (!versionCodeGE(currentVersion, lastVersion)) {
// The WebView package has been downgraded since we last ran in this
// application. Delete the WebView data directory's contents.
String dataDir = PathUtils.getDataDirectory();
Log.i(TAG,
"WebView package downgraded from " + lastVersion + " to "
+ currentVersion + "; deleting contents of " + dataDir);
deleteContents(new File(dataDir));
}
if (lastVersion != currentVersion) {
mWebViewPrefs.edit().putInt(VERSION_CODE_PREF, currentVersion).apply();
}
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
}
@TargetApi(Build.VERSION_CODES.N) // For getSystemService() and isUserUnlocked().
private void initialize(WebViewDelegate webViewDelegate) {
long startTime = SystemClock.elapsedRealtime();
......@@ -196,6 +224,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
try (ScopedSysTraceEvent e2 = ScopedSysTraceEvent.scoped(
"WebViewChromiumFactoryProvider.initCommandLine")) {
// This may take ~20 ms only on userdebug devices.
CommandLineUtil.initCommandLine();
}
......@@ -218,37 +247,18 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
ThreadUtils.setWillOverrideUiThread();
BuildInfo.setBrowserPackageInfo(packageInfo);
// Load chromium library.
AwBrowserProcess.loadLibrary(mWebViewDelegate.getDataDirectorySuffix());
try (ScopedSysTraceEvent e2 = ScopedSysTraceEvent.scoped(
"WebViewChromiumFactoryProvider.loadChromiumLibrary")) {
AwBrowserProcess.loadLibrary(mWebViewDelegate.getDataDirectorySuffix());
}
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try (ScopedSysTraceEvent e2 = ScopedSysTraceEvent.scoped(
"WebViewChromiumFactoryProvider.loadPlatSupportLibrary")) {
// Load glue-layer support library.
"WebViewChromiumFactoryProvider.loadGlueLayerPlatSupportLibrary")) {
System.loadLibrary("webviewchromium_plat_support");
// Use shared preference to check for package downgrade.
// Since N, getSharedPreferences creates the preference dir if it doesn't exist,
// causing a disk write.
mWebViewPrefs = ContextUtils.getApplicationContext().getSharedPreferences(
CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE);
int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0);
int currentVersion = packageInfo.versionCode;
if (!versionCodeGE(currentVersion, lastVersion)) {
// The WebView package has been downgraded since we last ran in this
// application. Delete the WebView data directory's contents.
String dataDir = PathUtils.getDataDirectory();
Log.i(TAG,
"WebView package downgraded from " + lastVersion + " to "
+ currentVersion + "; deleting contents of " + dataDir);
deleteContents(new File(dataDir));
}
if (lastVersion != currentVersion) {
mWebViewPrefs.edit().putInt(VERSION_CODE_PREF, currentVersion).apply();
}
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
deleteContentsOnPackageDowngrade(packageInfo);
// Now safe to use WebView data directory.
mAwInit.startVariationsInit();
......
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