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

Commit f19d30a4 authored by Li Li's avatar Li Li Committed by android-build-team Robot
Browse files

Fix process group of webview zygote

New processes forked from webview zygote should have their own process
group. Otherwise, some operations applied to any children will wrongly
impact all other children, like freezing or kill.

Bug: 62435375
Bug: 168907513
Bug: 189211698
Test: Verified webview children have their own cgroupfs node. Also,
freezing any children won't impact other children and webview zygote
itself.

Change-Id: I0606a8c8360fbb9e0851e2f799c6aaee521937ca
(cherry picked from commit da9ad351)
parent 5f14a83e
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -2377,6 +2377,7 @@ public final class ProcessList {
            }

            final Process.ProcessStartResult startResult;
            boolean regularZygote = false;
            if (hostingRecord.usesWebviewZygote()) {
                startResult = startWebView(entryPoint,
                        app.processName, uid, uid, gids, runtimeFlags, mountExternal,
@@ -2396,12 +2397,8 @@ public final class ProcessList {
                        app.getDisabledCompatChanges(), pkgDataInfoMap, allowlistedAppDataInfoMap,
                        false, false,
                        new String[]{PROC_START_SEQ_IDENT + app.getStartSeq()});

                if (Process.createProcessGroup(uid, startResult.pid) < 0) {
                    Slog.e(ActivityManagerService.TAG, "Unable to create process group for "
                            + app.processName + " (" + startResult.pid + ")");
                }
            } else {
                regularZygote = true;
                startResult = Process.start(entryPoint,
                        app.processName, uid, uid, gids, runtimeFlags, mountExternal,
                        app.info.targetSdkVersion, seInfo, requiredAbi, instructionSet,
@@ -2410,6 +2407,15 @@ public final class ProcessList {
                        allowlistedAppDataInfoMap, bindMountAppsData, bindMountAppStorageDirs,
                        new String[]{PROC_START_SEQ_IDENT + app.getStartSeq()});
            }

            if (!regularZygote) {
                // webview and app zygote don't have the permission to create the nodes
                if (Process.createProcessGroup(uid, startResult.pid) < 0) {
                    Slog.e(ActivityManagerService.TAG, "Unable to create process group for "
                            + app.processName + " (" + startResult.pid + ")");
                }
            }

            // This runs after Process.start() as this method may block app process starting time
            // if dir is not cached. Running this method after Process.start() can make it
            // cache the dir asynchronously, so zygote can use it without waiting for it.