BananaHemic / Mumble-Unity

Performant Mumble Client For Unity3D
MIT License
77 stars 29 forks source link

il2cpp support #35

Open NumanDogruay opened 4 years ago

NumanDogruay commented 4 years ago

I will try Script Backend il2cpp Not working on Android and Ios. When try on Android: It's not send debug to editor. I connect with breakpoint it's give Culture error on Debug.log side When try Ios: On load give error like Exception: Encoder error - BadArgument at Mumble.OpusEncoder.set_EnableForwardErrorCorrection (Boolean value) [0x00000] in :0 at Mumble.OpusCodec.InitializeEncoderWithSampleRate (Int32 newSampleRate) [0x00000] in :0 at MumbleTester.Start () [0x00000] in :0

I thing can't load static lib Unity on il2cpp. It's working on mono Script Backend but Ios only selected il2cpp.

Any idea?

BananaHemic commented 4 years ago

This plugin doesn't support ios to the best of my recollection. I also haven't tested il2cpp on Android, but I'm surprised that it doesn't work out of the box. Unfortunately, I really can't spend time working on this plugin anymore, but if you have any more errors / tests I can maybe point you in the right direction.

NumanDogruay commented 4 years ago

I build opus with https://trac.pjsip.org/repos/ticket/1904 this description and xcode saw library i thing only problem on il2cpp on unity.. Unity says "When using the IL2CPP scripting backend, you can use C/C++ source files as plug-ins and Unity compiles them along with IL2CPP generated files. This includes all C/C++ source files with extensions .c, .cc, .cpp and .h." on this page https://docs.unity3d.com/Manual/AndroidNativePlugins.html

Do you thing using this is work? Thanks for reply.

BananaHemic commented 4 years ago

I think that using the opus c and .h files could work, but I think it'd be making your life more difficult. I think the easiest solution would be to just use the compiled opus libraries that are already in the repo.

amir2821 commented 2 years ago

Any new update on this issue? I have this issue in unity2019.4.5 il2cpp android build

BananaHemic commented 2 years ago

I haven't looked into this personally, if you try something and hit an error you're welcome to post it here and I can take a look

amir2821 commented 2 years ago

I haven't looked into this personally, if you try something and hit an error you're welcome to post it here and I can take a look

Thank you for response, In unity editor everything is Ok but after build for android with IL2CPP scripting backend, running example scene on device gives this error: DllNotFoundExeption: Unable to load DLL 'opus-1_3': The specified module could not be found

error

BananaHemic commented 2 years ago

Hmm, I'm seeing other people with some similar issues in other repos. I think we need to change the DLLImport. You might want to change this line so that the __Internal name is being used for IL2CPP...Not sure if that will do the trick however

amir2821 commented 2 years ago

Hmm, I'm seeing other people with some similar issues in other repos. I think we need to change the DLLImport. You might want to change this line so that the __Internal name is being used for IL2CPP...Not sure if that will do the trick however

I did this and now I get error in build process(Building Native Binary with IL2CPP) :

Failed running C:\Program Files\Unity 2019.4.5f1\Editor\Data\il2cpp/build/deploy/net471/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --configuration="Release" --outputpath="C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a\libil2cpp.so" --cachedirectory="C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Assets..\Library\il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="C:/Program Files/Unity 2019.4.5f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\bdwgc/include" --additional-include-directories="C:/Program Files/Unity 2019.4.5f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\libil2cpp/include" --tool-chain-path="C:/Program Files/_ndk-r19/android-ndk-r19" --profiler-report --map-file-parser="C:/Program Files/Unity 2019.4.5f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --directory=C:/Users/Amirhosein/@ActiveProjects/Aflatoon/mumble/Mumble-Unity/Temp/StagingArea/assets/bin/Data/Managed --generatedcppdir=C:/Users/Amirhosein/@ActiveProjects/Aflatoon/mumble/Mumble-Unity/Temp/StagingArea/Il2Cpp/il2cppOutput

stdout: Building libil2cpp.so with AndroidToolChain Output directory: C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a Cache directory: C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Library\il2cpp_android_armeabi-v7a\il2cpp_cache ObjectFiles: 166 of which compiled: 0 Total compilation time: 228 milliseconds. il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files_ndk-r19\android-ndk-r19\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ @"C:\Users\Amirhosein\AppData\Local\Temp\tmp7850.tmp" -o "C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Library\il2cpp_android_armeabi-v7a\il2cpp_cache\linkresult_3822D0B563B449C5F5D3A11D75C42936\libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id -stdlib=libc++ -static-libstdc++ -target armv7-linux-androideabi19 -Wl,--wrap,sigaction -llog -rdynamic -fuse-ld=gold.exe

C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32411: error: undefined reference to 'opus_encoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32401: error: undefined reference to 'opus_encoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32411: error: undefined reference to 'opus_encoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32314: error: undefined reference to 'opus_encoder_get_size' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32325: error: undefined reference to 'opus_decoder_get_size' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32336: error: undefined reference to 'opus_encoder_init' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32347: error: undefined reference to 'opus_decoder_init' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32372: error: undefined reference to 'opus_encode_float' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32390: error: undefined reference to 'opus_packet_get_nb_channels' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32401: error: undefined reference to 'opus_encoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32432: error: undefined reference to 'opus_decoder_create' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32443: error: undefined reference to 'opus_decode' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32468: error: undefined reference to 'opus_decode_float' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32479: error: undefined reference to 'opus_decoder_destroy' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32489: error: undefined reference to 'opus_decoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32499: error: undefined reference to 'opus_decoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32509: error: undefined reference to 'opus_decoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32314: error: undefined reference to 'opus_encoder_get_size' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32336: error: undefined reference to 'opus_encoder_init' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32372: error: undefined reference to 'opus_encode_float' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32325: error: undefined reference to 'opus_decoder_get_size' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32347: error: undefined reference to 'opus_decoder_init' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32468: error: undefined reference to 'opus_decode_float' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32509: error: undefined reference to 'opus_decoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32390: error: undefined reference to 'opus_packet_get_nb_channels' clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)

at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet1 objectFiles, CppToolChainContext toolChainContext) at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics) at il2cpp.Program.DoRun(String[] args, List1 foundAssemblies) at il2cpp.Program.Run(String[] args, Boolean setInvariantCulture) at il2cpp.Program.Main(String[] args) stderr:

Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files_ndk-r19\android-ndk-r19\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ @"C:\Users\Amirhosein\AppData\Local\Temp\tmp7850.tmp" -o "C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Library\il2cpp_android_armeabi-v7a\il2cpp_cache\linkresult_3822D0B563B449C5F5D3A11D75C42936\libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id -stdlib=libc++ -static-libstdc++ -target armv7-linux-androideabi19 -Wl,--wrap,sigaction -llog -rdynamic -fuse-ld=gold.exe

C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32411: error: undefined reference to 'opus_encoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32401: error: undefined reference to 'opus_encoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32411: error: undefined reference to 'opus_encoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32314: error: undefined reference to 'opus_encoder_get_size' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32325: error: undefined reference to 'opus_decoder_get_size' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32336: error: undefined reference to 'opus_encoder_init' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32347: error: undefined reference to 'opus_decoder_init' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32372: error: undefined reference to 'opus_encode_float' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32390: error: undefined reference to 'opus_packet_get_nb_channels' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32401: error: undefined reference to 'opus_encoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32432: error: undefined reference to 'opus_decoder_create' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32443: error: undefined reference to 'opus_decode' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32468: error: undefined reference to 'opus_decode_float' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32479: error: undefined reference to 'opus_decoder_destroy' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32489: error: undefined reference to 'opus_decoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32499: error: undefined reference to 'opus_decoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32509: error: undefined reference to 'opus_decoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32314: error: undefined reference to 'opus_encoder_get_size' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32336: error: undefined reference to 'opus_encoder_init' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32372: error: undefined reference to 'opus_encode_float' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32325: error: undefined reference to 'opus_decoder_get_size' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32347: error: undefined reference to 'opus_decoder_init' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32468: error: undefined reference to 'opus_decode_float' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32509: error: undefined reference to 'opus_decoder_ctl' C:\Users\Amirhosein\@ActiveProjects\Aflatoon\mumble\Mumble-Unity\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:32390: error: undefined reference to 'opus_packet_get_nb_channels' clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)

at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet1 objectFiles, CppToolChainContext toolChainContext) at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics) at il2cpp.Program.DoRun(String[] args, List1 foundAssemblies) at il2cpp.Program.Run(String[] args, Boolean setInvariantCulture) at il2cpp.Program.Main(String[] args)

UnityEngine.Debug:LogError(Object) UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action1) UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List1, Action1, String) UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(Il2CppBuildPipelineData, String, String, Boolean) UnityEditorInternal.IL2CPPBuilder:Run() UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action1, RuntimeClassRegistry) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

BananaHemic commented 2 years ago

Seems that that did not do the trick. What arch is your android phone? Honestly, what we might want to do is look at another unity asset that uses opus, like Photon, and see if they have the same problem and if not, why.

amir2821 commented 2 years ago

Seems that that did not do the trick. What arch is your android phone? Honestly, what we might want to do is look at another unity asset that uses opus, like Photon, and see if they have the same problem and if not, why.

Good news, DllNotFoundExeption solved! I used the opus android plugin in this repo: https://github.com/TyounanMOTI/UnityOpus Build Succeeded.

Bad news, new error: ArgumentException: Get method not found for 'Name' error

BananaHemic commented 2 years ago

I had meant Photon Voice, not just Photon. Did you just change out the .so? If so, which one?

The error you listed looks like unity stripped something out that it should not have. You can change that in PlayerSettings > ManagedStrippingLevel

amir2821 commented 2 years ago

I had meant Photon Voice, not just Photon. Did you just change out the .so? If so, which one?

The error you listed looks like unity stripped something out that it should not have. You can change that in PlayerSettings > ManagedStrippingLevel

I removed files and folders in Plugins>Android and copied unityopus.aar there. Also changed "pluginName" in "NativeMethods" class to "unityopus", like this:

if UNITY_ANDROID

    const string pluginName = "unityopus";

else

I disabled ManagedStrippingLevel but the error still remains.

BananaHemic commented 2 years ago

Do you have any obfuscators in use? It seems like the serialization on this line is using reflection, which fails on "Name" for some reason. Seems like a lot of people have trouble with protobuf and il2cpp. You might want to try the solution listed here

amir2821 commented 2 years ago

Do you have any obfuscators in use? It seems like the serialization on this line is using reflection, which fails on "Name" for some reason. Seems like a lot of people have trouble with protobuf and il2cpp. You might want to try the solution listed here

Unfortunately, adding that link.xml did not solve the problem. I think the problem is .NET version. Unity has removed .NET3.5 from Api Compatibility Levels and now it is forced to .NET4.x. Maybe we need protobuf-net.dll that targets .NET4.x. I searched but I could not find one. Hope you can help. Capture

BananaHemic commented 2 years ago

I don't think so, the error you got really looks like either IL2CPP is not generating some needed code, or IL2CPP is stripping something needed. I think a NET version difference error would look quite different.

For next steps, I think you want to figure out which of those two possibilities it is. You might want to write some reflection code yourself to see which fields are available. Sorry I can't be more helpful