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
176 stars 85 forks source link

InAPP Screen sharing not working for iOS due to missing dimesions #281

Closed seemantabiswas87 closed 7 months ago

seemantabiswas87 commented 7 months ago

Describe the bug When we try to do In APP screen sharing with the default instruction for iOS localParticipant.setScreenShare(enabled: true) It throws error as

LiveKitSDK : [LiveKit] LocalParticipant.publish(track:publishOptions:) [publish] failed LocalVideoTrack(sid: nil, name: screen_share, source: Source(rawValue: 3)), error: TrackError.timedOut unable to resolve dimensions

Also tried with

private func getScreenShareOptions() -> ScreenShareCaptureOptions {
      ScreenShareCaptureOptions(
          dimensions: Dimensions(width: 540, height: 960),
          fps: 25,
          useBroadcastExtension: false
      )
  }
  func startScreenShare() {
    Task {
      await MainActor.run {
//          self.room.localParticipant?.setScreenShare(enabled: true)
          let videoTrack = LocalVideoTrack.createInAppScreenShareTrack(name: "screen_share", options: getScreenShareOptions())
          let videoTrackPublication = self.room?.localParticipant?.publishVideoTrack(track: videoTrack)
          videoTrackPublication?.then({ track in
            print(track)
          }).catch({ error in
            print("Failed publish screenshare tracks...", error)
          })
      }
    }
  }

Same error as TrackError.timedOut unable to resolve dimensions SDK Version 1.1.3 and 1.1.2

iOS 15.0+

Steps to Reproduce Steps to reproduce the behavior.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Logs

✅ Message LocalParticipant.publish(track:publishOptions:) [publish] LocalVideoTrack(sid: nil, name: screenshare, source: Source(rawValue: 3)) options: nil...
✅ Message InAppScreenCapturer.init(delegate:) startStopCounter 0 -> 1
✅ Message MulticastDelegate<VideoCapturerDelegate>.notify(label:_:) [notify] capturer.didUpdate state: CapturerState(rawValue: 1)
LocalParticipant.publish(track:publishOptions:) [publish] LocalVideoTrack(sid: nil, name: screenshare, source: Source(rawValue: 3)) options: nil...
InAppScreenCapturer.init(delegate:) startStopCounter 0 -> 1
MulticastDelegate<VideoCapturerDelegate>.notify(label:_:) [notify] capturer.didUpdate state: CapturerState(rawValue: 1)
10.3.0 - [FirebaseAnalytics][I-ACS800014] Cannot get flag for unregistered flag. SDK name, flag name: app_measurement, session_stitching_token_feature_enabled
The request of a upload task should not contain a body or a body stream, use `upload(for:fromFile:)`, `upload(for:from:)`, or supply the body stream through the `urlSession(_:needNewBodyStreamForTask:)` delegate method.
nw_path_necp_check_for_updates Failed to copy updated result (22)
✅ Message LocalParticipant.publish(track:publishOptions:) [publish] waiting for dimensions to resolve...
✅ Message Completer<Dimensions>.wait(on:_:throw:) [publish] wait created...
LocalParticipant.publish(track:publishOptions:) [publish] waiting for dimensions to resolve...
Completer<Dimensions>.wait(on:_:throw:) [publish] wait created...
✅ Message LocalParticipant.publish(track:publishOptions:) [publish] failed LocalVideoTrack(sid: nil, name: screenshare, source: Source(rawValue: 3)), error: TrackError.timedOut unable to resolve dimensions
LocalParticipant.publish(track:publishOptions:) [publish] failed LocalVideoTrack(sid: nil, name: screenshare, source: Source(rawValue: 3)), error: TrackError.timedOut unable to resolve dimensions
InAppScreenCapturer.init(delegate:) startStopCounter 1 -> 0
LocalVideoTrack.deinit sid: nil
MulticastDelegate<VideoCapturerDelegate>.notify(label:_:) [notify] capturer.didUpdate state: CapturerState(rawValue: 0)
✅ Message InAppScreenCapturer.init(delegate:) startStopCounter 1 -> 0
✅ Message LocalVideoTrack.deinit sid: nil
✅ Message MulticastDelegate<VideoCapturerDelegate>.notify(label:_:) [notify] capturer.didUpdate state: CapturerState(rawValue: 0)
gtarashuk commented 7 months ago

I'm facing the same issue

seemantabiswas87 commented 7 months ago

The issue was the window frame was not getting detected by RPScreenRecorder. Fixed locally and working now.

hiroshihorie commented 7 months ago

Hello @seemantabiswas87 , could you share the fix ?

seemantabiswas87 commented 7 months ago

Hello @seemantabiswas87 , could you share the fix ?

@hiroshihorie It was not an issue in Livekit SDK, Our existing PIP wasn't supporting the RPScreenRecorder to record the screen. We are trying to fix that.