Skip to content

Conversation

@ipavlidakis
Copy link
Contributor

📝 Summary

FastReconnection seems to have been broken due to ICE candidates not being applied correctly for the subscriber.

🛠 Implementation

We use this revision as an opportunity to align the fast reconnection process to the latest requirements from the SFU. Namely the changes are:

  • During fast reconnection, we only restartICE for the publisher connection. That should trigger a negotiation with iceConstraints.
  • During fast reconnection, when sending the joinRequest we always use temporary connections to generate the SDP rather than using any existing ones.
  • RestartICE on subscriber connection doesn't invoke the RTCPeerConnection.restartICE method but instead sends the iceRestart RPC call to the SFU. The SFU then will send a new subscriberOffer that will trigger the flow to update the ice state on the subscriber connection.

🧪 Manual Testing Notes

  • Join a call
  • Disable wifi for a second and enable it again
  • You should be connected back and all tracks (local and remote) should be active in a reasonable amount of time
  • Start screensharing
  • Disable wifi for a second and enable it again
  • You should be connected back and all tracks (local and remote) should be active in a reasonable amount of time

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change follows zero ⚠️ policy (required)
  • This change should receive manual QA
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (tutorial, CMS)

@ipavlidakis ipavlidakis added bug Something isn't working enhancement New feature or request labels Apr 2, 2025
@ipavlidakis ipavlidakis self-assigned this Apr 2, 2025
@ipavlidakis ipavlidakis requested a review from a team as a code owner April 2, 2025 08:11
@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Apr 2, 2025

SDK Size

title develop branch diff status
StreamVideo 7.6 MB 7.6 MB 0 KB 🟢
StreamVideoSwiftUI 2.09 MB 2.09 MB 0 KB 🟢
StreamVideoUIKit 2.23 MB 2.23 MB 0 KB 🟢
StreamWebRTC 9.85 MB 9.85 MB 0 KB 🟢

Copy link
Contributor

@martinmitrevski martinmitrevski left a comment

Choose a reason for hiding this comment

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

Looks good 👍 Let's do some testing today and tomorrow before merging it.

fileName: file,
lineNumber: line
)
if error is CancellationError { /* No-op */ }
Copy link
Contributor

Choose a reason for hiding this comment

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

should we maybe add a debug log here that the task was cancelled? Also the formatting looks weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That wouldn't be necessary. Cancelled tasks aren't errors but it means that the operation is invalid (most probably because the initiator of the task has e.g. deallocated). For formatting I just using that kind of formatting across the code base as i won't to make the cancellationError skipping as minimal as possible. Happy to expand it in 3 lines if you want to.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant a debug log, not an error log

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still don't think it's necessary. This is lowest component for executing the tasks. The only way to get cancelled tasks is to do it explicitely or deallocate the object. In both options the higher level code should log.

@github-actions
Copy link

github-actions bot commented Apr 2, 2025

Public Interface

 public final class SerialActorQueue: Sendable  
-   public func async(file: StaticString = #file,functionName: StaticString = #function,line: UInt = #line,_ block: @Sendable @escaping () async throws -> Void)
+   public func cancelAll()
-   public func sync(_ block: @Sendable @escaping () async throws -> Void)async throws
+   public func async(file: StaticString = #file,functionName: StaticString = #function,line: UInt = #line,_ block: @Sendable @escaping () async throws -> Void)
+   public func sync(_ block: @Sendable @escaping () async throws -> Void)async throws

@github-actions
Copy link

github-actions bot commented Apr 2, 2025

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@ipavlidakis ipavlidakis force-pushed the fix/fast-reconnection branch from b1ffa99 to 17da89a Compare April 2, 2025 10:40
@github-actions
Copy link

github-actions bot commented Apr 2, 2025

Public Interface

 public final class SerialActorQueue: Sendable  
-   public func async(file: StaticString = #file,functionName: StaticString = #function,line: UInt = #line,_ block: @Sendable @escaping () async throws -> Void)
+   public func cancelAll()
-   public func sync(_ block: @Sendable @escaping () async throws -> Void)async throws
+   public func async(file: StaticString = #file,functionName: StaticString = #function,line: UInt = #line,_ block: @Sendable @escaping () async throws -> Void)
+   public func sync(_ block: @Sendable @escaping () async throws -> Void)async throws

@ipavlidakis ipavlidakis force-pushed the fix/fast-reconnection branch from 17da89a to 0aba5f7 Compare April 3, 2025 14:21
@github-actions
Copy link

github-actions bot commented Apr 3, 2025

Public Interface

 public final class SerialActorQueue: Sendable  
-   public func async(file: StaticString = #file,functionName: StaticString = #function,line: UInt = #line,_ block: @Sendable @escaping () async throws -> Void)
+   public func cancelAll()
-   public func sync(_ block: @Sendable @escaping () async throws -> Void)async throws
+   public func async(file: StaticString = #file,functionName: StaticString = #function,line: UInt = #line,_ block: @Sendable @escaping () async throws -> Void)
+   public func sync(_ block: @Sendable @escaping () async throws -> Void)async throws

/// Handles a JoinResponse event.
///
/// - Parameter event: The JoinResponse event to handle.
private func handleJoinResponse(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We remove the handling from the SFUEventAdapter as the processing of the JoinResponse happens in WebRTCCoordinator+Joining. Having it here causes duplicated processing of the event.

@github-actions
Copy link

github-actions bot commented Apr 3, 2025

Public Interface

 public final class SerialActorQueue: Sendable  
-   public func async(file: StaticString = #file,functionName: StaticString = #function,line: UInt = #line,_ block: @Sendable @escaping () async throws -> Void)
+   public func cancelAll()
-   public func sync(_ block: @Sendable @escaping () async throws -> Void)async throws
+   public func async(file: StaticString = #file,functionName: StaticString = #function,line: UInt = #line,_ block: @Sendable @escaping () async throws -> Void)
+   public func sync(_ block: @Sendable @escaping () async throws -> Void)async throws

@github-actions
Copy link

github-actions bot commented Apr 4, 2025

Public Interface

 public final class SerialActorQueue: Sendable  
-   public func async(file: StaticString = #file,functionName: StaticString = #function,line: UInt = #line,_ block: @Sendable @escaping () async throws -> Void)
+   public func cancelAll()
-   public func sync(_ block: @Sendable @escaping () async throws -> Void)async throws
+   public func async(file: StaticString = #file,functionName: StaticString = #function,line: UInt = #line,_ block: @Sendable @escaping () async throws -> Void)
+   public func sync(_ block: @Sendable @escaping () async throws -> Void)async throws

@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 4, 2025

@ipavlidakis ipavlidakis enabled auto-merge (squash) April 7, 2025 10:31
@ipavlidakis ipavlidakis disabled auto-merge April 7, 2025 10:31
@ipavlidakis ipavlidakis merged commit 5e4667d into develop Apr 7, 2025
14 checks passed
@ipavlidakis ipavlidakis deleted the fix/fast-reconnection branch April 7, 2025 10:31
@Stream-SDK-Bot Stream-SDK-Bot mentioned this pull request Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants