diff --git a/src/monodroid/jni/monodroid-glue-internal.hh b/src/monodroid/jni/monodroid-glue-internal.hh index 6bcbe179e4e..f93b52bb936 100644 --- a/src/monodroid/jni/monodroid-glue-internal.hh +++ b/src/monodroid/jni/monodroid-glue-internal.hh @@ -224,7 +224,7 @@ namespace xamarin::android::internal void disable_external_signal_handlers (); void lookup_bridge_info (MonoDomain *domain, MonoImage *image, const OSBridge::MonoJavaGCBridgeType *type, OSBridge::MonoJavaGCBridgeInfo *info); void load_assembly (MonoDomain *domain, jstring_wrapper &assembly); - void load_assemblies (MonoDomain *domain, jstring_array_wrapper &assemblies); + void load_assemblies (MonoDomain *domain, bool preload, jstring_array_wrapper &assemblies); void set_debug_options (); void parse_gdb_options (); void mono_runtime_init (dynamic_local_string& runtime_args); diff --git a/src/monodroid/jni/monodroid-glue.cc b/src/monodroid/jni/monodroid-glue.cc index bf7e293ed61..4a242caff94 100644 --- a/src/monodroid/jni/monodroid-glue.cc +++ b/src/monodroid/jni/monodroid-glue.cc @@ -1595,7 +1595,7 @@ MonodroidRuntime::load_assembly (MonoDomain *domain, jstring_wrapper &assembly) } inline void -MonodroidRuntime::load_assemblies (MonoDomain *domain, jstring_array_wrapper &assemblies) +MonodroidRuntime::load_assemblies (MonoDomain *domain, bool preload, jstring_array_wrapper &assemblies) { timing_period total_time; if (XA_UNLIKELY (utils.should_log (LOG_TIMING))) @@ -1604,6 +1604,9 @@ MonodroidRuntime::load_assemblies (MonoDomain *domain, jstring_array_wrapper &as for (size_t i = 0; i < assemblies.get_length (); ++i) { jstring_wrapper &assembly = assemblies [i]; load_assembly (domain, assembly); + // only load the first "main" assembly if we are not preloading. + if (!preload) + break; } if (XA_UNLIKELY (utils.should_log (LOG_TIMING))) { @@ -1638,8 +1641,8 @@ MonodroidRuntime::create_and_initialize_domain (JNIEnv* env, jclass runtimeClass if (assembliesBytes != nullptr) designerAssemblies.add_or_update_from_java (domain, env, assemblies, assembliesBytes, assembliesPaths); #endif - if (androidSystem.is_assembly_preload_enabled () || (is_running_on_desktop && force_preload_assemblies)) - load_assemblies (domain, assemblies); + bool preload = (androidSystem.is_assembly_preload_enabled () || (is_running_on_desktop && force_preload_assemblies)); + load_assemblies (domain, preload, assemblies); init_android_runtime (domain, env, runtimeClass, loader); osBridge.add_monodroid_domain (domain);