The agent can end in a few cases where the process crashes, since it uses indices to candidates which has been removed.
Issue 1
https://github.com/webrtc-rs/rtc/blob/master/rtc-ice/src/agent/mod.rs#L736
if new_state == ConnectionState::Failed {
self.set_selected_pair(None);
self.delete_all_candidates(false);
}
this code does not reset the selected pairs, which means they now can point to invalid indexes in the candidate arrays.
Issue 2
https://github.com/webrtc-rs/rtc/blob/master/rtc-ice/src/agent/mod.rs#L1330
if let Ok(added) = self.add_remote_candidate(prflx_candidate)
&& added
{
remote_candidate_index = Some(self.remote_candidates.len() - 1);
}
add_remote_candidate can trigger a state change to failed, which clears the remote candidates (now the index becomes -1), because add_remote_candidate runs the contact() function which checks for timeouts.
There is a fix for these problems here: https://github.com/nabto/webrtc-rs-rtc/tree/ice_state_fail it defers the contact calls to the timeout handler and implements proper candidate pair cleanup.
Is it the preferred way to fix the issue?
The agent can end in a few cases where the process crashes, since it uses indices to candidates which has been removed.
Issue 1
https://github.com/webrtc-rs/rtc/blob/master/rtc-ice/src/agent/mod.rs#L736
this code does not reset the selected pairs, which means they now can point to invalid indexes in the candidate arrays.
Issue 2
https://github.com/webrtc-rs/rtc/blob/master/rtc-ice/src/agent/mod.rs#L1330
add_remote_candidate can trigger a state change to failed, which clears the remote candidates (now the index becomes -1), because add_remote_candidate runs the contact() function which checks for timeouts.
There is a fix for these problems here: https://github.com/nabto/webrtc-rs-rtc/tree/ice_state_fail it defers the contact calls to the timeout handler and implements proper candidate pair cleanup.
Is it the preferred way to fix the issue?