UnsatisfiedLinkError in Webrtc for Android

3,030 views
Skip to first unread message

Andrey Grusha

unread,
Aug 3, 2015, 8:53:25 AM8/3/15
to discuss-webrtc
Hello everyone!

Recently I've been reported about very weird sort of exception that happens with my Android webrtc application. 

java.lang.UnsatisfiedLinkError: No implementation found for void org.webrtc.voiceengine.WebRtcAudioTrack.nativeGetPlayoutData(int, long) (tried Java_org_webrtc_voiceengine_WebRtcAudioTrack_nativeGetPlayoutData and Java_org_webrtc_voiceengine_WebRtcAudioTrack_nativeGetPlayoutData__IJ)
       at org.webrtc.voiceengine.WebRtcAudioTrack.nativeGetPlayoutData(WebRtcAudioTrack.java)
       at org.webrtc.voiceengine.WebRtcAudioTrack.access$600(WebRtcAudioTrack.java:23)
       at org.webrtc.voiceengine.WebRtcAudioTrack$AudioTrackThread.run(WebRtcAudioTrack.java:85)

Unfortunately, I can't reproduce it by myself, so the only information that I have, are such stasktraces from different places where java layer of libjinglePeerconnection library is trying to reach to native layer and then fails. 
All I managed to find about the UnsatisfiedLinkError talks about improperly attached libraries that are not able to be loaded. But in my cases java layer of the library is trying to call native methods of this very library so I wonder is it my fault or is it some known issue?

Neernay Khairkar

unread,
Jun 20, 2016, 6:12:13 AM6/20/16
to discuss-webrtc
Hi All, even I am getting the same exception.

Christoffer Jansson

unread,
Jun 20, 2016, 7:34:44 AM6/20/16
to discuss-webrtc
The original post is over 1 year old, are you seeing this using the latest ToT code?

/Chris

Neernay Khairkar

unread,
Jun 20, 2016, 8:19:55 AM6/20/16
to discuss-webrtc
Yes, I am on the ToT. This is happening when I import .aar in another project. The webrtc SO file is in .aar.

Christoffer Jansson

unread,
Jun 21, 2016, 4:40:00 AM6/21/16
to discuss-webrtc
Hi,

Not familiar with adding WebRTC to an Android studio project. When you write "webrtc SO", which file do you mean? libjingle_peerconnection_so.so ?

What steps do you do when importing it?

/Chris

Neernay Khairkar

unread,
Jun 21, 2016, 7:02:59 AM6/21/16
to discuss-webrtc
yes, the libjingle_peerconnection_so.so and libjingle_peerconnection_java.jar.
I have library project in Android Studio which contains the above 2 files. This library project is exported as .aar file and include this .aar into 3rd third party project (which is the client appliaction).

I am generating the SO and JAR through this command: ninja -C out/Debug.

Christoffer Jansson

unread,
Jun 21, 2016, 7:25:59 AM6/21/16
to discuss-webrtc
Are you compiling for the correct instruction set? I.e. x86 compiled WebRTC libs will not work on an Android Arm device etc. Have you followed the steps at https://webrtc.org/native-code/android/ ?

/Chris

Neernay Khairkar

unread,
Jun 21, 2016, 8:30:09 AM6/21/16
to discuss-webrtc
Hi Chris, I am aware of that. The binary is for arm and not for x86. The issue mostly happens on android 4x devices.

Neernay Khairkar

unread,
Jun 21, 2016, 9:15:08 AM6/21/16
to discuss-webrtc
I am getting crash on 4.2.2 devices. The crash is not observed on 4.4.2+ devices.

Vikas Kashyap

unread,
Jan 10, 2017, 11:33:08 AM1/10/17
to discuss-webrtc
I am also getting this error quite frequently. This happens when disconnecting from one and connecting to other. Did you manage to find a solution for it?

Crossle Song

unread,
May 22, 2017, 3:11:49 AM5/22/17
to discuss-webrtc
same problem on the latest webrtc version

在 2015年8月3日星期一 UTC+8下午8:53:25,Andrey Grusha写道:

Jose Javier Alvarez

unread,
May 29, 2017, 9:59:00 AM5/29/17
to discuss-webrtc
Hi everyone, this issue is happening on Nexus 4, android version 5.1.1 - correct arch being used. Any idea of what's going on?

s.se...@sping.nl

unread,
Jul 3, 2017, 4:11:06 AM7/3/17
to discuss-webrtc
Got the same issue on a Samsung S6 edge running Android 6.0 and S7 edge running Android 7.0

Dean Wild

unread,
Jun 8, 2018, 5:20:22 AM6/8/18
to discuss-webrtc
Seeing this fairly frequently on a range of devices and Android versions. We're building branch r66.

Erik Hellman

unread,
Jun 11, 2018, 4:34:46 AM6/11/18
to discuss-webrtc
Hi all!

This is an unfortunate bug that appears sometimes when loading native libraries on Android. There is a long history behind this, but the TL:DR is; Sometimes, especially during upgrades/installs, the loading of an .so file in an Android app can fail. Worst case is that the user needs to uninstall and reinstall the application to solve the problem. This happens more frequently the larger your .so files are.

The good news is that there is a third-party library that can deal with this so! :)

The solution to your problems is ReLinker, which detects when loading fails and tries a different approach. You'll find it here: https://github.com/KeepSafe/ReLinker

Hope it works for all of you!

// Erik

Patrick Larson

unread,
Oct 26, 2018, 4:33:14 PM10/26/18
to discuss-webrtc
Hi Erik! We have an S6 device that reproduces this issue consistently under one of our use cases.

I got to do a little bit of digging and it seems to be due to the NativeRegistration owned by audio_track_jni (https://webrtc.googlesource.com/src/+/master/modules/audio_device/android/audio_track_jni.h#125) unregistering its natives on destruction. 
I verified that leaking that NativeRegistration object fixes this error.

I think my confusion here is why this static native function has it's registration owned in this non-static fashion.  I think fixes could either be to register this statically or provide the c-style function name to make registering this unnecessary.

Let me know if you need anything else to dig into this!

Dio Ye

unread,
Jan 16, 2019, 9:25:16 AM1/16/19
to discuss-webrtc
Hi Patrick!

Thank for your reply, it inspires me very much. I have been puzzled by this issue for a long time. Also I got another crash as below, these two are similar.

12-08 20:55:35.035 E/AndroidRuntime(30252): java.lang.UnsatisfiedLinkError: No implementation found for void org.webrtc.voiceengine.WebRtcAudioRecord.nativeDataIsRecorded(int, long) (tried Java_org_webrtc_voiceengine_WebRtcAudioRecord_nativeDataIsRecorded and Java_org_webrtc_voiceengine_WebRtcAudioRecord_nativeDataIsRecorded__IJ)
12-08 20:55:35.035 E/AndroidRuntime(30252): at org.webrtc.voiceengine.WebRtcAudioRecord.nativeDataIsRecorded(Native Method)
12-08 20:55:35.035 E/AndroidRuntime(30252): at org.webrtc.voiceengine.WebRtcAudioRecord.access$600(WebRtcAudioRecord.java)
12-08 20:55:35.035 E/AndroidRuntime(30252): at org.webrtc.voiceengine.WebRtcAudioRecord$AudioRecordThread.run(WebRtcAudioRecord.java)

Actually I searched this topic and found mozilla has made a fix on their own fork(https://bugzilla.mozilla.org/show_bug.cgi?id=1349581). They just defer the registration to avoid the issue. Though I don't fully understand how does it work.

I will try to register these two native functions statically. But the biggest question for me is that I can't reproduce the error, it's risky to verify it on production environment. So could you give me a hint?

Thank you!

在 2018年10月27日星期六 UTC+8上午4:33:14,Patrick Larson写道:

Patrick Larson

unread,
Jan 16, 2019, 1:38:30 PM1/16/19
to discuss-webrtc
Hi Dio,

I'll preface this with the recommended solution being to move away from the deprecated audio device module.  

In the short term this is what I found:
I believe in our case what was happening is that we had a race between creation and destruction of two of the audio_track_jni objects.  We had one audio_track_jni object that was being destroyed while a second one was being created.  If the creation of the second one finished before the first, the destructor of the first would unregister the native functions when destroying the NativeRegistration. This would cause unsatisfiedllinkerror when trying to use any native function on that second audio_track_jni object.

You may be able to force a repro by playing with multiple of these objects and fiddling with their destruction.

Kushtrim Pacaj

unread,
Feb 8, 2019, 7:18:00 AM2/8/19
to discuss-webrtc
Reply all
Reply to author
Forward
0 new messages