Skip to content

Conversation

@dfed
Copy link

@dfed dfed commented Nov 20, 2025

LiveKit currently marks multiple types that are not thread-safe as being Sendable. These extensions mean that consumer's applications also treat these types as Sendable, which can lead to thread-safety bugs.

This PR removes the Sendable extensions without adding new warnings. This is accomplished by utilizing internal wrapper types that are marked as @unchecked Sendable.


// MARK: Collections

extension NSHashTable: @unchecked Swift.Sendable {} // cannot specify Obj-C generics
Copy link
Author

Choose a reason for hiding this comment

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

This extension was not used.

@dfed dfed marked this pull request as ready for review November 20, 2025 19:34
import Foundation

/// A thin unchecked sendable wrapper around NSMapTable.
final class MapTable<KeyType, ObjectType>: @unchecked Sendable where KeyType: AnyObject, ObjectType: AnyObject {
Copy link
Author

Choose a reason for hiding this comment

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

I did not implement every method on NSMapTable here. Just ones that were used.

@hiroshihorie hiroshihorie requested a review from pblazej November 20, 2025 20:29

extension AVCaptureDevice: @unchecked Swift.Sendable {}
extension AVCaptureDevice.Format: @unchecked Swift.Sendable {}
extension CVPixelBuffer: @unchecked Swift.Sendable {}
Copy link
Author

Choose a reason for hiding this comment

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

I worked around this one locally – no need for a global change

Comment on lines 57 to 58
extension AVCaptureDevice: @unchecked Swift.Sendable {}
extension AVCaptureDevice.Format: @unchecked Swift.Sendable {}
Copy link
Author

Choose a reason for hiding this comment

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

These two are effectively sendable per documentation, so I left them

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