question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not entering "onAddTrack" function

See original GitHub issue

Observed Behavior

Connection is not able to reach to “onAddTrack”. this happens after i upgraded RN to 0.70.6 and the webrtc plugin to beta 7, same issue on beta 6. but this wasn’t happening on my code before the upgrade. also i’m not sure if its 100% plugin issue or in my code but i’m not able to know what can go wrong.

i did some logs here they are :

    public WritableMap peerConnectionAddTrack(int id,
                                              String trackId,
                                              ReadableMap options) {
        try {
            return (WritableMap) ThreadUtils.submitToExecutor((Callable<Object>) () -> {
                PeerConnectionObserver pco = mPeerConnectionObservers.get(id);
                Log.d(TAG, "peerConnectionAddTrack() " + "A");
                if (pco == null) {
                    Log.d(TAG, "peerConnectionAddTrack() peerConnection is null");
                    return null;
                }

                MediaStreamTrack track = getLocalTrack(trackId);
                if (track == null) {
                    Log.w(TAG, "peerConnectionAddTrack() couldn't find track " + trackId);
                    return null;
                }
                Log.d(TAG, "peerConnectionAddTrack() " + "B");
                List<String> streamIds = new ArrayList<>();
                if (options.hasKey("streamIds")) {
                    ReadableArray rawStreamIds = options.getArray("streamIds");
                    if (rawStreamIds != null) {
                        for (int i = 0; i < rawStreamIds.size(); i++) {
                        Log.d(TAG, "peerConnectionAddTrack() " + i + rawStreamIds.getString(i));
                            streamIds.add(rawStreamIds.getString(i));
                        }
                    }
                }
                Log.d(TAG, "peerConnectionAddTrack() " + pco.getPeerConnection());
                RtpSender sender = pco.getPeerConnection().addTrack(track, streamIds);
                Log.d(TAG, "peerConnectionAddTrack() " + "C");
                // Need to get the corresponding transceiver as well
                RtpTransceiver transceiver = pco.getTransceiver(sender.id());

                // We need the transceiver creation order to reorder the transceivers array
                // in the JS layer.
                WritableMap params = Arguments.createMap();
                params.putInt("transceiverOrder", pco.getNextTransceiverId());
                params.putMap("transceiver", SerializeUtils.serializeTransceiver(id, transceiver));
                params.putMap("sender", SerializeUtils.serializeSender(id, sender));
                Log.d(TAG, "peerConnectionAddTrack() " + "D");
                return params;
            }).get();
        } catch (InterruptedException | ExecutionException e) {
            Log.d(TAG, "peerConnectionAddTrack() " + e.getMessage());
            return null;
        }
    }

image

Platform Information

  • React Native Version: 0.70.6
  • Plugin Version: beta-7
  • OS: Android
  • OS Version: 9/12/10

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
saif-o99commented, Dec 12, 2022

Sure will do, thanks for your efforts

0reactions
saghulcommented, Dec 12, 2022

Beta 8 is out, can you give it another try?

Read more comments on GitHub >

github_iconTop Results From Across the Web

RTCPeerConnection.ontrack event not firing - Stack Overflow
ontrack event not firing whenever a new MediaStreamTrack object has been created (by the RTCPeerConnection.addTrack() function). Using the ...
Read more >
MediaStream: addtrack event - Web APIs | MDN
The addtrack event is fired when a new MediaStreamTrack object has been added to a MediaStream . This event is not cancelable and...
Read more >
Issues · react-native-webrtc/react-native-webrtc - GitHub
icefailed => try to create offer again, but not working ... Not entering "onAddTrack" function ... Remote stream is not visible on android...
Read more >
872 - webrtc - Monorail
Issue 872: Implement Remote media stream events for MediaStreamTrackList:onaddtrack and onremovetrack ... Create a MediaStreamTrack object track ...
Read more >
Media Capture and Streams - W3C
Firing a track event named e with a MediaStreamTrack track means that an event with the name e , which does not bubble...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found