Restart the WebView zygote after a WebView update.
The zygote is stopped when a WebView update occurs, and will be automatically restarted the first time an app tries to use it, but this means the first app to use WebView after an update pays a fairly large startup time penalty. Instead, queue a background task to wait for RELRO creation to be finished and then start the zygote immediately afterward, as we do at boot time, saving the app from paying this cost. Fixes: 112485729 Test: atest WebViewUpdateServiceTest Change-Id: I14159980851f423675b6a4ec0905cecda63e0e54
This commit is contained in:
@@ -163,6 +163,7 @@ class WebViewUpdateServiceImpl {
|
||||
}
|
||||
|
||||
void prepareWebViewInSystemServer() {
|
||||
mSystemInterface.notifyZygote(isMultiProcessEnabled());
|
||||
try {
|
||||
synchronized (mLock) {
|
||||
mCurrentWebViewPackage = findPreferredWebViewPackage();
|
||||
@@ -199,12 +200,6 @@ class WebViewUpdateServiceImpl {
|
||||
Slog.e(TAG, "No valid provider and no fallback available.");
|
||||
}
|
||||
}
|
||||
|
||||
boolean multiProcessEnabled = isMultiProcessEnabled();
|
||||
mSystemInterface.notifyZygote(multiProcessEnabled);
|
||||
if (multiProcessEnabled) {
|
||||
AsyncTask.THREAD_POOL_EXECUTOR.execute(this::startZygoteWhenReady);
|
||||
}
|
||||
}
|
||||
|
||||
private void startZygoteWhenReady() {
|
||||
@@ -358,6 +353,12 @@ class WebViewUpdateServiceImpl {
|
||||
mWebViewPackageDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Once we've notified the system that the provider has changed and started RELRO creation,
|
||||
// try to restart the zygote so that it will be ready when apps use it.
|
||||
if (isMultiProcessEnabled()) {
|
||||
AsyncTask.THREAD_POOL_EXECUTOR.execute(this::startZygoteWhenReady);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user