Search Issue Tracker

By Design

Votes

0

Found in

2018.4

2018.4.11f1

2020.2

Issue ID

1262895

Regression

No

[Mobile] 'Unsupported internal call for IL2CPP' errors are thrown when Managed Code Stripping is enabled

IL2CPP

-

How to reproduce:
1. Open the attached '1262895.zip' project
2. Build for iOS/Android
3. Deploy the project to the device

Expected result: The project is deployed successfully and there are no errors thrown in the console
Actual result: The project is deployed successfully and 'Unsupported internal call for IL2CPP:Assembly::InternalGetAssemblyName - "This icall is not supported by il2cpp." error is thrown in the Console

Reproducible with: 2018.4.26f1, 2020.2.0a19

Reproducible with:
iPhone 8+ (iOS 12.0)
iPhone XR (iOS 13.4.1)
iPad Air 2 (iOS 11.0.3)
iPad 9.7 6th gen (iOS 12.1)
VLNQA00001, Google Pixel 2 (Pixel 2), Android 11, CPU: Snapdragon 835 MSM8998, GPU: Adreno (TM) 540
VLNQA00128, Samsung Galaxy Note8 (SM-N950F), Android 9, CPU: Exynos 9 Octa 8895, GPU: Mali-G71
N/A, Oneplus OnePlus 6 (ONEPLUS A6003), Android 10, CPU: Snapdragon 845 SDM845, GPU: Adreno (TM) 630

Notes:
- Reproducible when Managed Code Stripping is set to Low, Medium, High in Project Settings -> Player
- Reproducible with .NET 4.x, .NET Standard 2.0
- Full error: 'NotSupportedException: ./External/il2cpp/builds/libil2cpp/icalls/mscorlib/System.Reflection/Assembly.cpp(326) : Unsupported internal call for IL2CPP:Assembly::InternalGetAssemblyName - "This icall is not supported by il2cpp."
at System.Reflection.AssemblyName.GetAssemblyName (System.String assemblyFile) [0x00000] in <00000000000000000000000000000000>:0
at DLLAmmemblyName.Start () [0x00000] in <00000000000000000000000000000000>:0
InvalidOperationException: A suitable constructor for type 'BananaTree' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.'

  1. Resolution Note:

    It looks like there are a few different issues reported in this case.

    1. A stripping issue that causes the error "InvalidOperationException: A suitable constructor for type 'BananaTree' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.'"

    This is the intended behavior of managed stripping when set to Medium or High. Because the provided code relies on reflection to find and create the BananaTree class, and managed code stripping has limited support for finding all usages with reflection, that class's constructor gets stripped.

    One solution is the workaround provided in the code, which is to have at least one instance of calling the class's constructor somewhere in the code. Another option is to create a public constructor on the class and mark it with a "Preserve" attribute to ensure it does not get stripped:

    [Preserve]
    public BananaTree()
    {
    }
    The reason why a "link.xml" did not work is because "link.xml" files never apply to the project's "Assembly-CSharp.dll" assembly, which is where all the user project code is compiled to.

    2. When code stripping is set to High, there is an additional error related to stripping a type from the class "Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope". Because this class IS in another assembly, it can be added to the "link.xml" in order to be preserved:

    <assembly fullname="Microsoft.Extensions.DependencyInjection">
    <type fullname="Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope" preserve="all" />
    </assembly>

    3. The "NotSupportedException" caused by an unsupported internal call in IL2CPP ("Unsupported internal call for IL2CPP:Assembly::InternalGetAssemblyName").

    This happens regardless of stripping level, and is a specific limitation of IL2CPP. We don't plan to support this in IL2CPP, as it would require the player build to carry around extra assembly data that would increase code size too much.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.