Libraries that fail to compile on 2021.2

Hi

I've seen lot of libraries failing to compile with this beta, but the last one is the popular Rewired package from the asset store. If you try to build for windows, you'll get this error:

C:\Program Files\Unity\Hub\Editor\2021.2.0b4\Editor\Data\il2cpp\build\deploy\net5.0\il2cpp.exe @Library\Bee\artifacts\rsp\934381626019808312.rsp
Error: IL2CPP error for method 'System.Void BuQfNOXjKvFpXbLqwLzdtdPJnBF::JZtcOIgQadIewBwbFvSqZhfkgjZB(RlkJYFLOmcVFEMpdCcsniXwfaBp)' in assembly 'D:\Dropbox\DogfightUnity5\Library\Bee\artifacts\WinPlayerBuildProgram\ManagedStripped\Rewired_Windows.dll'
System.InvalidOperationException: Attempting to constrain a value of type 'System.Void' to type 'System.Guid'.
at Unity.IL2CPP.MethodBodyWriter.WriteConstrainedCallExpressionFor(ResolvedInstruction ins, ResolvedMethodInfo origMethodToCall, List1 poppedValues, String& copyBackBoxedExpr)
at Unity.IL2CPP.MethodBodyWriter.ProcessInstruction(Node node, InstructionBlock block, ResolvedInstruction ins)
at Unity.IL2CPP.MethodBodyWriter.GenerateCodeRecursive(Node node, ReadOnlyDictionary
2 instructionBlocks)
at Unity.IL2CPP.MethodBodyWriter.Generate()
at Unity.IL2CPP.CodeWriters.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter writer, String methodSignature, String methodFullName, Action2 writeMethodBody, String uniqueIdentifier, MethodReference methodRef)
at Unity.IL2CPP.MethodWriter.WriteMethodDefinition(AssemblyWriteContext context, IGeneratedMethodCodeWriter writer, MethodReference method, Boolean addToMethodCollection)
at Unity.IL2CPP.SourceWriter.WriteType(SourceWritingContext context, IGeneratedMethodCodeWriter writer, TypeReference type, NPath filePath, Boolean writeMarshalingDefinitions, Boolean addToMethodCollection)
at Unity.IL2CPP.SourceWriters.GenericInstanceTypeSourceWriter.WriteItem(SourceWritingContext context, IGeneratedMethodCodeWriter writer, GenericInstanceType item, NPath filePath)
at Unity.IL2CPP.SourceWriters.SourceWriterBase
2.WriteItem(StreamWorkItemData2 data)
at Unity.IL2CPP.Contexts.Scheduling.Streams.FileLevelParallelStreamManager
3.WorkerWriteItemsToFile(WorkItemData2 data)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler
1.WorkerLoop(Object data)
Error: IL2CPP error for method 'System.Void BuQfNOXjKvFpXbLqwLzdtdPJnBF::JZtcOIgQadIewBwbFvSqZhfkgjZB(RlkJYFLOmcVFEMpdCcsniXwfaBp)' in assembly 'D:\Dropbox\DogfightUnity5\Library\Bee\artifacts\WinPlayerBuildProgram\ManagedStripped\Rewired_Windows.dll'
System.InvalidOperationException: Attempting to constrain a value of type 'System.Void' to type 'System.Guid'.
at Unity.IL2CPP.MethodBodyWriter.WriteConstrainedCallExpressionFor(ResolvedInstruction ins, ResolvedMethodInfo origMethodToCall, List1 poppedValues, String& copyBackBoxedExpr)
at Unity.IL2CPP.MethodBodyWriter.ProcessInstruction(Node node, InstructionBlock block, ResolvedInstruction ins)
at Unity.IL2CPP.MethodBodyWriter.GenerateCodeRecursive(Node node, ReadOnlyDictionary
2 instructionBlocks)
at Unity.IL2CPP.MethodBodyWriter.Generate()
at Unity.IL2CPP.CodeWriters.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter writer, String methodSignature, String methodFullName, Action2 writeMethodBody, String uniqueIdentifier, MethodReference methodRef)
at Unity.IL2CPP.MethodWriter.WriteMethodDefinition(AssemblyWriteContext context, IGeneratedMethodCodeWriter writer, MethodReference method, Boolean addToMethodCollection)
at Unity.IL2CPP.SourceWriter.WriteType(SourceWritingContext context, IGeneratedMethodCodeWriter writer, TypeReference type, NPath filePath, Boolean writeMarshalingDefinitions, Boolean addToMethodCollection)
at Unity.IL2CPP.SourceWriters.GenericInstanceTypeSourceWriter.WriteItem(SourceWritingContext context, IGeneratedMethodCodeWriter writer, GenericInstanceType item, NPath filePath)
at Unity.IL2CPP.SourceWriters.SourceWriterBase
2.WriteItem(StreamWorkItemData2 data)
at Unity.IL2CPP.Contexts.Scheduling.Streams.FileLevelParallelStreamManager
3.WorkerWriteItemsToFile(WorkItemData2 data)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler
1.WorkerLoop(Object data)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

and no idea how to fix it. anyone?

Can you submit a bug report for this issue? Thanks!

Case 1352676

2 Likes

If you have Visual Studio 2019 installed, make sure you have disabled the new jump optimizer or any manner of inexplicable build or runtime errors will occur with IL2CPP. (Not specific to any version of Unity).

https://guavaman.com/projects/rewired/docs/KnownIssues.html#windows-standalone-il2cpp-vs2019-hang

1 Like

FWIW I think this issue happens before C++ compilation of the generated IL2CPP code. It looks like the exception comes during the code conversion step, so it looks like this entirely on the Unity side.

Thanks for the bug report, we appreciate it!

Nope, didn´t fix it. Also, it compiled just fine on 2021.1. It fails beginning in 2021.2

Okay. Thanks.

Unfortunately, I have the same issue, is there already a workaround for this issue?

Looks like this is going to be fixed in b7: https://issuetracker.unity3d.com/product/unity/issues/guid/1352676/

Nope. I've just updated to unity b7 and it's not fixed. Error
Unable to update following assemblies:Assets/Rewired/Internal/Libraries/Runtime/Rewired_Core.dll (Name = Rewired_Core, Error = 131) (Output: C:\Users\joaqu\AppData\Local\Temp\tmp777cc8cf.tmp)
[AssemblyUpdater] Failed to resolve type 'System.Int32'
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: parameterType

1 Like

The same for me also the same error message, it does not work for me in b7.

Yeah I don't understand why they say it's fixed when all they need to do is get my bug report project and try to compile it. I feel like I wasted my time with the submission.

QA did that and was no longer able to reproduce the issue. If the issue is not fixed for you, you can reply to the email conversation related to your bug report. That will re-open the investigation.

I’ve re-opened the case for now.

Hi, I'm experiencing this issue with 2021.2.0f1 while building. It seems the issue should be fixed by now though — any ideas?

Unable to update following assemblies:Assets/Rewired/Internal/Libraries/Runtime/Rewired_Core.dll (Name = Rewired_Core, Error = 131) (Output: /var/folders/p7/3r_24ryx7ns4356q6y8lxhcw0000gn/T/tmp4f1b600f.tmp)

[AssemblyUpdater] Failed to resolve type 'System.Int32'
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null.

Parameter name: parameterType
  at Mono.Cecil.ParameterReference..ctor (System.String name, Mono.Cecil.TypeReference parameterType) [0x00010] in <a6860a9f6366437387ebdc1f225b7fd4>:0
  at Mono.Cecil.ParameterDefinition..ctor (System.String name, Mono.Cecil.ParameterAttributes attributes, Mono.Cecil.TypeReference parameterType) [0x0000b] in <a6860a9f6366437387ebdc1f225b7fd4>:0
  at Mono.Cecil.ParameterDefinition..ctor (Mono.Cecil.TypeReference parameterType) [0x00000] in <a6860a9f6366437387ebdc1f225b7fd4>:0
  at AssemblyUpdater.Steps.MemberReferenceReplacer.ParameterDefinitionFor (Mono.Cecil.MethodReference methodOwner, APIUpdater.Framework.Configuration.TypeReferenceSpec typeSpec, Mono.Cecil.TypeReference resolutionScope, Mono.Cecil.TypeReference originalParamType) [0x00027] in <4d66a2db9b904e6d8a493875017bf944>:0
  at AssemblyUpdater.Steps.MemberReferenceReplacer.AddParametersToReference (Mono.Cecil.MethodReference reference, Mono.Cecil.MethodReference originalMethod, APIUpdater.Framework.Configuration.MemberReferenceReplacementConfig replacement, Mono.Cecil.TypeReference targetType) [0x000f5] in <4d66a2db9b904e6d8a493875017bf944>:0

This looks like it might be a bug - can you submit a bug report?

https://unity3d.com/unity/qa/bug-reporting

If you file a bug, please post the link here so I can look into it asap.

Thanks

@Vagaus @JoshPeterson

I was able to fix the issue by reimporting some packages in my project. If it reoccurs, I will report.

I suspect the issue was related to my attempts (and recently, successes) in getting the Firebase SDK to work inside the native apple silicon editor, despite Google not providing AS-native bundles for the editor. Google doesn't seem to be working on this at all, which is unfortunate. https://github.com/firebase/quickstart-unity/issues/1100#issuecomment-958462301

/cc @aromana

Actually after looking again in the exception it looks it has already been reported (but with a different assembly involved). If you can share your copy of Rewired_Core.dll I can double check.

Basically you will get this error if the assembly has a call to any of these methods:

  • Resize(int width, int height, GraphicsFormat format, bool hasMipMap)
  • Resize(int width, int height, TextureFormat format, bool hasMipMap)
  • Resize(int width, int height)

This has been reported in 2021.2. I’ve fixed it in that version and I am forward porting it to trunk

Best

I’m guessing that is Texture2D.Resize you’re referring to. I checked and it hasn’t been deprecated so I assume there is nothing I should be changing in my code.

1 Like