diff --git a/src/Mono.Android/Android.Runtime/JNIEnvInit.cs b/src/Mono.Android/Android.Runtime/JNIEnvInit.cs index 9311757806e..585d7205909 100644 --- a/src/Mono.Android/Android.Runtime/JNIEnvInit.cs +++ b/src/Mono.Android/Android.Runtime/JNIEnvInit.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -80,6 +81,13 @@ static unsafe void RegisterJniNatives (IntPtr typeName_ptr, int typeName_len, In #endif internal static unsafe void Initialize (JnienvInitializeArgs* args) { + // var report = new System.Text.StringBuilder (); + // var total = new Stopwatch (); + // total.Start (); + + // var watch = new Stopwatch (); + // watch.Start (); + IntPtr total_timing_sequence = IntPtr.Zero; IntPtr partial_timing_sequence = IntPtr.Zero; @@ -97,13 +105,31 @@ internal static unsafe void Initialize (JnienvInitializeArgs* args) LocalRefsAreIndirect = args->localRefsAreIndirect == 1; + // watch.Stop (); + // report.Append ("Initialize: initialize fields:: "); + // report.Append (watch.ElapsedTicks); + // report.AppendLine (); + + // watch.Restart (); #if MONOANDROID1_0 Mono.SystemDependencyProvider.Initialize (); #endif + // watch.Stop (); + // report.Append ("Initialize: system deps init:: "); + // report.Append (watch.ElapsedTicks); + // report.AppendLine (); + // watch.Restart (); bool androidNewerThan10 = args->androidSdkVersion > 10; BoundExceptionType = (BoundExceptionType)args->ioExceptionType; + androidRuntime = new AndroidRuntime (args->env, args->javaVm, androidNewerThan10, args->grefLoader, args->Loader_loadClass, args->jniAddNativeMethodRegistrationAttributePresent != 0); + // watch.Stop (); + // report.Append ("Initialize: AndroidRuntime.ctor:: "); + // report.Append (watch.ElapsedTicks); + // report.AppendLine (); + + // watch.Restart (); AndroidValueManager = (AndroidValueManager) androidRuntime.ValueManager; AllocObjectSupported = androidNewerThan10; @@ -124,6 +150,17 @@ internal static unsafe void Initialize (JnienvInitializeArgs* args) #if !MONOANDROID1_0 SetSynchronizationContext (); #endif + // watch.Stop (); + // report.Append ("Initialize: the rest:: "); + // report.Append (watch.ElapsedTicks); + // report.AppendLine (); + + // total.Stop (); + // report.Append ("Initialize: total time:: "); + // report.Append (total.ElapsedTicks); + // report.AppendLine (); + + // Console.WriteLine ($"Initialize: {report.ToString ()}"); } #if !MONOANDROID1_0 diff --git a/src/Mono.Android/Android.Runtime/RuntimeNativeMethods.cs b/src/Mono.Android/Android.Runtime/RuntimeNativeMethods.cs index 3487514a6a7..7d5a35eea28 100644 --- a/src/Mono.Android/Android.Runtime/RuntimeNativeMethods.cs +++ b/src/Mono.Android/Android.Runtime/RuntimeNativeMethods.cs @@ -11,9 +11,11 @@ internal static class RuntimeNativeMethods [DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)] internal extern static void monodroid_log (LogLevel level, LogCategories category, string message); + [SuppressGCTransition] [DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)] internal extern static IntPtr monodroid_timing_start (string? message); + [SuppressGCTransition] [DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)] internal extern static void monodroid_timing_stop (IntPtr sequence, string? message); diff --git a/src/monodroid/jni/monodroid-glue.cc b/src/monodroid/jni/monodroid-glue.cc index ab041f4b1c9..46c26c7cda6 100644 --- a/src/monodroid/jni/monodroid-glue.cc +++ b/src/monodroid/jni/monodroid-glue.cc @@ -1133,6 +1133,7 @@ MonodroidRuntime::init_android_runtime ( "Failed to obtain unmanaged-callers-only pointer to the Android.Runtime.JNIEnvInit.Initialize method. %s", mono_error_get_message (&error) ); + log_info (LOG_DEFAULT, "Before INITIALIZE"); initialize (&init); #else // def NET && def ANDROID void *args [] = {