Unity-Technologies / com.unity.webrtc

WebRTC package for Unity
Other
753 stars 191 forks source link

[BUG] WebRTC with Unity as a Library / Cordova + iosRTC #555

Open Kerugal opened 2 years ago

Kerugal commented 2 years ago

Setup: Unity as a library on iOS device. The existing code is compiled by Cordova. A plugin is used in Cordova https://github.com/cordova-rtc/cordova-plugin-iosrtc On Unity side Unity-Webrtc is used. All components build correctly as stand-alone and also as UaaL if WebRTC is not included in Unity. The following error message is thrown:

2021-11-11 17:59:48.086883+0100 XXX[11121:1943090] Error loading /var/containers/Bundle/Application/F8920C8F-FA77-4A40-B72C-D69636DEB42F/XXX.app/Frameworks/UnityFramework.framework/UnityFramework: dlopen(/var/containers/Bundle/Application/F8920C8F-FA77-4A40-B72C-D69636DEB42F/XXX.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/webrtc.framework/webrtc

Referenced from: /private/var/containers/Bundle/Application/F8920C8F-FA77-4A40-B72C-D69636DEB42F/XXX.app/Frameworks/UnityFramework.framework/UnityFramework

Reason: tried: '/private/var/containers/Bundle/Application/F8920C8F-FA77-4A40-B72C-D69636DEB42F/XXX.app/Frameworks/webrtc.framework/webrtc' (no such file), '/private/var/containers/Bundle/Application/F8920C8F-FA77-4A40-B72C-D69636DEB42F/XXX.app/Frameworks/webrtc.framework/webrtc' (no such file), '/usr/lib/swift/webrtc.framework/webrtc' (no such file), '/private/var/containers/Bundle/Application/F8920C8F-FA77-4A40-B72C-D69636DEB42F/XXX.app/Frameworks/webrtc.framework/webrtc' (no such file), '/System/Library/Frameworks/webrtc.framework/webrtc' (no such file)

2021-11-11 17:59:48.087928+0100 XXX[11121:1943090] Error loading /var/containers/Bundle/Application/F8920C8F-FA77-4A40-B72C-D69636DEB42F/XXX.app/Frameworks/UnityFramework.framework/UnityFramework: dlopen(/var/containers/Bundle/Application/F8920C8F-FA77-4A40-B72C-D69636DEB42F/XXX.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/webrtc.framework/webrtc

Referenced from: /private/var/containers/Bundle/Application/F8920C8F-FA77-4A40-B72C-D69636DEB42F/XXX.app/Frameworks/UnityFramework.framework/UnityFramework

For the report production, a Corodva project with iosRTC + Unity as a Library with Unity WebRTC had to be set up.

Does the application have a name conflict with the iosRTC library? Should I integrate the library differently?

Environment

Many many Thanks Patrick

karasusan commented 2 years ago

@Kerugal I have never tried to built UaaS with the webrtc library. I would like to know the more detailed that you determined the cause of issue is a name conflict?

Kerugal commented 2 years ago

Whether it's a name conflict, I don't know for sure - that was just a guess. However, since all components run individually, this was my first suspicion. WebRTC in a UaaL project also runs without errors. Only when I include "iosRTC" in the existing iOS project or visa versa does this error occur as soon as I switch to Unity - hence the assumption that there may be a name conflict.

As soon as I get back to the office, I'll send you some screenshots of my XCode project setup.

Kerugal commented 2 years ago

IssueWebrtc (1) IssueWebrtc (3) IssueWebrtc (2)

karasusan commented 2 years ago

memo: WRS-156

Kerugal commented 2 years ago

In case it helps with reproduction - here are my findings so far:

Regards Patrick

karasusan commented 2 years ago

@Kerugal Thanks for sharing helpful information. Could you tell me more about "ARM64 error"?

Kerugal commented 2 years ago

At the moment we do not own an arm64 macOS. We think that this will cause errors in the script. At least that's what the script says. Next week we will build it on an arm64 Mac and hope that this will solve the problem. Cross-compiling, between x86 and arm64 has not worked so far

Kerugal commented 2 years ago

Small update: With the rebuilt and renamed WebRTC library, it now runs workaorund moderately.

karasusan commented 2 years ago

@Kerugal I can't think of any good ideas for avoiding name conflict. Do you have any ideas?

Kerugal commented 2 years ago

I changed the output files in build_plugin_ios.sh to webrtcUnity.framework. Then executed each build process individually. Before building the archieve in Xcode I also changed the generated cmake files. In one file there was also a comment with the hint to rename. Afterwards the framework was mounted locally from the disk with changed names.

Certainly not a model solution, but as a workaround it worked, so that the two frameworks no longer get in each other's way.

kannan-xiao4 commented 2 years ago

@Kerugal Thank you for trying the workaround. Let us investigate if XCode offers a workaround other.