Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2eaf59d5 authored by Torne (Richard Coles)'s avatar Torne (Richard Coles) Committed by android-build-merger
Browse files

Merge "Wait for RELRO before starting WebViewZygote at boot." into qt-dev am: 49e9f80e

am: a38c6379

Change-Id: I6c09d518a6b87e6cfbe8a57e94f02fd03ca21019
parents 5bc25408 a38c6379
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.webkit;

import android.content.pm.PackageInfo;
import android.os.AsyncTask;
import android.os.Build;
import android.os.ChildZygoteProcess;
import android.os.Process;
@@ -81,17 +80,9 @@ public class WebViewZygote {
        synchronized (sLock) {
            sMultiprocessEnabled = enabled;

            // When toggling between multi-process being on/off, start or stop the
            // zygote. If it is enabled and the zygote is not yet started, launch it.
            // Otherwise, kill it. The name may be null if the package information has
            // not yet been resolved.
            if (enabled) {
                // Run on a background thread as this waits for the zygote to start and we don't
                // want to block the caller on this. It's okay if this is delayed as anyone trying
                // to use the zygote will call it first anyway.
                AsyncTask.THREAD_POOL_EXECUTOR.execute(WebViewZygote::getProcess);
            } else {
                // No need to run this in the background, it's very brief.
            // When multi-process is disabled, kill the zygote. When it is enabled,
            // the zygote will be started when it is first needed in getProcess().
            if (!enabled) {
                stopZygoteLocked();
            }
        }
+5 −0
Original line number Diff line number Diff line
@@ -265,6 +265,11 @@ public class SystemImpl implements SystemInterface {
        WebViewZygote.setMultiprocessEnabled(enableMultiProcess);
    }

    @Override
    public void ensureZygoteStarted() {
        WebViewZygote.getProcess();
    }

    @Override
    public boolean isMultiProcessDefaultEnabled() {
        // Multiprocess is enabled for all 64-bit devices, since the ability to run the renderer
+2 −0
Original line number Diff line number Diff line
@@ -61,5 +61,7 @@ public interface SystemInterface {
    public int getMultiProcessSetting(Context context);
    public void setMultiProcessSetting(Context context, int value);
    public void notifyZygote(boolean enableMultiProcess);
    /** Start the zygote if it's not already running. */
    public void ensureZygoteStarted();
    public boolean isMultiProcessDefaultEnabled();
}
+9 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.server.webkit;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.os.AsyncTask;
import android.os.UserHandle;
import android.webkit.WebViewProviderInfo;
import android.webkit.WebViewProviderResponse;
@@ -81,6 +82,14 @@ public class WebViewUpdateServiceImpl {
        migrateFallbackStateOnBoot();
        mWebViewUpdater.prepareWebViewInSystemServer();
        mSystemInterface.notifyZygote(isMultiProcessEnabled());
        AsyncTask.THREAD_POOL_EXECUTOR.execute(this::startZygoteWhenReady);
    }

    void startZygoteWhenReady() {
        // Wait on a background thread for RELRO creation to be done. We ignore the return value
        // because even if RELRO creation failed we still want to start the zygote.
        waitForAndGetProvider();
        mSystemInterface.ensureZygoteStarted();
    }

    void handleNewUser(int userId) {
+3 −0
Original line number Diff line number Diff line
@@ -184,6 +184,9 @@ public class TestSystemImpl implements SystemInterface {
    @Override
    public void notifyZygote(boolean enableMultiProcess) {}

    @Override
    public void ensureZygoteStarted() {}

    @Override
    public boolean isMultiProcessDefaultEnabled() {
        return mMultiProcessDefault;