Azure / azure-remote-rendering

SDK and samples for Azure Remote Rendering
MIT License
107 stars 39 forks source link

Failing to compile Showcase app #93

Closed Merichbier closed 1 year ago

Merichbier commented 1 year ago

Describe the problem

We can't build the Showcase app with Sharing feature. A Photo exception is triggered :

Exception: IL2CPP error for method 'System.Void POpusCodec.OpusDecoderAsync`1::DataCallbackStatic(System.IntPtr,System.IntPtr,System.Int32,System.Boolean)' in C:\Users\abirchme\Documents\Unity\azure-remote-rendering\Unity\Showcase\App\Assets\Photon\PhotonVoice\PhotonVoiceApi\Core\POpusCodec\OpusDecoder.cs:155
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

Any suggestion about what might be the issue would be helpfull.

Provide additional information

All credentials are setup through the arr.account.xml located in the Assets/StreamingAssets. This is the only change made to the project (except the import of the package through the Script)

Additional context

Unity 2020.3.42f Photo Voice 2 2.51 PUN 2 - Free 2.41

mariambecet commented 1 year ago

Hi @Merichbier. I am able to reproduce your issue. It seems to be related to the latest Photon version (2.51). The Showcase app was tested and works fine with the previous version (2.50) However since it's not possible to download older assets in Unity I'm looking now into finding a solution. Just a couple of questions to help diagnose the problem better:

  1. Which visual studio version are you using?
  2. Are you using the latest ARR release (1.3.34)?
Merichbier commented 1 year ago

Hi @mariambecet, Thanks for the response ! I indeed tried this morning to downgrade everything to be aligned with your state (Unity 2020.3.13f and Photon Voice 2 2.50) but hit the issue that I couldn't find Photon Voice 2 2.50... So sad I'm sure It would have worked !

Regarding your questions :

  1. Currently using VS 17.4.4. But I couldn't build the project from Unity. The issue arises there. Here is the complete error with stacktrace in the hope that this help :
    Exception: IL2CPP error for method 'System.Void POpusCodec.OpusDecoderAsync`1::DataCallbackStatic(System.IntPtr,System.IntPtr,System.Int32,System.Boolean)' in C:\Users\abirchme\Documents\Unity\azure-remote-rendering\Unity\Showcase\App\Assets\Photon\PhotonVoice\PhotonVoiceApi\Core\POpusCodec\OpusDecoder.cs:154
    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 <2cd7f07c7b884ea9bf02386eb91a464c>:0)
    UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1[T] setupStartInfo) (at <2cd7f07c7b884ea9bf02386eb91a464c>:0)
    UnityEditorInternal.IL2CPPBuilder.RunIl2CppWithArguments (System.Collections.Generic.List`1[T] arguments, System.Action`1[T] setupStartInfo) (at <2cd7f07c7b884ea9bf02386eb91a464c>:0)
    UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (UnityEditor.Il2Cpp.Il2CppBuildPipelineData data) (at <2cd7f07c7b884ea9bf02386eb91a464c>:0)
    UnityEditorInternal.IL2CPPBuilder.Run () (at <2cd7f07c7b884ea9bf02386eb91a464c>:0)
    UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action`1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at <2cd7f07c7b884ea9bf02386eb91a464c>:0)
    PostProcessWinRT.RunIL2CPPForProjectBuild () (at C:/build/output/unity/unity/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessWinRT.cs:1910)
    PostProcessWinRT.RunIL2CPP () (at C:/build/output/unity/unity/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessWinRT.cs:1879)
    PostProcessWinRT.Process () (at C:/build/output/unity/unity/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessWinRT.cs:211)
    UnityEditor.UWP.BuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at C:/build/output/unity/unity/PlatformDependent/MetroPlayer/Extensions/Managed/ExtensionModule.cs:86)
    Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
    UnityEditor.UWP.BuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at C:/build/output/unity/unity/PlatformDependent/MetroPlayer/Extensions/Managed/ExtensionModule.cs:90)
    UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <2cd7f07c7b884ea9bf02386eb91a464c>: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 <2cd7f07c7b884ea9bf02386eb91a464c>:0)
    UnityEditor.DefaultBuildMethods:BuildPlayer(BuildPlayerOptions)
    BuildGuard:OnBuildClicked(BuildPlayerOptions) (at Assets/App/Utilities/Editor/BuildGuard.cs:41)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
  2. Yes using the latest ARR release (freshly downloaded the repo at the beginning of the week) 1.3.34
mariambecet commented 1 year ago

Hi @Merichbier, Sorry for the delay. There is unfortunately nothing we can do on the ARR side to fix it for Unity 2020.3. I have tried several workarounds, and the one I suggest is to just comment out the functions that are causing the compilation errors in Photon. From what I can tell, these functions are only needed for Webgl platform and commenting them out didn't affect the app on the Hololens or Editor when I tested it. The lines to comment out are: In \Showcase\App\Assets\Photon\PhotonVoice\PhotonVoiceApi\Core\POpusCodec\OpusDecoder.cs comment out the MonoPInvokeAttribute in line 152 & the function implementation (155 to 158)

//[AOT.MonoPInvokeCallbackAttribute(typeof(Action<IntPtr, IntPtr, int, bool>))]
static public void DataCallbackStatic(IntPtr handle, IntPtr p, int count, bool endOfStream)
{
    //if (handles.TryGetValue(handle, out var obj))
    //{
    //    obj.dataCallback(p, count, endOfStream);
    //}
}

In \Showcase\App\Assets\Photon\PhotonVoice\PhotonVoiceApi\Core\POpusCodec\OpusEncoder.cs comment out the MonoPInvokeAttribute in line 255 & the function implementation (line 258 to 261)

//[AOT.MonoPInvokeCallbackAttribute(typeof(Action<IntPtr, IntPtr, int>))]
static public void DataCallbackStatic(IntPtr handle, IntPtr p, int count)
{
    //if (handles.TryGetValue(handle, out var obj))
    //{
    //    obj.dataCallback(p, count);
    //}
}

Hopefully this compilation issue will be mitigated in future Photon updates, we will also try to reach out to Photon and report it.

Merichbier commented 1 year ago

Hi @mariambecet, First thanks a lot for the time you took into investigating this ! I was able to build and deploy the app with your solution. I still need to test that the sharing feature works (will be this week) but I'm confident that everything will be alright :) I guess we can close this issue as, like you said, this is an issue on Photon side.

Thanks again