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

Commit d80e894b authored by Keun-young Park's avatar Keun-young Park
Browse files

run webview preparation in separate thread

- There is no other dependency for webview from system server.
  Prepare it in separate thread and confirm completion
  before allowing 3rd party apps.

bug: 33840151
Test: manual, reboot
Change-Id: I417b0451c37f663c577295ab07f33474e72fe457
parent 45250aca
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import com.android.internal.logging.MetricsLogger;
import com.android.internal.os.BinderInternal;
import com.android.internal.os.SamplingProfilerIntegration;
import com.android.internal.policy.EmergencyAffordanceManager;
import com.android.internal.util.ConcurrentUtils;
import com.android.internal.widget.ILockSettings;
import com.android.server.accessibility.AccessibilityManagerService;
import com.android.server.am.ActivityManagerService;
@@ -117,6 +118,7 @@ import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;

import static android.view.Display.DEFAULT_DISPLAY;

@@ -1580,11 +1582,19 @@ public final class SystemServer {
            }
            traceEnd();

            // No dependency on Webview preparation in system server. But this should
            // be completed before allowring 3rd party
            final String WEBVIEW_PREPARATION = "WebViewFactoryPreparation";
            Future<?> webviewPrep = null;
            if (!mOnlyCore) {
                Slog.i(TAG, "WebViewFactory preparation");
                traceBeginAndSlog("WebViewFactoryPreparation");
                webviewPrep = SystemServerInitThreadPool.get().submit(() -> {
                    Slog.i(TAG, WEBVIEW_PREPARATION);
                    BootTimingsTraceLog traceLog = new BootTimingsTraceLog(
                            "SystemServerTiming", Trace.TRACE_TAG_SYSTEM_SERVER);
                    traceLog.traceBegin(WEBVIEW_PREPARATION);
                    mWebViewUpdateService.prepareWebViewInSystemServer();
                traceEnd();
                    traceLog.traceEnd();
                }, WEBVIEW_PREPARATION);
            }

            traceBeginAndSlog("StartSystemUI");
@@ -1641,6 +1651,10 @@ public final class SystemServer {
            Watchdog.getInstance().start();
            traceEnd();

            if (webviewPrep != null) {
                ConcurrentUtils.waitForFutureNoInterrupt(webviewPrep, WEBVIEW_PREPARATION);
            }

            // It is now okay to let the various system services start their
            // third party code...
            traceBeginAndSlog("PhaseThirdPartyAppsCanStart");