haiyangwu / mediasoup-client-android

mediasoup android client side library https://mediasoup.org
MIT License
179 stars 107 forks source link

Crash related to Audio #12

Closed whatisor closed 3 years ago

whatisor commented 4 years ago

When "WebSockets connection lost", application crash with below ERROR log:

`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) 03-21 14:26:08.102 3914-4000/ /AndroidRuntime: FATAL EXCEPTION: AudioTrackJavaThread Process: com.immertec.vr, PID: 3914 java.lang.Error: FATAL EXCEPTION [AudioTrackJavaThread] Unity version : 2018.4.18f1 Device model : unknown Android SDK built for x86 Device fingerprint: Android/sdk_google_phone_x86/generic_x86:6.0/MASTER/5525988:userdebug/test-keys

Caused by: 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(Native Method)
    at org.webrtc.voiceengine.WebRtcAudioTrack.access$400(WebRtcAudioTrack.java:28)
    at org.webrtc.voiceengine.WebRtcAudioTrack$AudioTrackThread.run(WebRtcAudioTrack.java:147)`
ethand91 commented 4 years ago

Does the crash happen randomly? Or is there a way to reproduce this issue?

whatisor commented 4 years ago

@ethand91 ,as described, "WebSockets connection lost". My network quality is bad, sometimes it disconnected to https://v3demo.mediasoup.org/, then it occurs

gongwj1119 commented 4 years ago

@whatisor @ethand91 Has the crash been solved?

haiyangwu commented 4 years ago

@gongwj1119 @whatisor Would you try the latest version, I've modified the implementation of xx-jni.cpp and the crash never happened during my local test.

PhilanthropistBright commented 4 years ago

I had the same problem, and in the Demo it crashed just by switching the network

lusfold commented 4 years ago

latest version still crash:

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(Native Method)

foobra commented 4 years ago

@gongwj1119 @whatisor Would you try the latest version, I've modified the implementation of xx-jni.cpp and the crash never happened during my local test.

do you push your local change to github? I didn't see any change about xx-jni.cpp during last 30days

wujianwei121 commented 4 years ago

@linsunshinecoder RoomClient->JoinImpl if (mMediasoupDevice == null) { mMediasoupDevice = new Device(); String routerRtpCapabilities = mProtoo.syncRequest("getRouterRtpCapabilities"); mMediasoupDevice.load(routerRtpCapabilities); } Mmediasaupdevice was created repeatedly

pintukumarpatil commented 4 years ago

org.mediasoup.droid.demo E/soup.droid.dem: 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_nativeGetPlayoutDataIJ) FATAL EXCEPTION: AudioTrackJavaThread Process: org.mediasoup.droid.demo, PID: 11162 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_nativeGetPlayoutDataIJ) at org.webrtc.voiceengine.WebRtcAudioTrack.nativeGetPlayoutData(Native Method) at org.webrtc.voiceengine.WebRtcAudioTrack.access$400(WebRtcAudioTrack.java:28) at org.webrtc.voiceengine.WebRtcAudioTrack$AudioTrackThread.run(WebRtcAudioTrack.java:147)

facing same issue

Ben0421 commented 3 years ago

I can reproduce this error by: 1 - Creating both send and receive transports 2 - Connecting sendTransport by producing 3 - Pausing the producer 4 - Connecting recvTransport by consuming 5 - Stopping the consumer 6 - Closing the recvTransport 7 - Disposing the recvTransport <-- After disposing, app will crash soon 8 - Recreating the recvTransport in the server and than the client

App crashes after disposing of the recvTransport if the sendTransport is connected (a producer is created on this transport and has produced). The crash can be reproduced quite easily following those steps on two devices (other devices tested work as intended).

The devices where this crash happens are armeabi-v7a Android 6.0.1 device (2 different manufacturers) and a Android 5.1-v7a device. This isn't specific to armv7a as devices with v7a/Android 7.1 work as expected.

PeerConnectionFactory is created a single time and MediasoupDevice is also only created once. I am using a build with the latest commits (26 june).

Any help is appreciated!

E/ACRA: ACRA caught a UnsatisfiedLinkError for com.ex.app 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) at org.webrtc.voiceengine.WebRtcAudioRecord.nativeDataIsRecorded(Native Method) at org.webrtc.voiceengine.WebRtcAudioRecord.access$600(WebRtcAudioRecord.java:26) at org.webrtc.voiceengine.WebRtcAudioRecord$AudioRecordThread.run(WebRtcAudioRecord.java:166)

Ben0421 commented 3 years ago

@haiyangwu 大佬好,当我运行代码 recvTransport.close()时候会出现下面这个异常。请问是什么原因呢, 是创建transport的时候要注意哪些问题还是什么原因呀? 望回复,谢谢!

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)

Did you call recvTransport.close() before or after sendTransport.close() ? Did you call .dispose() for both transports? What Android version is affected?

haitunSasa commented 3 years ago

I think I have fixed this problem. In the webrtc issues, there also have this problem. https://bugs.chromium.org/p/webrtc/issues/detail?id=7587 The reason is that only one audio device module supported on Android. In this code, when join the room, the peerConnectionFactory has been created 4 times and each time will create one audio device module.So I try to create only one peerConnectionFactory in java, and add peerconnection options params in device.cpp. Finally, it works.
I hope it helps you.

wujianwei121 commented 3 years ago

Thanks 兄嘚

------------------ 原始邮件 ------------------ 发件人: "haiyangwu/mediasoup-client-android" <notifications@github.com>; 发送时间: 2020年7月23日(星期四) 下午2:08 收件人: "haiyangwu/mediasoup-client-android"<mediasoup-client-android@noreply.github.com>; 抄送: "℉ōrēvēr."<417757407@qq.com>;"Comment"<comment@noreply.github.com>; 主题: Re: [haiyangwu/mediasoup-client-android] Crash related to Audio (#12)

I think I have fixed this problem. In the webrtc issues, there also have this problem. https://bugs.chromium.org/p/webrtc/issues/detail?id=7587 The reason is that only one audio device module supported on Android. In this code, when join the room, the peerConnectionFactory has been created 4 times and each time will create one audio device module.So I try to create only one peerConnectionFactory in java, and add peerconnection options params in device.cpp. Finally, it works. I hope it helps you.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

Ben0421 commented 3 years ago

I think I have fixed this problem. In the webrtc issues, there also have this problem. https://bugs.chromium.org/p/webrtc/issues/detail?id=7587 The reason is that only one audio device module supported on Android. In this code, when join the room, the peerConnectionFactory has been created 4 times and each time will create one audio device module.So I try to create only one peerConnectionFactory in java, and add peerconnection options params in device.cpp. Finally, it works. I hope it helps you.

Nice catch! libmediasoup creates multiple peer connection factories by default, including when creating a Device. Did you do a commit of the patch you applied? I checked your fork of this project but unfortunately it did not include any changes. Would you be open to sharing the solution?

skgwazap commented 3 years ago

I've scribbled something here https://github.com/haiyangwu/mediasoup-client-android/pull/42

janus-xiao commented 3 years ago

libmediasoupclient_ so.so How to compile by yourself ?

tkreknin commented 3 years ago

libmediasoupclient_ so.so How to compile by yourself ?

It's better to ask here https://github.com/versatica/libmediasoupclient/ as mediasoup-client-android depends on it. But, afair, once you have all dependencies and tools downloaded (cmake, webrtc) you can build mediasoup-client-android using gradle and it will automatically build libmediasoupclient_ so.so

acoderleex commented 3 years ago

waiting for new release to this problem

acoderleex commented 3 years ago

I think I have fixed this problem. In the webrtc issues, there also have this problem. https://bugs.chromium.org/p/webrtc/issues/detail?id=7587 The reason is that only one audio device module supported on Android. In this code, when join the room, the peerConnectionFactory has been created 4 times and each time will create one audio device module.So I try to create only one peerConnectionFactory in java, and add peerconnection options params in device.cpp. Finally, it works. I hope it helps you.

Could you release a branch for us?

whatisor commented 3 years ago

If we talk about pure Java technically, does someone know why a function is possible to become unknown by some bad logic? It should be constrained from .so binary.

whatisor commented 3 years ago

Base on update from haiyangwu, this is my solution: