OSDN Git Service

[framework] Compile secondary dex files in isolation
authorCalin Juravle <calin@google.com>
Wed, 4 Oct 2017 17:53:09 +0000 (10:53 -0700)
committerAndreas Gampe <agampe@google.com>
Thu, 2 Nov 2017 16:37:15 +0000 (09:37 -0700)
The class loader context adds the overhead of extracting in-memory and
possibly extra verification which is being frowned upon when the loading
happens on the UI thread. Revert the correct fix of compiling secondary
dex files with their loading context until b/64530081 is done.

Partial revert of commit f1ff36f0f99ebb41d0c7e0f3248506a56998fa3f.

(cherry picked from commit 27f926212483e8291a63884e60fa44de4d0df17c)

Test: adb shell cmd package compile -m quicken -f --secondary-dex
com.google.android.gms
Bug: 64530081
Bug: 66984396
Merged-In: Ib2815ce67b224883fe95c28d1424103e56342c6e
Change-Id: Ib2815ce67b224883fe95c28d1424103e56342c6e

services/core/java/com/android/server/pm/PackageDexOptimizer.java

index 2e955be..ef015e7 100644 (file)
@@ -366,18 +366,13 @@ public class PackageDexOptimizer {
                 + " dexoptFlags=" + printDexoptFlags(dexoptFlags)
                 + " target-filter=" + compilerFilter);
 
-        String classLoaderContext;
-        if (dexUseInfo.isUnknownClassLoaderContext() ||
-                dexUseInfo.isUnsupportedClassLoaderContext() ||
-                dexUseInfo.isVariableClassLoaderContext()) {
-            // If we have an unknown (not yet set), unsupported (custom class loaders), or a
-            // variable class loader chain, compile without a context and mark the oat file with
-            // SKIP_SHARED_LIBRARY_CHECK. Note that his might lead to a incorrect compilation.
-            // TODO(calin): We should just extract in this case.
-            classLoaderContext = SKIP_SHARED_LIBRARY_CHECK;
-        } else {
-            classLoaderContext = dexUseInfo.getClassLoaderContext();
-        }
+        // TODO(calin): b/64530081 b/66984396. Use SKIP_SHARED_LIBRARY_CHECK for the context
+        // (instead of dexUseInfo.getClassLoaderContext()) in order to compile secondary dex files
+        // in isolation (and avoid to extract/verify the main apk if it's in the class path).
+        // Note this trades correctness for performance since the resulting slow down is
+        // unacceptable in some cases until b/64530081 is fixed.
+        String classLoaderContext = SKIP_SHARED_LIBRARY_CHECK;
+
         try {
             for (String isa : dexUseInfo.getLoaderIsas()) {
                 // Reuse the same dexopt path as for the primary apks. We don't need all the