FirstGearGames / FishNet

FishNet: Unity Networking Evolved.
Other
1.35k stars 144 forks source link

IL2CPP build failure if RPC has nullable in arguments #149

Closed lordubbe closed 1 year ago

lordubbe commented 1 year ago

Pulled out quite a bit of hair today not knowing why builds suddenly failed. Only after discovering this issue (most likely related) and then digging through new code I found out that the culprit was a nullable int in the signature of a ServerRpc.

Not sure if FN is supposed to support nullables, but if not then a compiler error would be nice!

Error: IL2CPP error for method 'System.Void FishNet.Runtime.GeneratedWriters___FN::Write___System.Nullable1(FishNet.Serializing.Writer,System.Nullable1<System.Int32>)' in assembly 'C:\Users\lordubbe\GOLFIE\Golf Roguelite\Library\Bee\artifacts\WinPlayerBuildProgram\ManagedStripped\Assembly-CSharp.dll' System.ArgumentException: An item with the same key has already been added. Key: GeneratedWriters___FN_Write___System_Nullable_1U3CSystem_Int32U3E_mB19D33940FF34FEB4F53A3949FC61EB644F8CC45_MetadataUsageId at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at Unity.IL2CPP.CodeWriters.InMemoryGeneratedMethodCodeWriter.AddMetadataUsage(String identifier, MethodMetadataUsage usage) at Unity.IL2CPP.CodeWriters.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter writer, String methodSignature, Action2 writeMethodBody, String uniqueIdentifier, MethodReference methodRef, Boolean writingMethodBody) at Unity.IL2CPP.MethodWriter.WriteMethodDefinition(AssemblyWriteContext context, IGeneratedMethodCodeWriter writer, MethodReference method) at Unity.IL2CPP.SourceWriter.WriteType(SourceWritingContext context, IGeneratedMethodCodeWriter writer, TypeReference type, NPath filePath, Boolean writeMarshalingDefinitions) at Unity.IL2CPP.SourceWriters.SourceWriterBase2.WriteItem(StreamWorkItemData2 data) at Unity.IL2CPP.Contexts.Scheduling.Streams.FileLevelParallelStreamManager3.WorkerWriteItemsToFile(WorkItemData2 data) at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler1.WorkerLoop(Object data) Error: IL2CPP error (no further information about what managed code was being converted is available) System.InvalidOperationException: Failed to compare two elements in the array. ---> System.ArgumentException: Unhandled compare for System.Void FishNet.Runtime.GeneratedWritersFN::WriteSystem.Nullable1<System.Int32>(FishNet.Serializing.Writer,System.Nullable1) and System.Void FishNet.Runtime.GeneratedWritersFN::WriteSystem.Nullable1<System.Int32>(FishNet.Serializing.Writer,System.Nullable1)

Assembly Qualified Names were System.Void, mscorlib FishNet.Runtime.GeneratedWritersFN, Assembly-CSharp::WriteSystem.Nullable1<System.Int32>(FishNet.Serializing.Writer, FishNet.Runtime,System.Nullable1, mscorlib[[System.Int32, mscorlib]]) and System.Void, mscorlib FishNet.Runtime.GeneratedWritersFN, Assembly-CSharp::WriteSystem.Nullable1<System.Int32>(FishNet.Serializing.Writer, FishNet.Runtime,System.Nullable1, mscorlib[[System.Int32, mscorlib]])

at Unity.IL2CPP.DataModel.Awesome.Ordering.OrderingCompareExtensions.ThrowFailureException(String xToString, String yToString, String xAssemblyQualifiedName, String yAssemblyQualifiedName) at Unity.IL2CPP.DataModel.Awesome.Ordering.OrderingCompareExtensions.Compare(MethodDefinition x, MethodDefinition y) at Unity.IL2CPP.DataModel.Awesome.Ordering.OrderingCompareExtensions.Compare(MethodReference x, MethodReference y) at System.Collections.Generic.ArraySortHelper1.InsertionSort(Span1 keys, Comparison1 comparer) at System.Collections.Generic.ArraySortHelper1.IntroSort(Span1 keys, Int32 depthLimit, Comparison1 comparer) at System.Collections.Generic.ArraySortHelper1.IntroSort(Span1 keys, Int32 depthLimit, Comparison1 comparer) at System.Collections.Generic.ArraySortHelper1.IntroSort(Span1 keys, Int32 depthLimit, Comparison1 comparer) at System.Collections.Generic.ArraySortHelper1.IntroSort(Span1 keys, Int32 depthLimit, Comparison1 comparer) at System.Collections.Generic.ArraySortHelper1.IntroSort(Span1 keys, Int32 depthLimit, Comparison1 comparer) at System.Collections.Generic.ArraySortHelper1.IntroSort(Span1 keys, Int32 depthLimit, Comparison1 comparer) at System.Collections.Generic.ArraySortHelper1.IntroSort(Span1 keys, Int32 depthLimit, Comparison1 comparer) at System.Collections.Generic.ArraySortHelper1.IntroSort(Span1 keys, Int32 depthLimit, Comparison1 comparer) at System.Collections.Generic.ArraySortHelper1.IntrospectiveSort(Span1 keys, Comparison1 comparer) at System.Collections.Generic.ArraySortHelper1.Sort(Span1 keys, IComparer1 comparer) --- End of inner exception stack trace --- at System.Collections.Generic.ArraySortHelper1.Sort(Span1 keys, IComparer1 comparer) at System.Array.Sort[T](T[] array, Int32 index, Int32 length, IComparer1 comparer) at System.Collections.Generic.List1.Sort(Int32 index, Int32 count, IComparer1 comparer) at Unity.IL2CPP.Contexts.Components.MethodCollectorComponent.SortItems(List1 items) at Unity.IL2CPP.Contexts.Components.Base.ItemsWithMetadataIndexCollectorPhaseSortSupport4.PhaseSortItems() at Unity.IL2CPP.AssemblyConversion.Steps.Base.ContextFreeScheduledStep1.WorkerWrapper(Object unusedContext) at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler1.WorkerLoop(Object data) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

FirstGearGames commented 1 year ago

Likely a bug because nullables are supported.

FirstGearGames commented 1 year ago

related: https://github.com/FirstGearGames/FishNet/issues/135

FirstGearGames commented 1 year ago

I actually need more information such as the RPC, the data you're sending, the editor version, FN version.

FirstGearGames commented 1 year ago

Disregard. Resolved in 2.6.0