melihercan / WebRTCme

A cross-platform framework for adding WebRTC support to .NET MAUI, Blazor, and Desktop applications by using a single unified .NET/C# API.
https://github.com/melihercan/WebRTCme
MIT License
223 stars 46 forks source link

Java.Lang.AbstractMethodError org.webrtc.PeerConnection$Observer.onTrack FATAL Error #35

Open georgeinva2004 opened 6 months ago

georgeinva2004 commented 6 months ago

Finally making the jump to Maui. I'm able to establish a connect to a peer with video and audio streaming properly. However, after about 15-20 seconds, I get the error: FATAL UNHANDLED EXCEPTION: Java.Lang.AbstractMethodError: abstract method "void org.webrtc.PeerConnection$Observer.onTrack(org.webrtc.RtpTransceiver)". Saw this in StackOverflow if it helps. https://stackoverflow.com/questions/59932333/webrtc-crash-abstractmethoderror-due-to-the-method-ontrack-in-the-peerconnection

Any help would be greatly appreciated.

Particulars: The app is built for Android API 34 .net 8 Same issue in both the emulator and on a Galaxy Tab S9 Using WebRtcMe Signaling server Peer is using the 1.x version of WebRTCMe on Blazor running on Windows 11. The peer is not throwing any errors. Visual Studio 2022 17.9.1

Pertinent section of the log:

[stun_port.cc] (line 604): UDP send of 20 bytes to host stun.l.google.com:19302 (142.250.112.x:19302) failed with error 0 : [0x00000016] Invalid argument [stun_port.cc] (line 604): UDP send of 20 bytes to host stun.l.google.com:19302 ([2607:f8b0:4023:x:x:x:x:x]:19302) failed with error 0 : [0x00000065] Network is unreachable [stun_port.cc] (line 604): UDP send of 20 bytes to host stun.l.google.com:19302 ([2607:f8b0:4023:x:x:x:x:x]:19302) failed with error 0 : [0x00000065] Network is unreachable [mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.AbstractMethodError: abstract method "void org.webrtc.PeerConnection$Observer.onTrack(org.webrtc.RtpTransceiver)" [mono-rt] at Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 20830 [mono-rt] at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(String encodedMember, IJavaPeerable self, JniArgumentValue parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 75 [mono-rt] at Org.Webrtc.PeerConnection.IObserver.OnTrack(RtpTransceiver transceiver) [mono-rt] at Org.Webrtc.PeerConnection.IObserver.n_OnTrack_Lorg_webrtcRtpTransceiver(IntPtr jnienv, IntPtr native__this, IntPtr native_transceiver) [mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 125 [mono-rt] --- End of managed Java.Lang.AbstractMethodError stack trace --- [mono-rt] java.lang.AbstractMethodError: abstract method "void org.webrtc.PeerConnection$Observer.onTrack(org.webrtc.RtpTransceiver)" [mono-rt] at crc64d3c2160b97caa851.RTCPeerConnection.n_onTrack(Native Method) [mono-rt] at crc64d3c2160b97caa851.RTCPeerConnection.onTrack(RTCPeerConnection.java:175) [mono-rt] [mono-rt] --- End of managed Java.Lang.AbstractMethodError stack trace --- [mono-rt] java.lang.AbstractMethodError: abstract method "void org.webrtc.PeerConnection$Observer.onTrack(org.webrtc.RtpTransceiver)" [mono-rt] at crc64d3c2160b97caa851.RTCPeerConnection.n_onTrack(Native Method) [mono-rt] at crc64d3c2160b97caa851.RTCPeerConnection.onTrack(RTCPeerConnection.java:175)

georgeinva2004 commented 6 months ago

Thinking I may have a compatibility problem between V1 of WebRTCme and V2, I updated EVERYTHING. My Maui and Blazor apps are using V2 of the library. I also moved to the Signaling Server in the V2 repo. Unfortunately, I have the same issue. Any thought?

melihercan commented 5 months ago

I will try to check it this weekend. Currently, I am very busy on my other projects.

georgeinva2004 commented 5 months ago

I upped the minimum android version to 32 on the android-specific projects and that seemed to fix the crash. Now I'm able to stream android video to the Blazor app, but the rendering on the Android app is a bit weird. The local video only shows when the tablet I'm using is in portrait mode. The android app is not showing the Blazor video.

melihercan commented 5 months ago

The code is untested in landscape mode (and tablets). You may need to fiddle a bit with the code to get what you want.

georgeinva2004 commented 5 months ago

Incidentally, this project is fantastic. Thanks for all your hard work. I fiddled with the FlexLayout a bit and things appear to be working much better. I can see video from the Blazor app on the Maui Android app and vice versa. Now working on the audio/video muting. I noticed the media element exposes audio and video mute properties along with show controls. Simply setting those (even on the UI thread) doesn't appear to have any effect. Is there something magic in the middleware that I may have missed to control audio/video streams?

melihercan commented 5 months ago

Muting hasn't been implemented on the UI and media levels yet; only property binding has been provided.