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

Commit 0a24f333 authored by Aditya's avatar Aditya
Browse files

Fix for kernal panic caused by large number of threads.

The problem is triggered by the broadcast received durint app uninstall,
resulting in DocsUi creating thread pools faster than they can exit.

To fix this, `CachedThreadPool` has been replaced by a static
`FixedThreadPool` of 10 threads.

Bug: 365682930
Test: Samsung QA
Flag: EXEMPT bugfix
Change-Id: I0017151d1141f0d2ddf04925b68619d73a241997
parent 56ee25a2
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ import com.android.modules.utils.build.SdkLevel;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.util.concurrent.MoreExecutors;

import java.util.ArrayList;
import java.util.Collection;
@@ -76,7 +75,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

@@ -95,6 +93,9 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName {
            // ArchivesProvider doesn't support any roots.
            ArchivesProvider.AUTHORITY);
    private static final int FIRST_LOAD_TIMEOUT_MS = 5000;
    private static final int NUM_THREADS = 10;
    private static final ExecutorService ASYNC_TASKS_THREAD_POOL =
            Executors.newFixedThreadPool(NUM_THREADS);

    private final Context mContext;

@@ -562,8 +563,7 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName {

            if (!taskInfos.isEmpty()) {
                CountDownLatch updateTaskInternalCountDown = new CountDownLatch(taskInfos.size());
                ExecutorService executor = MoreExecutors.getExitingExecutorService(
                        (ThreadPoolExecutor) Executors.newCachedThreadPool());
                ExecutorService executor = ASYNC_TASKS_THREAD_POOL;
                for (SingleProviderUpdateTaskInfo taskInfo : taskInfos) {
                    executor.submit(() ->
                            startSingleProviderUpdateTask(