devopvoid / webrtc-java

WebRTC for desktop platforms running Java
Apache License 2.0
248 stars 60 forks source link

Fatal error in audio_send_stream.cc #118

Open Charles92011 opened 1 year ago

Charles92011 commented 1 year ago

Describe the bug I've had my experimental project working for a while now: https://github.com/Charles92011/webrtc-java-experimental-server It was working great, but I put it away for a couple of months until we're ready to transition to it. When I started it up today, it gets this error upon connecting two connections together:

#
# Fatal error in: ../../audio/audio_send_stream.cc, line 387
# last system error: 0
# Check failed: !race_checker.RaceDetected()
# 

I updated my pom file to get the latest version of the library and it still fails. This error is untrappable, so I can't recover from it

To Reproduce Steps to reproduce the behavior:

  1. clone https://github.com/Charles92011/webrtc-java-experimental-server
  2. run main.java
  3. browse to wsclient.html
  4. click start
  5. click mirror
  6. Server will crash

Expected behavior You should get two videos working fine

Desktop (please complete the following information): Windows 10

Additional context This was working fine when I last used it a few months ago.

Charles92011 commented 1 year ago

This error only appears when transmitting an audio track. Video tracks alone do not throw this error.

naveenSaini1 commented 2 months ago

hey i am also getting this same error wheni am trying to add mediastreamtrack of another party

Map<String, RTCPeerConnection> savedMapOfConnection = list_of_connected_user
                        .get(roomUserResponse.getRoomId());
                    savedMapOfConnection.forEach((key, connection) -> {
                    final int receivers = connection.getReceivers().length;
                    if (receivers == 0)
                                      {return;}
                    try {
                        for (int index = 0; index < receivers; index++) {

                            final RTCRtpReceiver receiver = connection.getReceivers()[index];
                            if (receiver != null) {

                                final MediaStreamTrack track = receiver.getTrack();
                                if (track != null) {

                                    List<String> streamIds = new ArrayList<String>();
                                    streamIds.add(receiver.getTrack().getId());

                                    @SuppressWarnings("unused")
                                    RTCRtpSender sender = connection.addTrack(track, streamIds);
                                }
                            }
                        }

                    }
                    catch(Exception e) {
                        System.out.println("someting went wrong "+e.getMessage());

                    }

                });
        }

so help

Charles92011 commented 2 months ago

@naveenSaini1 I was never able to get past this error, and in a year there's been no update that mentions it. I had to abandon it.

naveenSaini1 commented 2 months ago

@Charles92011 hey i saw your project and that is really amazing most of the things i learn from there and about this error i need to resolve this because i am trying to make sfu server in webrtc and now i have been stuck at this point if you want we can figure out on this

Charles92011 commented 2 months ago

@naveenSaini1 I'm in the same situation. My goal was to build a server with this library, but I had to abandon it because of this error.

You could always download the library source, and see if you can trap the error.

From my research, the error is actually occurring in the WebRTC code itself, not the java RTC library. So you could try to modify JavaRTC to trap the exception or try to debug Google's WebRTC code to fix it. I don't have the resources available to do either one.

naveenSaini1 commented 2 months ago

@Charles92011 hi i noticed something in this , like whenever we send the audioTrack like this

 AudioTrackSource audioSource = peerConnectionFactory.createAudioSource(new AudioOptions());
        AudioTrack audioTrack = peerConnectionFactory.createAudioTrack("audioTrack", audioSource);
            audioTrack.addSink(new AudioTrackSink() {
                @Override
                public void onData(byte[] data, int bitsPerSample, int sampleRate, int channels, int frames) {
                    System.out.println(data);
                }
            });

            List<String> streamIds = new ArrayList<>();
            streamIds.add("stream-0");

            RTCRtpSender audioSender = peer_connection.addTrack(audioTrack, streamIds);

we will not get the error so i change this way to puting the track in diffrent way

AudioTrack audioTrack = (AudioTrack)allTheTracks.get("a");
            audioTrack.addSink(new AudioTrackSink() {
                @Override
                public void onData(byte[] data, int bitsPerSample, int sampleRate, int channels, int frames) {
                    System.out.println(data);
                }
            });

            List<String> streamIds = new ArrayList<>();
            streamIds.add(allTheTracks.get("a").getId());

            RTCRtpSender audioSender = peer_connection.addTrack(audioTrack, streamIds);

but guess what same thing that same issue

 #
# Fatal error in: ../../audio/audio_send_stream.cc, line 387
# last system error: 11
# Check failed: !race_checker.RaceDetected()

@devopvoid can you please look into this , i really don't know like how to resolve this or can you gave little hint