Skip to content

[Bug] WebRTC Connection Fails: SDP m-lines Order Mismatch in @livekit/react-native #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
franco820711 opened this issue Mar 27, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@franco820711
Copy link

[Bug] Failed to Set Remote Answer SDP Due to m-lines Order Mismatch on Android 13

Describe the bug

When attempting to set a remote answer SDP in a WebRTC connection, the process fails with the error: Failed to set remote answer sdp: The order of m-lines in answer doesn't match order in offer. Rejecting answer. This prevents the WebRTC connection from being established properly.

To Reproduce

Steps to reproduce the behavior:

  1. Set up a WebRTC peer connection using @livekit/react-native and @livekit/react-native-webrtc.
  2. Join a room (e.g., room-452a6def) with a participant (e.g., test).
  3. Attempt to set the remote answer SDP received from the server.
  4. See the error logged in the console.

Expected behavior

The remote answer SDP should be successfully applied, allowing the WebRTC connection to proceed without errors.

Screenshots

Image

Device Info:

  • Device: Xiaomi M2101K6G (Redmi Note 10 Pro)
  • OS: Android 13

Dependencies Info:

  • @livekit/react-native: ^2.6.5
  • @livekit/react-native-expo-plugin: ^1.0.1
  • @livekit/react-native-webrtc: ^125.0.9

Additional context

The issue seems to stem from a mismatch in the m-lines order between the offer and answer SDPs. Below are the relevant logs and SDP details:

Observations:

  • The answer SDP contains only one m-line (m=application for a data channel), which might not align with the offer SDP if it includes additional media types (e.g., audio or video).
  • This issue could be related to how @livekit/react-native or @livekit/react-native-webrtc handles SDP negotiation on Android 13.
  • Note: While the error appears in development logs, it does not currently block functionality (e.g., joining and using the room). However, this has not been tested in a production environment, so potential impacts remain unknown.
@franco820711 franco820711 added the bug Something isn't working label Mar 27, 2025
@sanduluca
Copy link

I have the same issue.

logcat

Logcat

03-30 15:02:24.048  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 1 createAnswer +3ms
03-30 15:02:24.075  2268  2615 I ReactNativeJS: 'publishing track', { room: '8199d8f2e0593b320d46d4530cc79a891ed',
03-30 15:02:24.075  2268  2615 I ReactNativeJS:   roomID: 'RM_pYkeAVHKowUR',
03-30 15:02:24.075  2268  2615 I ReactNativeJS:   participant: 'Sandu',
03-30 15:02:24.075  2268  2615 I ReactNativeJS:   pID: 'PA_cFSJEkCGv2Mp',
03-30 15:02:24.075  2268  2615 I ReactNativeJS:   trackID: undefined,
03-30 15:02:24.075  2268  2615 I ReactNativeJS:   source: 'microphone',
03-30 15:02:24.075  2268  2615 I ReactNativeJS:   muted: false,
03-30 15:02:24.075  2268  2615 I ReactNativeJS:   enabled: true,
03-30 15:02:24.075  2268  2615 I ReactNativeJS:   kind: 'audio',
03-30 15:02:24.075  2268  2615 I ReactNativeJS:   streamID: '4478bce2-f5ab-4bfb-aabe-d324ded16e6e',
03-30 15:02:24.075  2268  2615 I ReactNativeJS:   streamTrackID: '4478bce2-f5ab-4bfb-aabe-d324ded16e6e' }
03-30 15:02:24.100  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 addTransceiver +52ms
03-30 15:02:24.131  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 createOffer OK +32ms
03-30 15:02:24.139  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 setLocalDescription +8ms
03-30 15:02:24.141  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 1 setLocalDescription +2ms
03-30 15:02:24.147  2268  2619 I org.webrtc.Logging: NetworkMonitor: Start monitoring with native observer -5476376671632052496 fieldTrialsString: 
03-30 15:02:24.151  1723  3137 D CompatibilityChangeReporter: Compat change id reported: 266524688; UID 12345; state: ENABLED
03-30 15:02:24.152  2268  2619 W org.webrtc.Logging: NetworkMonitorAutoDetect: Unable to obtain permission to request a cellular network.
03-30 15:02:24.154  1723  3137 D CompatibilityChangeReporter: Compat change id reported: 319212206; UID 12345; state: ENABLED
03-30 15:02:24.155  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 createOffer +14ms
03-30 15:02:24.159  2268  2883 I org.webrtc.Logging: NetworkMonitorAutoDetect: Network handle: 450082295821 becomes available: 104
03-30 15:02:24.160  1723  2487 D ConnectivityService: NetReassign [no changes] [c 0] [a 1] [i 4]
03-30 15:02:24.161  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceGatheringChangeGATHERING
03-30 15:02:24.165  2268  2883 I org.webrtc.Logging: NetworkMonitorAutoDetect: handle: 450082295821 capabilities changed: [ Transports: WIFI Capabilities: NOT_METERED&INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN&VALIDATED&NOT_ROAMING&FOREGROUND&NOT_CONGESTED&NOT_SUSPENDED&NOT_VCN_MANAGED LinkUpBandwidth>=41226Kbps LinkDnBandwidth>=36556Kbps TransportInfo: <SSID: <unknown ssid>, BSSID: 02:00:00:00:00:00, MAC: 02:00:00:00:00:00, IP: /192.168.0.8, Security type: 2, Supplicant state: COMPLETED, Wi-Fi standard: 11n, RSSI: -65, Link speed: 144Mbps, Tx Link speed: 144Mbps, Max Supported Tx Link speed: 144Mbps, Rx Link speed: 65Mbps, Max Supported Rx Link speed: 144Mbps, Frequency: 2417MHz, Net ID: -1, Metered hint: false, score: 60, isUsable: true, CarrierMerged: false, SubscriptionId: -1, IsPrimary: -1, Trusted: true, Restricted: false, Ephemeral: false, OEM paid: false, OEM private: false, OSU AP: false, FQDN: <none>, Provider friendly name: <none>, Requesting package name: <none><none>MLO Information: , Is TID-To-Link negotiation supported by the AP: false, AP MLD Address: <none>, AP MLO Link Id: <none>, AP MLO Affiliated links: <none>, Vendor Data: <none>> SignalStrength: -65 UnderlyingNetworks: Null]
03-30 15:02:24.167  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceCandidate
03-30 15:02:24.168  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceCandidate
03-30 15:02:24.168  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceGatheringChangeGATHERING
03-30 15:02:24.169  2268  2883 I org.webrtc.Logging: NetworkMonitorAutoDetect: handle: 450082295821 link properties changed
03-30 15:02:24.170  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceCandidate
03-30 15:02:24.170  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceCandidate
03-30 15:02:24.173  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 setLocalDescription OK +18ms
03-30 15:02:24.177  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 1 setLocalDescription OK +4ms
03-30 15:02:24.194  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 createOffer OK +16ms
03-30 15:02:24.202  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 setLocalDescription +9ms
03-30 15:02:24.206  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceCandidate
03-30 15:02:24.207  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceCandidate
03-30 15:02:24.209  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 setLocalDescription OK +6ms
03-30 15:02:24.209  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceCandidate
03-30 15:02:24.209  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceCandidate
03-30 15:02:24.233  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 setRemoteDescription +24ms
03-30 15:02:24.241  2268  2615 W ReactNativeJS: 'not able to set answer, falling back to unmodified sdp', { room: '8199d8f2e0593b320d46d4530cc79a891ed',
03-30 15:02:24.241  2268  2615 W ReactNativeJS:   roomID: 'RM_pYkeAVHKowUR',
03-30 15:02:24.241  2268  2615 W ReactNativeJS:   participant: 'Sandu',
03-30 15:02:24.241  2268  2615 W ReactNativeJS:   pID: 'PA_cFSJEkCGv2Mp',
03-30 15:02:24.241  2268  2615 W ReactNativeJS:   error: 
03-30 15:02:24.241  2268  2615 W ReactNativeJS:    { [Error: Failed to set remote answer sdp: The order of m-lines in answer doesn't match order in offer. Rejecting answer.]
03-30 15:02:24.241  2268  2615 W ReactNativeJS:      nativeStackAndroid: [],
03-30 15:02:24.241  2268  2615 W ReactNativeJS:      userInfo: null,
03-30 15:02:24.241  2268  2615 W ReactNativeJS:      code: 'E_OPERATION_ERROR' },
03-30 15:02:24.241  2268  2615 W ReactNativeJS:   sdp: 'v=0\r\no=- 7202846363982893381 1743336143 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=extmap-allow-mixed\r\na=ice-lite\r\na=fingerprint:sha-256 2E:CE:AB:6F:15:F4:DD:FD:35:CD:18:52:55:B8:7A:D5:15:36:11:E5:E7:B1:4C:6F:38:C2:A3:5B:92:1D:53:5E\r\na=group:BUNDLE 0\r\na=msid-semantic:WMS*\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=setup:active\r\na=mid:0\r\na=sendrecv\r\na=ice-ufrag:kgIEpfbdQhLShepf\r\na=ice-pwd:jdRsnjUmmXKLkCivZJEWyWHIPPhywmjz\r\na=sctp-port:5000\r\n' }
03-30 15:02:24.242  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 setRemoteDescription +9ms
03-30 15:02:24.243  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceCandidate
03-30 15:02:24.251  2268  2615 E ReactNativeJS: 'unable to set answer', { room: '8199d8f2e0593b320d46d4530cc79a891ed',
03-30 15:02:24.251  2268  2615 E ReactNativeJS:   roomID: 'RM_pYkeAVHKowUR',
03-30 15:02:24.251  2268  2615 E ReactNativeJS:   participant: 'Sandu',
03-30 15:02:24.251  2268  2615 E ReactNativeJS:   pID: 'PA_cFSJEkCGv2Mp',
03-30 15:02:24.251  2268  2615 E ReactNativeJS:   fields: 
03-30 15:02:24.251  2268  2615 E ReactNativeJS:    { error: 'Failed to set remote answer sdp: The order of m-lines in answer doesn\'t match order in offer. Rejecting answer.',
03-30 15:02:24.251  2268  2615 E ReactNativeJS:      sdp: 'v=0\r\no=- 7202846363982893381 1743336143 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=msid-semantic:WMS*\r\na=fingerprint:sha-256 2E:CE:AB:6F:15:F4:DD:FD:35:CD:18:52:55:B8:7A:D5:15:36:11:E5:E7:B1:4C:6F:38:C2:A3:5B:92:1D:53:5E\r\na=ice-lite\r\na=extmap-allow-mixed\r\na=group:BUNDLE 0\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=setup:active\r\na=mid:0\r\na=sendrecv\r\na=sctp-port:5000\r\na=ice-ufrag:kgIEpfbdQhLShepf\r\na=ice-pwd:jdRsnjUmmXKLkCivZJEWyWHIPPhywmjz\r\n' } }
03-30 15:02:24.314  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 setRemoteDescription +72ms
03-30 15:02:24.339  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 setRemoteDescription OK +25ms
03-30 15:02:24.339  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 addIceCandidate +1ms
03-30 15:02:24.341  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 addIceCandidate +1ms
03-30 15:02:24.341  2268  2621 D com.oney.WebRTCModule.WebRTCModule: onIceCandidate
03-30 15:02:24.342  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 addIceCandidate +1ms
03-30 15:02:24.343  2268  2615 I ReactNativeJS: rn-webrtc:pc:DEBUG 0 addIceCandidate +2ms
03-30 15:02:24.364  2268  2615 I ReactNativeJS: 'connecting', undefined
03-30 15:02:24.370  2268  2615 I ReactNativeJS: 'connecting', undefined

@Genening
Copy link

Genening commented May 5, 2025

I have the same issue.

Console Log

console log
console.js:654 unable to set answer 
{room: '1746437658417', roomID: 'RM_9W3wXg8o5yUu', participant: 'testUser', pID: 'PA_wMGYw9HPJmnP', fields: {…}}
fields
: 
error
: 
"Failed to set remote answer sdp: The order of m-lines in answer doesn't match order in offer. Rejecting answer."
sdp
: 
"v=0\r\no=- 8549255068889549517 1746437721 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=msid-semantic:WMS*\r\na=fingerprint:sha-256 21:7B:FB:40:14:65:CB:CA:48:B3:7B:E5:8C:41:0D:E3:79:AB:B0:D6:CC:6A:C1:D4:AF:3F:4F:B1:B9:07:AD:9F\r\na=extmap-allow-mixed\r\na=group:BUNDLE 0\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=setup:active\r\na=mid:0\r\na=sendrecv\r\na=sctp-port:5000\r\na=ice-ufrag:aNgUwzjeCzkxUljg\r\na=ice-pwd:xzfImMHNhxjFreLzeVPNJzFbcaCzVXql\r\n"
[[Prototype]]
: 
constructor
: 
ƒ Object()
hasOwnProperty
: 
ƒ hasOwnProperty()
isPrototypeOf
: 
ƒ isPrototypeOf()
propertyIsEnumerable
: 
ƒ propertyIsEnumerable()
toLocaleString
: 
ƒ toLocaleString()
toString
: 
ƒ toString()
valueOf
: 
ƒ valueOf()
__defineGetter__
: 
ƒ __defineGetter__()
__defineSetter__
: 
ƒ __defineSetter__()
__lookupGetter__
: 
ƒ __lookupGetter__()
__lookupSetter__
: 
ƒ __lookupSetter__()
__proto__
: 
(…)
get __proto__
: 
ƒ __proto__()
set __proto__
: 
ƒ __proto__()
pID
: 
"PA_wMGYw9HPJmnP"
participant
: 
"testUser"
room
: 
"1746437658417"
roomID
: 
"RM_9W3wXg8o5yUu"
[[Prototype]]
: 
constructor
: 
ƒ Object()
hasOwnProperty
: 
ƒ hasOwnProperty()
isPrototypeOf
: 
ƒ isPrototypeOf()
propertyIsEnumerable
: 
ƒ propertyIsEnumerable()
toLocaleString
: 
ƒ toLocaleString()
toString
: 
ƒ toString()
valueOf
: 
ƒ valueOf()
__defineGetter__
: 
ƒ __defineGetter__()
__defineSetter__
: 
ƒ __defineSetter__()
__lookupGetter__
: 
ƒ __lookupGetter__()
__lookupSetter__
: 
ƒ __lookupSetter__()
__proto__
: 
(…)
get __proto__
: 
ƒ __proto__()
set __proto__
: 
ƒ __proto__()
length
: 
1
name
: 
"set __proto__"
[[Prototype]]
: 
ƒ ()

@syedfaheem27
Copy link

Any fixes on this bug. I have got the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants