diff --git a/.changes/single-peer-connection-by-default b/.changes/single-peer-connection-by-default new file mode 100644 index 000000000..a9d55907b --- /dev/null +++ b/.changes/single-peer-connection-by-default @@ -0,0 +1 @@ +minor type="changed" "`RoomOptions.singlePeerConnection` now defaults to `true`, matching client-sdk-js and rust-sdks: one ICE/DTLS handshake instead of two, and the publisher offer travels with the JOIN request. Measured ~17% off the post-signal connect phase against LiveKit Cloud. Servers older than LiveKit OSS 1.9.2 fall back to the legacy dual peer connection path automatically; pass `singlePeerConnection: false` to opt out" diff --git a/Sources/LiveKit/Types/Options/RoomOptions.swift b/Sources/LiveKit/Types/Options/RoomOptions.swift index a00b7c0f9..3ac495619 100644 --- a/Sources/LiveKit/Types/Options/RoomOptions.swift +++ b/Sources/LiveKit/Types/Options/RoomOptions.swift @@ -62,7 +62,13 @@ public final class RoomOptions: NSObject, Sendable, Loggable { /// Use a single peer connection for both publishing and subscribing. /// - /// - Note: Requires LiveKit Cloud or LiveKit OSS >= 1.9.2. + /// Defaults to `true`, matching client-sdk-js and rust-sdks. One connection means one ICE and + /// DTLS handshake instead of two, and it is the only mode that can carry the publisher offer + /// in the JOIN request — which removes an offer/answer round trip from the connect path. + /// + /// - Note: Requires LiveKit Cloud or LiveKit OSS >= 1.9.2. Against an older server the SDK + /// falls back to the legacy dual peer connection path automatically, so setting this has no + /// effect there beyond one extra failed request. public let singlePeerConnection: Bool override public init() { @@ -79,7 +85,7 @@ public final class RoomOptions: NSObject, Sendable, Loggable { e2eeOptions = nil encryptionOptions = nil reportRemoteTrackStatistics = false - singlePeerConnection = false + singlePeerConnection = true } public init(defaultCameraCaptureOptions: CameraCaptureOptions = CameraCaptureOptions(), @@ -95,7 +101,7 @@ public final class RoomOptions: NSObject, Sendable, Loggable { e2eeOptions: E2EEOptions? = nil, encryptionOptions: EncryptionOptions? = nil, reportRemoteTrackStatistics: Bool = false, - singlePeerConnection: Bool = false) + singlePeerConnection: Bool = true) { self.defaultCameraCaptureOptions = defaultCameraCaptureOptions self.defaultScreenShareCaptureOptions = defaultScreenShareCaptureOptions