livekit / client-sdk-swift

LiveKit Swift Client SDK. Easily build live audio or video experiences into your mobile app, game or website.
https://livekit.io
Apache License 2.0
174 stars 84 forks source link

Un/publishing video track on macOS is broken #331

Open creativecbr opened 5 months ago

creativecbr commented 5 months ago

Describe the Bug

When streaming the display and subsequently shutting it down, the streaming automatically stops. If attempting to unpublish the display track, it returns an error stating that the track either does not exist or is already stopped. However, when the display turns back on, it does not automatically republish. When attempting to publish a newly created track with the same display ID, an error message is received:

'The same track couldn't be used, error: Timed out, trying to initialize a new one.'

SDK Version I've identified a bug in the main branch of macOS Swift's LiveKit version. This issue did not occur in the released version 1.16.

iOS/macOS Version macOS 12.7.1, macOS 14.2.1.

Steps to Reproduce

  1. Set the display you want to use for screen sharing as the main display in Settings -> Displays.
  2. Publish a video track from your screen; share the screen on macOS (using your sample app, for instance).
  3. Turn off the display using the physical button; streaming continues.
  4. Attempt to stop the published track using publication - an error is encountered.
  5. Turn on the display.
  6. Attempt to gather a track from this display and publish it in the room - an error "can't publish an already published track" is received, and the stream is not resumed.

Just changing a video stream setting will resume streaming - for example, logging with "setting layer to," and then streaming starts again.

Expected Behavior Unpublishing a track that is already stopped should work, and publishing the same display track should succeed.