On some devices (specially Samsung) I have found the following error while establishing a P2P connection:
Error processing ICE candidate- Failed to set remote offer sdp: The order of m-lines in subsequent offer doesn't match order from previous offer/answer
If I establish the connection for the first time it works perfectly but if I try it a second time it fails until I wait some time, even if I force the P2P connection to close. This does not happen with Chrome for Android or every device.
My code before setting an Ice candidate:
var candidate = new RTCIceCandidate({
sdpMLineIndex: evt.sdpMLineIndex,
sdpMid : evt.sdpMid,
candidate : evt.candidate
});
peerConn.addIceCandidate(candidate, onSuccess, onFailure);
It seems that I wasn't cutting the local stream properly which made the camera and microphone look like they were still in use.
if(localstream){
localstream.getTracks()[0].stop();
localstream = null;
}
I think Samsung's layer makes Firefox act differently as it only happened on the Samsung devices from all the devices I tested.