Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mono.Android] add "built-in" delegate for _JniMarshal_PPII_L #8245

Merged

Commits on Aug 7, 2023

  1. [Mono.Android] add "built-in" delegate for _JniMarshal_PPII_L

    I noticed some methods appear when creating a new `.aotprofile` for .NET
    MAUI:
    
        void System.Reflection.Emit.RuntimeILGenerator:.ctor (System.Reflection.Module,System.Reflection.Emit.ITokenGenerator,int)
        void System.Reflection.Emit.RuntimeILGenerator:BeginCatchBlock (System.Type)
        void System.Reflection.Emit.RuntimeILGenerator:Emit (System.Reflection.Emit.OpCode,int)
        void System.Reflection.Emit.RuntimeILGenerator:Emit (System.Reflection.Emit.OpCode,System.Reflection.Emit.Label)
        void System.Reflection.Emit.RuntimeILGenerator:Emit (System.Reflection.Emit.OpCode,System.Reflection.Emit.LocalBuilder)
        void System.Reflection.Emit.RuntimeILGenerator:Emit (System.Reflection.Emit.OpCode,System.Reflection.MethodInfo)
        void System.Reflection.Emit.RuntimeILGenerator:Emit (System.Reflection.Emit.OpCode)
    
    We generally don't want S.R.E to run at application startup. This can
    happen when `Android.Runtime.JNINativeWrapper:CreateBuiltInDelegate`
    doesn't find a match. We fallback to S.R.E in that case.
    
    Running a `dotnet new maui` app w/ .NET 8 Preview 7 logs the message:
    
        08-07 10:01:51.674 16590 16590 D monodroid-assembly: Falling back to System.Reflection.Emit for delegate type '_JniMarshal_PPII_L': IntPtr n_GetClipPath_II(IntPtr, IntPtr, Int32, Int32)
    
    This may also coincide with `AndroidEnableMarshalMethods` being turned
    off by default. We would not have seen this log message when it was on.
    
    After this change, we skip the S.R.E code path:
    
        08-07 10:37:23.089 17661 17661 D Mono    : AOT NOT FOUND: (wrapper native-to-managed) Android.Runtime.JNINativeWrapper:Wrap_JniMarshal_PPII_L (intptr,intptr,int,int).
    
    We should update the `.aotprofile` in xamarin-android and dotnet/maui
    after this change.
    
    To update `JNINativeWrapper.g.tt`:
    
        dotnet tool install -g dotnet-t4
        t4 src\Mono.Android\Android.Runtime\JNINativeWrapper.g.tt -o src\Mono.Android\Android.Runtime\JNINativeWrapper.g.cs
    
    Other changes:
    
    * Fixed code formatting, so we don't have empty tabs in output.
    jonathanpeppers committed Aug 7, 2023
    Configuration menu
    Copy the full SHA
    623054e View commit details
    Browse the repository at this point in the history