Photon Voice error with IL2CPP build

Exception: IL2CPP error for method 'System.Void POpusCodec.OpusDecoderAsync`1::DataCallbackStatic(System.IntPtr,System.IntPtr,System.Int32,System.Boolean)' in C:\Unity\Projects\Aviation2\Assets\Photon\PhotonVoice\PhotonVoiceApi\Core\POpusCodec\OpusDecoder.cs:155

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

  at Mono.Collections.Generic.Collection`1.get_Item(Int32 index)

  at Unity.Cecil.Awesome.TypeResolver.Resolve(TypeReference typeReference, Boolean resolveGenericParameters)

  at Unity.Cecil.Awesome.TypeResolver.Resolve(TypeReference typeReference, Boolean resolveGenericParameters)

  at Unity.IL2CPP.Marshaling.BodyWriters.NativeToManaged.ReversePInvokeMethodBodyWriter.GetInteropMethod(MethodReference method)

  at Unity.IL2CPP.Marshaling.BodyWriters.NativeToManaged.ReversePInvokeMethodBodyWriter.Create(MinimalContext context, MethodReference managedMethod)

  at Unity.IL2CPP.MethodWriter.WriteReversePInvokeMethodDefinition(IGeneratedMethodCodeWriter writer, MethodReference method)

  at Unity.IL2CPP.SourceWriter.WriteMarshalingDefinitions(SourceWritingContext context, IGeneratedMethodCodeWriter writer, TypeReference type)

  at Unity.IL2CPP.SourceWriters.SourceWriterBase`1.WriteItem(StreamWorkItemData`2 data)

  at Unity.IL2CPP.Contexts.Scheduling.Streams.FileLevelParallelStreamManager`2.WorkerWriteItemsToFile(WorkItemData`2 data)

  at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)

UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at <abcf38996a474f319c10e3e20ff8cc9f>:0)

UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1[T] setupStartInfo) (at <abcf38996a474f319c10e3e20ff8cc9f>:0)

UnityEditorInternal.IL2CPPBuilder.RunIl2CppWithArguments (System.Collections.Generic.List`1[T] arguments, System.Action`1[T] setupStartInfo) (at <abcf38996a474f319c10e3e20ff8cc9f>:0)

UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (UnityEditor.Il2Cpp.Il2CppBuildPipelineData data) (at <abcf38996a474f319c10e3e20ff8cc9f>:0)

UnityEditorInternal.IL2CPPBuilder.Run () (at <abcf38996a474f319c10e3e20ff8cc9f>:0)

UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action`1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at <abcf38996a474f319c10e3e20ff8cc9f>:0)

UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <04b7ada17ece4f3da2133228ef06844e>:0)

UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <04b7ada17ece4f3da2133228ef06844e>:0)

UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <04b7ada17ece4f3da2133228ef06844e>:0)

UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <04b7ada17ece4f3da2133228ef06844e>:0)

UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <abcf38996a474f319c10e3e20ff8cc9f>:0)

UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Answers

  • Unfortunately, there is a bug in the latest Voice. Please use Unity 2021.3 and newer or (as a quick fix) comment out the OpusDecoderAsync class and its usage.

  • @chuckyw That's how I resolved it, by upgrading Unity Engine. Anyway thank you for clearing the doubt