# Error Unity DllNotFoundException: Unable to load DLL 'webrtc'

**URL:** <https://forum.magicleap.cloud/t/error-unity-dllnotfoundexception-unable-to-load-dll-webrtc/2299>\
**Category:** WebRTC\
**Created:** [July 31, 2023, 7:27pm UTC](https://forum.magicleap.cloud/t/error-unity-dllnotfoundexception-unable-to-load-dll-webrtc/2299 "2023-07-31T19:27:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ks-scott](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@ks-scott](https://forum.magicleap.cloud/u/ks-scott)\
**Post date:** [July 31, 2023, 7:27pm UTC](https://forum.magicleap.cloud/t/error-unity-dllnotfoundexception-unable-to-load-dll-webrtc/2299/1 "2023-07-31T19:27:55Z")

</div>

**Unity Editor version** : 2022.3.1f1  
**Unity package version** : 1.8.0  
**ML2 OS version** : 1.3.0-dev2  
**MLSDK version** : 1.3.0-dev2

We are currently blocked on `com.unity.webrtc` not working at this MLSDK version, so I decided to try the `MLWebRTC` API. The C# bindings are all still available, but it seems the native code DLL could not be found.

I have been experimenting with the `MLWebRTC.PeerConnection.CreateRemote()` call because it is the first call into the WebRTC library in our scenario. The sample code in [github.com/magicleap/MagicLeapUnityExamples:MLWebRTCExample@v1.8.0](http://github.com/magicleap/MagicLeapUnityExamples:MLWebRTCExample@v1.8.0), when run on the headset, produces a non-null connection and `result.IsOk`. The same call run in the simulator produces a `NotImplementedException`, which I presume is expected behaviour.

When I attempt the same `CreateRemote()` call in our app, there is a managed code `NullReferenceException` that is proceeded by this message:

**webrtc DLL not found**

> 2023-07-28 14:58:24.397 28752 28774 Error Unity DllNotFoundException:  
> **Unable to load DLL 'webrtc'**. Tried the load the following dynamic libraries:  
> Unable to load dynamic library 'webrtc' because of 'Failed to open the  
> requested dynamic library (0x06000000) dlerror() = dlopen failed: library "webrtc" not found

**Then the NullReferenceException**

> System.NullReferenceException: Object reference not set to an instance of an object.  
> at UnityEngine.\_AndroidJNIHelper.GetSignature (System.Object obj) [0x00000] in \<00000000000000000000000000000000\>:0   
> at UnityEngine.\_AndroidJNIHelper.GetSignature[ReturnType] (System.Object args) [0x00000] in \<00000000000000000000000000000000\>:0   
> at UnityEngine.\_AndroidJNIHelper.GetMethodID[ReturnType] (System.IntPtr jclass, System.String methodName, System.Object args, System.Boolean isStatic) [0x00000] in \<0000000000000000000000000  
> at UnityEngine.AndroidJavaObject.\_CallStatic[ReturnType] (System.String methodName, System.Object args) [0x00000] in \<00000000000000000000000000000000\>:0   
> at UnityEngine.XR.MagicLeap.MLPermissions.CheckPermissionInternal (System.String permission) [0x00000] in \<00000000000000000000000000000000\>:0   
> at UnityEngine.XR.MagicLeap.MLPermissions.CheckPermission (System.String permission) [0x00000] in \<00000000000000000000000000000000\>:0   
> at **UnityEngine.XR.MagicLeap.MLWebRTC+PeerConnection.CreateRemote** (UnityEngine.XR.MagicLeap.MLWebRTC+IceServer iceServers, UnityEngine.XR.MagicLeap.MLResult& result) [0x00000] in \<00000000000  
> at Assets.RemoteSpark.Scripts.WebRTC.ML.MLPeerConnection..ctor (KSpark.Telemetry.KSparkLogger logger) [0x00000] in \<00000000000000000000000000000000\>:0   
> at Assets.RemoteSpark.Scripts.WebRTC.ML.MLWebRTCProvider.CreatePeerConnection () [0x00000] in \<00000000000000000000000000000000\>:0   
> [... snip ...]

We have been comparing the failing code in our app to the successful sample code, but cannot find the cause. It seems like it must be a project setup detail, but I'm just guessing. Do you have any advice for what might cause this, or how to investigate further?

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [July 31, 2023, 7:39pm UTC](https://forum.magicleap.cloud/t/error-unity-dllnotfoundexception-unable-to-load-dll-webrtc/2299/2 "2023-07-31T19:39:08Z")

</div>

Hi @ks-scott,

Welcome to the Magic Leap 2 Developer forums. We are grateful to have you here engaging with us.

I found [a tool that may be able to help find the missing dependencies](https://github.com/lucasg/Dependencies). Let me know if this is helpful for you.

Best,

El

---

<div class="post-metadata">

**Author:** ![ks-scott](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@ks-scott](https://forum.magicleap.cloud/u/ks-scott)\
**Post date:** [July 31, 2023, 8:10pm UTC](https://forum.magicleap.cloud/t/error-unity-dllnotfoundexception-unable-to-load-dll-webrtc/2299/3 "2023-07-31T20:10:43Z")

</div>

Thanks @etucker for the quick reply. Full disclosure: I am a newcomer to both Unity development and the Magic Leap platform, so I could easily be missing something that you would expect to be obvious.

I have used that Dependencies tool many times -- it can indeed be a life saver. But it's Windows only, no? I see in my post that I neglected to emphasize an important detail: the issue I'm having is specific to the Magic Leap headset, so an Android `.so` dependency I presume. I assume the reference to DLL is just because `DllNotFoundException` is a standard dotnet exception class that is used uniformly on all platforms.

I think the call to `PeerConnection.CreateRemote()` is the first call into the `MLWebRTC` API, which -- I'm guessing -- triggers an attempt to load the native code `webrtc.so` which for some reason is not on the library path. As I am an Android/ML2/Unity newbie, I wonder if I have just missed a project or player setting that would include webrtc.so in the build. Or something. I don't know where it is meant to be sourced from or where in the build process I would look to see what is going on.

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [August 1, 2023, 4:13pm UTC](https://forum.magicleap.cloud/t/error-unity-dllnotfoundexception-unable-to-load-dll-webrtc/2299/4 "2023-08-01T16:13:29Z")

</div>

Hi @ks-scott the com.unity.webrtc package is not fully supported by Magic Leap at this time. We are investigating an issue with the Plugin that prevents Magic Leap applications from initializing correctly.

That said, the reason why you are running into a `Unable to load DLL` issue is because Unity has not released the x86\_64 compatible version yet. The build script has been updated 2 weeks ago in the [project repository](https://github.com/Unity-Technologies/com.unity.webrtc). If you want to try to use it in your Magic Leap 2 project you will need to manually [build the plugin from the main branch](https://github.com/Unity-Technologies/com.unity.webrtc/blob/main/Plugin~/README.md#android).
