react-native-webrtc: [iOS] dataChannelDidChangeState crash

Hello, after this PR https://github.com/react-native-webrtc/react-native-webrtc/pull/919 (issue https://github.com/react-native-webrtc/react-native-webrtc/issues/917) I have a crash when a connection is made. Specifically the crash occurs in dataChannelDidChangeState in RTCDataChannel.m : a NSDictionnary is created with the channel id but channel.originDataChannelId can be null. Note that it doesn’t always happen so it looks like a race condition.

Expected behavior

Connecting to a peer should not make the app crash randomly on iOS.

Platform information

  • React Native version: 0.63.4
  • Plugin version: 1.89.1
  • OS: iOS
  • OS version: 14

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 16 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I have a started the refactor for fixing this, hopefully I can have a PR tomorrow.

The PR is now ready and the test @ibc posted works just fine. I also fixed some more corner cases when closing datachannels.

I was wrong, it’s not set early enough. It starts at -1 and gets set once negotiated. So in the meantime you have a DC with id -1. And if you create 2 of them… well you have a problem.