-
Notifications
You must be signed in to change notification settings - Fork 156
Do not leak Sendable extensions to consumers #848
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| // MARK: Collections | ||
|
|
||
| extension NSHashTable: @unchecked Swift.Sendable {} // cannot specify Obj-C generics |
There was a problem hiding this comment.
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.
| import Foundation | ||
|
|
||
| /// A thin unchecked sendable wrapper around NSMapTable. | ||
| final class MapTable<KeyType, ObjectType>: @unchecked Sendable where KeyType: AnyObject, ObjectType: AnyObject { |
There was a problem hiding this comment.
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.
|
|
||
| extension AVCaptureDevice: @unchecked Swift.Sendable {} | ||
| extension AVCaptureDevice.Format: @unchecked Swift.Sendable {} | ||
| extension CVPixelBuffer: @unchecked Swift.Sendable {} |
There was a problem hiding this comment.
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
| extension AVCaptureDevice: @unchecked Swift.Sendable {} | ||
| extension AVCaptureDevice.Format: @unchecked Swift.Sendable {} |
There was a problem hiding this comment.
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
LiveKit currently marks multiple types that are not thread-safe as being
Sendable. These extensions mean that consumer's applications also treat these types asSendable, 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.