cordova-rtc / cordova-plugin-iosrtc

Cordova iOS plugin exposing the WebRTC W3C API
MIT License
690 stars 338 forks source link

catch NPEs when calling replaceTrack #780

Closed patrick-tresp closed 3 months ago

patrick-tresp commented 1 year ago

I have addressed the issue of Null Pointer Exceptions in the iosrtcPlugin#RTCPeerConnection_RTCRtpSender_replaceTrack() method. I am using this plugin in a capacitor project where it can lead to app crashes without checking for nil values before accessing their properties.

Early Existence Checks: I have introduced early existence checks to ensure that critical objects, such as pluginRTCPeerConnection and pluginRTCRptSender, are not nil before attempting to use them.

Graceful Handling of Missing Objects: In case any of these objects are not found, I now emit error messages with informative details to assist with debugging and troubleshooting.

Safety for Optional Values: I have utilized Swift's optional binding (if let) to safely unwrap and use optional values like pluginMediaStreamTrack.

hthetiot commented 1 year ago

Hello @patrick-tresp thank you for your PR, can you revert the version increment, it is made during release only. Then I will test and release.

hthetiot commented 1 year ago

Notice that next release will also include this fix for nil sender #770

patrick-tresp commented 1 year ago

Hello @patrick-tresp thank you for your PR, can you revert the version increment, it is made during release only. Then I will test and release.

nice, thank you ,reverted already.

hthetiot commented 1 year ago

Thx will for review fix. I will merge and attempt to release next week after testing.

hthetiot commented 10 months ago

Thank you @patrick-tresp , that why i dont close PR or Issues even after a while, you never know. I love the last commit 96be63b super clean. Let me know if you tested, an i will merge on master, then release ASAP.