Skip to content

Conversation

renefloor
Copy link
Collaborator

Android is the only place where we don't expect local description to be null, which can lead to a crash on sdp.description.
Other parts (iOS and Flutter) already expect local description to be nullable.

Existing iOS code:

    if (peerConnection) {
      RTCSessionDescription* sdp = peerConnection.localDescription;
      if (nil == sdp) {
        result(nil);
      } else {
        NSString* type = [RTCSessionDescription stringForType:sdp.type];
        result(@{@"sdp" : sdp.sdp, @"type" : type});
      }
    } 

Existing Flutter code:

      final response =
          await WebRTC.invokeMethod('getLocalDescription', <String, dynamic>{
        'peerConnectionId': _peerConnectionId,
      });

      if (null == response) {
        return null;
      }
      String sdp = response['sdp'];
      String type = response['type'];
      return RTCSessionDescription(sdp, type);

@renefloor renefloor merged commit 5504fd0 into main Jun 20, 2025
14 of 16 checks passed
@renefloor renefloor deleted the fix/null-check-local-description branch June 20, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants