Skip to content
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

Don't terminate PeerConnection after moving to the failed state #202

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

mickel8
Copy link
Member

@mickel8 mickel8 commented Mar 3, 2025

We have been terminating PeerConnection after it moved to the failed state. While this approach was easy to implement, it had two drawbacks:

  • once PeerConnection failed, we couldn't gather stats via get_stats as the process was no longer alive
  • we couldn't perform ICE restart

This PR keeps peer connection alive even when it moves to the failed state. This is pretty big breaking change as a lot of our examples and demo apps relies on linking to the PeerConnection process and waiting until it crashes.

Things to note:

  • when PC moves to the failed state (no matter this is because of DTLS or ICE transport fails), most of the operations are still allowed. E.g. user can still successfully call addTrack, addTransceiver or createOffer even though the connection might not be able to restart (that's the case when DTLS fails, or at least we don't support DTLS restart).
  • sending RTP, RTCP, or data via DataChannel in state failed is silently discarded - silently because there is a RC between calling send_rtp and others, and moving to the failed state so such a log could appear pretty often
  • closing web browser's peer connection no longer terminates our peer connection process. So far, closing web browser's peer connection was causing DTLS alert (probably close_notify) that was resulting in the termination of DTLS transport process. From now, we just move DTLS transport to the failed state

Relevant specs:

Copy link

codecov bot commented Mar 3, 2025

Codecov Report

Attention: Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.

Project coverage is 88.51%. Comparing base (241931e) to head (fff797c).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
lib/ex_webrtc/peer_connection.ex 25.00% 3 Missing ⚠️
lib/ex_webrtc/dtls_transport.ex 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #202      +/-   ##
==========================================
+ Coverage   88.38%   88.51%   +0.12%     
==========================================
  Files          49       49              
  Lines        2531     2533       +2     
==========================================
+ Hits         2237     2242       +5     
+ Misses        294      291       -3     
Files with missing lines Coverage Δ
lib/ex_webrtc/dtls_transport.ex 84.17% <60.00%> (-1.23%) ⬇️
lib/ex_webrtc/peer_connection.ex 86.40% <25.00%> (+0.14%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 241931e...fff797c. Read the comment docs.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mickel8 mickel8 force-pushed the self-crash branch 6 times, most recently from d689e31 to 0e5fb08 Compare March 4, 2025 12:56
@@ -1283,21 +1301,15 @@ defmodule ExWebRTC.PeerConnection do
@impl true
def handle_info({:ex_ice, _from, {:connection_state_change, new_ice_state}}, state) do
state = %{state | ice_state: new_ice_state}
notify(state.owner, {:ice_connection_state_change, new_ice_state})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be fired before connection state change

@mickel8 mickel8 marked this pull request as ready for review March 4, 2025 13:09
@mickel8 mickel8 requested review from sgfn and brzep March 4, 2025 13:09
@mickel8 mickel8 merged commit 13e9aae into master Mar 6, 2025
3 checks passed
@mickel8 mickel8 deleted the self-crash branch March 6, 2025 09:51
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.

1 participant