Handle Thread Safety and Concurrency
mainThe LiveKit Swift SDK follows these threading rules:
- UI Components: All operations on
VideoView(reading/writing properties, etc.) must be performed on themainthread. - Core Classes: Most other core classes can be accessed from any thread.
- Delegates: SDK delegates are called on an internal SDK thread. You must ensure any UI updates triggered by delegates are dispatched to the main thread using
@MainActororDispatchQueue.main.async. - Swift 6: The SDK is compiled with Swift 6.1 and full support for strict concurrency. Apps using Swift 6 language mode can access LiveKit classes without needing
@preconcurrencyor@unchecked Sendable.