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.

RTCPeerConnection.setRemoteDescription closing the app without any error

See original GitHub issue

i was calling RTCPeerConnection.setRemoteDescription(recievedOffer) just after RTCPeerConnection.createOffer() on other side. but RTCPeerConnection.setRemoteDescription was closing app abruptly without even any error.

Expected behavior

it should be able to set remote description successfully or it should throw error in react native app instead of closing app

Observerd behavior

It closing the app abruptly.

Steps to reproduce the problem

CODE

createAnswer = async (remoteDes) => { try { console.log(‘setting up create answer’, remoteDes); // this line closing the app abruptly await this.localPC.setRemoteDescription(remoteDes); console.log(‘createAnswer => set local description’); const answer = await this.localPC.createAnswer(); console.log(createAnswer from remotePC: ${remoteDes.sdp}); await this.localPC.setLocalDescription(answer); console.log(‘createAnswer, setRemoteDescription’); fObj.sendMsgForVideoCall( {cid: this.state.myID, localDescription: this.localPC.localDescription}, ‘answer’, ); } catch (err) { console.error(Error while offering ${err}); } };`

Error from androind emulator

09-02 10:57:40.415 2121 2280 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String java.lang.String.toUpperCase(java.util.Locale)’ on a null object reference 09-02 10:57:40.415 2121 2280 E AndroidRuntime: at org.webrtc.SessionDescription$Type.fromCanonicalForm(SessionDescription.java:34) 09-02 10:57:40.415 2121 2280 E AndroidRuntime: at com.oney.WebRTCModule.WebRTCModule.peerConnectionSetRemoteDescriptionAsync(WebRTCModule.java:811) 09-02 10:57:40.415 2121 2280 E AndroidRuntime: at com.oney.WebRTCModule.WebRTCModule.lambda$peerConnectionSetRemoteDescription$17$WebRTCModule(WebRTCModule.java:800) 09-02 10:57:40.415 2121 2280 E AndroidRuntime: at com.oney.WebRTCModule.-$$Lambda$WebRTCModule$hxPcRQaZtSAbYntTvH4jzT2Ocgk.run(Unknown Source:8) 09-02 10:57:40.415 2121 2280 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 09-02 10:57:40.415 2121 2280 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 09-02 10:57:40.415 2121 2280 E AndroidRuntime: at java.lang.Thread.run(Thread.java:923) 09-02 10:57:40.417 2121 2121 I org.webrtc.Logging: EglRenderer: Initializing EglRenderer 09-02 10:57:40.418 512 2706 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2

  • React Native version: 0.64.2
  • react-native-webrtc version: 1.92.1
  • OS: Android
  • OS version:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:26 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
dlavrantoniscommented, Oct 2, 2022

After a closer look it’s apparent that there’s something weird in the library. Have a look at the constructor of RTCSessionDescription. It expects an “info” object with type as null.

export default class RTCSessionDescription {
    _sdp: string;
    _type: string | null;
    constructor(info?: {
        type: null;
        sdp: string;
    });
    get sdp(): string;
    get type(): string | null;
    toJSON(): {
        sdp: string;
        type: string | null;
    };
}

Later on in peerConnectionSetRemoteDescription (WebRTCModule.java file for android) a session description object is attempted to be constructed with this code:

SessionDescription sdp = new SessionDescription(
    SessionDescription.Type.fromCanonicalForm(sdpMap.getString("type")),
    sdpMap.getString("sdp")
);

This can never work since the getString will always assert cause the type is constructed as null. Not sure why the type is set to null during construction.

a quick fix is to set the type to what you want right after constructing an RTCSessionDescription object with e.g.

answerDescription._type = 'answer'

1reaction
fukemycommented, Aug 22, 2022

@yehyaumar can u explain more? Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

RTCPeerConnection.setRemoteDescription closing the app ...
createOffer() on other side. but RTCPeerConnection.setRemoteDescription was closing app abruptly without even any error.
Read more >
How to set remote description for a WebRTC caller in Chrome ...
How to set remote description for a WebRTC caller in Chrome without errors? ; Step 1: caller creates offer ; Step 2: caller...
Read more >
RTCPeerConnection.setRemoteDescription() - Web APIs | MDN
The RTCPeerConnection method setRemoteDescription() sets the specified session description as the remote peer's current offer or answer.
Read more >
RTCPeerConnection.setRemoteDescription()
A JavaScript Function which accepts no input parameters to be be called once the description has been successfully set. At that time, the...
Read more >
webRTC on iOS: Can't send SDP answer ...
Coding example for the question webRTC on iOS: Can't send SDP answer, RTCPeerConnection.setRemoteDescription() failed.
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