IL2CPP GenericSharingVisitor.Process - NotImplementedException

I’m using LTS 2021.3.15f1. Also happens on 3.14f1. I’m getting NotImplementedException - The method or operation is not implemented from IL2CPP GenericSharingVisitor. The call site for the exception changes each time I attempt a build. The exception is thrown from both user code and Unity package code.

Unity Bug Portal IN-25812

I’m unable to create builds of my game. Is there a known workaround?

Error: IL2CPP error for type 'UnityEngine.XR.InputDeviceCharacteristics' in assembly
'C:\Source\Library\Bee\artifacts\WinPlayerBuildProgram\ManagedStripped\UnityEngine.XRModule.dll'
System.NotImplementedException: The method or operation is not implemented.
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.Process(Instruction instruction, MethodDefinition method, Boolean fullGenericSharing)```

Do you happen to have the full call stack from IL2CPP available?

Build Attempt #1

C:\Program Files\Unity\Hub\Editor\2021.3.15f1\Editor\Data\il2cpp\build\deploy\il2cpp.exe @Library\Bee\artifacts\rsp\4115519617908147460.rsp
Error: IL2CPP error for method 'System.String CI.HttpClient.Helpers.AuthHelper::CreateOAuth2Header(System.String)' in C:/Source/XXX/XXX/Assets/Plugins/HttpClient/Helpers/AuthHelper.cs:24
System.NotImplementedException: The method or operation is not implemented.
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.Process(Instruction instruction, MethodDefinition method, Boolean fullGenericSharing)
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.ProcessType(TypeDefinition type)
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.Collect(AssemblyDefinition assembly)
at Unity.IL2CPP.AssemblyConversion.PrimaryCollection.Steps.Global.GenericSharingAnalysis.ProcessItem(GlobalPrimaryCollectionContext context, AssemblyDefinition item)
at Unity.IL2CPP.AssemblyConversion.Steps.Base.ScheduledItemsStepFuncWithContinueFunc`4.WorkerWrapper(WorkItemData`3 workerData)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.ContinueWithResultsWorkItem`4.InvokeWorker(Object context, Int32 uniqueId)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.BaseContinueWorkItem`2.Invoke(Object context, Int32 uniqueId)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
AuthHelper.cs Line 24
public static string CreateOAuth2Header(string token)
{
return "Bearer " + token; // line 24
}

Build Attempt #2

C:\Program Files\Unity\Hub\Editor\2021.3.15f1\Editor\Data\il2cpp\build\deploy\il2cpp.exe @Library\Bee\artifacts\rsp\4115519617908147460.rsp
Error: IL2CPP error for method 'Steamworks.Data.SNetSocket_t Steamworks.ISteamNetworking::CreateP2PConnectionSocket(Steamworks.SteamId,System.Int32,System.Int32,System.Boolean)' in assembly 'C:\Source\XXX\XXX\Library\Bee\artifacts\WinPlayerBuildProgram\ManagedStripped\Facepunch.Steamworks.Win64.dll'
System.NotImplementedException: The method or operation is not implemented.
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.Process(Instruction instruction, MethodDefinition method, Boolean fullGenericSharing)
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.ProcessType(TypeDefinition type)
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.Collect(AssemblyDefinition assembly)
at Unity.IL2CPP.AssemblyConversion.PrimaryCollection.Steps.Global.GenericSharingAnalysis.ProcessItem(GlobalPrimaryCollectionContext context, AssemblyDefinition item)
at Unity.IL2CPP.AssemblyConversion.Steps.Base.ScheduledItemsStepFuncWithContinueFunc`4.WorkerWrapper(WorkItemData`3 workerData)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.ContinueWithResultsWorkItem`4.InvokeWorker(Object context, Int32 uniqueId)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.BaseContinueWorkItem`2.Invoke(Object context, Int32 uniqueId)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Build Attempt #3

C:\Program Files\Unity\Hub\Editor\2021.3.15f1\Editor\Data\il2cpp\build\deploy\il2cpp.exe @Library\Bee\artifacts\rsp\4115519617908147460.rsp
Error: IL2CPP error for method 'System.Void Newtonsoft.Json.Utilities.DynamicProxy`1::.ctor()' in /root/repo/Src/Newtonsoft.Json/Utilities/DynamicProxy.cs:36
System.NotImplementedException: The method or operation is not implemented.
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.Process(Instruction instruction, MethodDefinition method, Boolean fullGenericSharing)
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.ProcessType(TypeDefinition type)
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.Collect(AssemblyDefinition assembly)
at Unity.IL2CPP.AssemblyConversion.PrimaryCollection.Steps.Global.GenericSharingAnalysis.ProcessItem(GlobalPrimaryCollectionContext context, AssemblyDefinition item)
at Unity.IL2CPP.AssemblyConversion.Steps.Base.ScheduledItemsStepFuncWithContinueFunc`4.WorkerWrapper(WorkItemData`3 workerData)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.ContinueWithResultsWorkItem`4.InvokeWorker(Object context, Int32 uniqueId)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.BaseContinueWorkItem`2.Invoke(Object context, Int32 uniqueId)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Thanks for the details. I’m going to guess that the error message is pointing to the wrong line of code, unfortunately.

I’ll ask our QA team to prioritize this bug report - we’ll need to investigate this to understand the problem.

1 Like

Build Attempt #4. Failure location originates from Unity package code.

C:\Program Files\Unity\Hub\Editor\2021.3.15f1\Editor\Data\il2cpp\build\deploy\il2cpp.exe @Library\Bee\artifacts\rsp\4115519617908147460.rsp
Error: IL2CPP error for type 'UnityEngine.XR.InputDeviceCharacteristics' in assembly 'C:\Source\XXX\XXX\Library\Bee\artifacts\WinPlayerBuildProgram\ManagedStripped\UnityEngine.XRModule.dll'
System.NotImplementedException: The method or operation is not implemented.
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.Process(Instruction instruction, MethodDefinition method, Boolean fullGenericSharing)
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.ProcessType(TypeDefinition type)
at Unity.IL2CPP.GenericSharing.GenericSharingVisitor.Collect(AssemblyDefinition assembly)
at Unity.IL2CPP.AssemblyConversion.PrimaryCollection.Steps.Global.GenericSharingAnalysis.ProcessItem(GlobalPrimaryCollectionContext context, AssemblyDefinition item)
at Unity.IL2CPP.AssemblyConversion.Steps.Base.ScheduledItemsStepFuncWithContinueFunc`4.WorkerWrapper(WorkItemData`3 workerData)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.ContinueWithResultsWorkItem`4.InvokeWorker(Object context, Int32 uniqueId)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.BaseContinueWorkItem`2.Invoke(Object context, Int32 uniqueId)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Thank you!

FWIW, I am also seeing this in 2022.2.1f1.

Since the issue manifests across two versions of Unity separated by a year, I’m inclined to think there is an environmental cause. I installed older versions of the Windows SDK, as well as VC++ libraries thinking it is a version compat issue. Unfortunately, this didn’t remedy the issue. I am really needing to get a build out. Is there anything I can try?

RE: related. Feature preview: IL2CPP Full Generic Sharing in Unity 2022.1 beta | Unity Blog

Tried:

Preferences → Diagnostics → Editor → VMIl2CppAditionalArgs –disable-generic-sharing
and
Project Settings-> IL2CPP Code Generation → Faster (smaller) Builds

I wonder what other settings besides --disable-generic-sharing that might be worth trying…

Thanks! I don’t see much action on this from our QA team - I’ll follow up again. Does this only happen when the “Faster (smaller) Builds” option is used?

Thank you for following up. I tried with both build options (smaller vs faster) and I see the same behavior. I’m open to trying anything — I’m out of ideas.

Thanks for the details - I’ll try to get this moving and get back to you via the bug report with a work around at the very least.

@JoshPeterson I’m working to get a reduced size project sent over. I’m starting at over 100GB, and it is taking some time. In the interim, I asked the Customer QA team if they could review source for GenericSharingVisitor.Process and advise what scenarios cause a NotImplementedException to be thrown.

Thanks! I don’t think our QA team will be able to do that, but I did have a look at the code myself. It looks like the not implemented case is a catch-all at the bottom of a switch statement used for handling many different IL opcodes.

So if you don’t have success putting together a smaller project, let me know, and I can send you a custom assembly with better logging so that at least we can get a sense for what is happening.

Thanks Josh! I updated the ticket with a download link to a project (1.3GB) which reproduces the issue in my environment.

Excellent, thank you!

I appreciate all of your help. Do you know if a work-around might exist? I’m very much hoping to produce a build. The 2021 and 2022 Unity versions seem to have the same behavior.