Search Unity

Resolved IL2CPP fail to pass WACK

Discussion in 'Windows' started by Wadjey, Sep 8, 2020.

  1. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    Hello,
    My UWP build fail to pass WACK with this error:
    FAILED Supported APIs:
    Error Found: The supported APIs test detected the following errors:

    • API _XcptFilter in msvcrt.dll is not supported for this application type. clrcompression.dll calls this API.
    • API __C_specific_handler in msvcrt.dll is not supported for this application type. clrcompression.dll calls this API.
    • API _amsg_exit in msvcrt.dll is not supported for this application type. clrcompression.dll calls this API.
    • API _initterm in msvcrt.dll is not supported for this application type. clrcompression.dll calls this API.
    • API free in msvcrt.dll is not supported for this application type. clrcompression.dll calls this API.
    • API malloc in msvcrt.dll is not supported for this application type. clrcompression.dll calls this API.
    • API memcpy in msvcrt.dll is not supported for this application type. clrcompression.dll calls this API.
    • API memset in msvcrt.dll is not supported for this application type. clrcompression.dll calls this API.
    • API ExecuteAssembly in uwphost.dll is not supported for this application type. UWPShim.exe calls this API.
    • API DllGetActivationFactory in uwphost.dll is not supported for this application type. UWPShim.exe has an export that forwards to this API.
    I'm using Unity 2019.4.9f1 and VS2019 (16.7.2) and Windows 10 v2004 (19041.450).
    Any idea what may cause this and how to fix it?

    Note: I tested with a newly created project and got the same issue
     
    Last edited: Sep 8, 2020
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Did you modify the generated project at all? The errors suggest final Visual Studio project have .NET components (and that they haven't been compiled with .NET Native). However, in 2019.4 you can only use IL2CPP so Unity generates C++ project and any .NET components that were in your Unity project were supposed to already have been converted to pure C++.
     
  3. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    I added reference to AdDuplex.
    upload_2020-9-8_11-46-55.png

    Any workaround to avoid failing the WACK?
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
  5. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    After applying these instructions I got this error:
    Error MSB3816 Loading assembly "C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\runtime.win10-x64-aot.microsoft.netcore.universalwindowsplatform\6.2.10\runtimes\win10-x64-aot\lib\uap10.0.15138\System.Diagnostics.DiagnosticSource.dll" failed. System.IO.FileNotFoundException: Could not load file or assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
    File name: 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
    at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
    at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
    at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
    at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
    at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
    at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
    at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
    at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
    at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](Assembly element)
    at Microsoft.Build.Tasks.ProcessResourceFiles.ReadAssemblyResources(String name, String outFileOrDir)
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    I'm not exactly sure what's wrong with it. Does the example project I linked work? Did you try comparing .vcxproj files and see where any differences lie?
     
  7. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    I changed

    <UseDotNetNativeToolchain Condition="'$(Configuration)'=='MasterWithLTCG'">true</UseDotNetNativeToolchain>
    to
    <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>

    And now the build succeed but only when ARM64 is unselected in the app bundle (Publish -> Create App Packages...), when I select ARM64 I'm getting this error:
    Error MSB3816 Loading assembly "C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\runtime.win10-arm64-aot.microsoft.netcore.universalwindowsplatform\6.2.10\runtimes\win10-arm64-aot\lib\uap10.0.15138\System.Diagnostics.DiagnosticSource.dll" failed. System.IO.FileNotFoundException: Could not load file or assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
    File name: 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
    at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
    at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
    at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
    at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
    at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
    at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
    at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
    at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
    at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](Assembly element)
    at Microsoft.Build.Tasks.ProcessResourceFiles.ReadAssemblyResources(String name, String outFileOrDir)
    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
    UWP_ARM64 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets 1361

    Also before applying this workaround I was getting this error when I try to build for ARM64:
    Your project.json doesn't list 'win10-arm64' as a "RuntimeIdentifier". You should add '"win10-arm64": { }' inside your "runtimes" section in your project.json and then re-run NuGet restore.

    Is it because AdDuplex plugin don't support ARM64? If yes, is there any possible workaround to be able to build for ARM64?
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
  9. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    I added a package.json file to the project with these parameters:
    Code (CSharp):
    1. {
    2.   "frameworks": {
    3.     "uap10.0": {}
    4.   },
    5.   "runtimes": {
    6.     "win10-arm": {},
    7.     "win10-arm64": {},
    8.     "win10-arm-aot": {},
    9.     "win10-arm64-aot": {},
    10.     "win10-x86": {},
    11.     "win10-x86-aot": {},
    12.     "win10-x64": {},
    13.     "win10-x64-aot": {}
    14.   }
    15. }
    And added this line to the vcxproj ->
    PropertyGroup:
    <RuntimeIdentifiers>win10-arm;win10-arm64;win10-arm-aot;win10-arm64-aot;win10-x86;win10-x86-aot;win10-x64;win10-x64-aot</RuntimeIdentifiers>

    And get this build error:
    One of your dependencies requires the .NET Framework, but the .NET Framework could not be found in the NuGet packages installed in this project. Please install the appropriate .NET Framework packages required by your dependency.

    This is weird, spent lot of time and I'm still unable to complete the migration from .NET to IL2CPP...
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    I would first try getting this to work in a barebones project without Unity. Might be easier to iterate/try things out. Once you have an empty C++ project with AdDuplex working, transferring that to the project generated by Unity should be fairly simple.

    Unfortunately I don't know how to properly set it up so you'll have to figure out it yourself. I think that github project is a good starting point. It wasn't clear to me whether it was working for you as is or not.

    Another option if you don't want to deal with the package-foo could be downloading AdDuplex NuGet package and try getting it working by putting it directly into your Unity project, rather than referencing it from generated VS project. That should theoretically work if you make sure all of its files end up in the built package.
     
    Wadjey likes this.
  11. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    Finally found what's causing this error, it was simply a lack of free disc space! the generated IL2CPP solution requires about a 50GB of free disk space to be able to build the UWP app bundle, while the .NET generated solution requires only about 4-5GB! A huge difference!!!
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    50 GB? That's insane! Do you know what files take that much space?