Commit e25a41d6 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Support stack_unwinder module in renderer process with isolated splits

This change moves the stack_unwinder module back out into a DFM since it
has no deps on //chrome Java code. After this change, module installer
can handle loading Java modules from isolated splits (although assets
will still take more work). Native libs are still in the base module, so
nothing special needs to be done there.

Bug: 1142967
Change-Id: I1af06b3153472581e058f606937de4e32f6a14ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2503581Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821618}
parent 42f76fd3
...@@ -295,7 +295,6 @@ android_library("chrome_java") { ...@@ -295,7 +295,6 @@ android_library("chrome_java") {
"//chrome/android/modules/cablev2_authenticator/public:java", "//chrome/android/modules/cablev2_authenticator/public:java",
"//chrome/android/modules/image_editor/provider:java", "//chrome/android/modules/image_editor/provider:java",
"//chrome/android/modules/image_editor/public:java", "//chrome/android/modules/image_editor/public:java",
"//chrome/android/modules/stack_unwinder/provider:java",
"//chrome/android/third_party/compositor_animator:compositor_animator_java", "//chrome/android/third_party/compositor_animator:compositor_animator_java",
"//chrome/android/webapk/libs/client:client_java", "//chrome/android/webapk/libs/client:client_java",
"//chrome/android/webapk/libs/common:common_java", "//chrome/android/webapk/libs/common:common_java",
...@@ -2143,6 +2142,9 @@ android_library("base_module_java") { ...@@ -2143,6 +2142,9 @@ android_library("base_module_java") {
"//components/viz/service:service_java", "//components/viz/service:service_java",
"//content/public/android:content_java", "//content/public/android:content_java",
# Deps for DFMs.
"//chrome/android/modules/stack_unwinder/provider:java",
# Deps to pull services into base module. # Deps to pull services into base module.
# TODO(crbug.com/1126301): Consider moving these to the chrome module to # TODO(crbug.com/1126301): Consider moving these to the chrome module to
# reduce base dex size. # reduce base dex size.
......
...@@ -10,4 +10,5 @@ stack_unwinder_module_desc = { ...@@ -10,4 +10,5 @@ stack_unwinder_module_desc = {
java_deps = [ "//chrome/android/modules/stack_unwinder/internal:java" ] java_deps = [ "//chrome/android/modules/stack_unwinder/internal:java" ]
native_deps = [ "//chrome/android/modules/stack_unwinder/internal:native" ] native_deps = [ "//chrome/android/modules/stack_unwinder/internal:native" ]
load_native_on_get_impl = false load_native_on_get_impl = false
supports_isolated_split = true
} }
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
package org.chromium.components.module_installer.builder; package org.chromium.components.module_installer.builder;
import android.content.Context;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.BundleUtils; import org.chromium.base.BundleUtils;
...@@ -107,7 +109,7 @@ public class Module<T> { ...@@ -107,7 +109,7 @@ public class Module<T> {
ensureNativeLoaded(); ensureNativeLoaded();
} }
mImpl = mInterfaceClass.cast(instantiateReflectively(mImplClassName)); mImpl = mInterfaceClass.cast(instantiateReflectively(mName, mImplClassName));
return mImpl; return mImpl;
} }
} }
...@@ -160,7 +162,7 @@ public class Module<T> { ...@@ -160,7 +162,7 @@ public class Module<T> {
} }
return (ModuleDescriptor) instantiateReflectively( return (ModuleDescriptor) instantiateReflectively(
"org.chromium.components.module_installer.builder.ModuleDescriptor_" + name); name, "org.chromium.components.module_installer.builder.ModuleDescriptor_" + name);
} }
/** /**
...@@ -169,15 +171,17 @@ public class Module<T> { ...@@ -169,15 +171,17 @@ public class Module<T> {
* Ignores strict mode violations since accessing code in a module may cause its DEX file to be * Ignores strict mode violations since accessing code in a module may cause its DEX file to be
* loaded and on some devices that can cause such a violation. * loaded and on some devices that can cause such a violation.
* *
* @param moduleName The module's name.
* @param className The object's class name. * @param className The object's class name.
* @return The object. * @return The object.
*/ */
private static Object instantiateReflectively(String className) { private static Object instantiateReflectively(String moduleName, String className) {
Context context = ContextUtils.getApplicationContext();
if (BundleUtils.isIsolatedSplitInstalled(context, moduleName)) {
context = BundleUtils.createIsolatedSplitContext(context, moduleName);
}
try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) {
return ContextUtils.getApplicationContext() return context.getClassLoader().loadClass(className).newInstance();
.getClassLoader()
.loadClass(className)
.newInstance();
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
......
...@@ -6,6 +6,7 @@ package org.chromium.components.module_installer.builder; ...@@ -6,6 +6,7 @@ package org.chromium.components.module_installer.builder;
import android.app.Activity; import android.app.Activity;
import org.chromium.base.BundleUtils;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.StrictModeContext; import org.chromium.base.StrictModeContext;
import org.chromium.components.module_installer.engine.EngineFactory; import org.chromium.components.module_installer.engine.EngineFactory;
...@@ -39,6 +40,12 @@ class ModuleEngine implements InstallEngine { ...@@ -39,6 +40,12 @@ class ModuleEngine implements InstallEngine {
@Override @Override
public boolean isInstalled(String moduleName) { public boolean isInstalled(String moduleName) {
// If the module is in an installed isolated split, it is installed.
if (BundleUtils.isIsolatedSplitInstalled(
ContextUtils.getApplicationContext(), moduleName)) {
return true;
}
// Accessing classes in the module may cause its DEX file to be loaded. And on some // Accessing classes in the module may cause its DEX file to be loaded. And on some
// devices that causes a read mode violation. // devices that causes a read mode violation.
try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment