twilio / video-quickstart-ios

Twilio Video Quickstart for iOS
https://www.twilio.com/docs/api/video
MIT License
457 stars 177 forks source link

App has stuck when multiple particiapnts join. #653

Open NaiyerAghaz opened 1 year ago

NaiyerAghaz commented 1 year ago

App has stuck with multiple particiapnts after 10 minutes call

Description

When multiple join participants join then then start video very slow for conversation its not proper display video, my internet is okay, I have 50 mbps, I don't know why this happened.

Steps to Reproduce

  1. video call start then add to invite another user to join call
  2. when join new participants then then start video very slow for conversation its not proper display video, my internet is okay, I have 50 mbps.
  3. after 10 to 12 minutes conversation from starting video has stuck
  4. high cpu used. Screenshot 2022-07-26 at 3 32 32 PM

    Code

// Code that helps reproduce the issue

Expected Behavior

Video conference call should not be stuck after specific time.

Actual Behavior

[What actually happens]

Reproduces How Often

[What percentage of the time does it reproduce?]

Logs

Execution of the command buffer was aborted due to an error during execution. Insufficient Memory.

TwilioVideoSDK.setLogLevel(.debug)

Using this func to connect Twilio SDK with room ` ```

func doConnectTwilio(twilioToken: String){
        prepareLocalMedia()
        let connectionOption = ConnectOptions.init(token: twilioToken) { builder in

          // builder.preferredVideoCodecs =   [TVIVideoCodec.H264.rawValue]
            //new added code
            builder.isNetworkQualityEnabled = true

            builder.networkQualityConfiguration =
            NetworkQualityConfiguration(localVerbosity: .minimal, remoteVerbosity: .minimal)
          builder.encodingParameters = EncodingParameters(audioBitrate:16, videoBitrate:0)

           // builder.encodingParameters = EncodingParameters(audioBitrate:0, videoBitrate:1600)
            // Enable recommended Collaboration mode Bandwidth Profile Options
            let videoBandwidthProfileOptions = VideoBandwidthProfileOptions { builder in

                builder.dominantSpeakerPriority = .high
                builder.maxSubscriptionBitrate = 6000
                builder.mode = .presentation
                builder.trackSwitchOffMode = .predicted

            }
            builder.bandwidthProfileOptions = BandwidthProfileOptions(videoOptions: videoBandwidthProfileOptions)
            builder.preferredVideoCodecs = [Vp8Codec(simulcast: true)]
            //end
            builder.isDominantSpeakerEnabled = true
            builder.roomName = self.roomID
            if let audioTrack = self.localAudioTrack {
                builder.audioTracks = [audioTrack]
            }
            if let videoTrack = self.localVideoTrack {
                builder.videoTracks = [videoTrack]
            }
        }
        self.room = TwilioVideoSDK.connect(options: connectionOption, delegate: self)

    }
// Log output when the issue occurs

Versions

All relevant version information for the issue.

Video iOS SDK

[e.g. 5.1.1 via CocoaPods]

Xcode

[e.g. 13.3]

iOS Version

[e.g. 14.4]

iOS Device

[e.g. iPhone 8 ]

NaiyerAghaz commented 1 year ago

my sid is: PAf4205a8d4d746fc491ae7a85f04cd4cc

now I got stuck within 8 minutes. Screenshot 2022-07-27 at 3 47 47 PM

I have changed my code while connect Twilio with room and capture of video but still same issue please help me out why this happened.

captured time:

` if PlatformUtils.isSimulator { return } let frontCamera = CameraSource.captureDevice(position: .front) let backCamera = CameraSource.captureDevice(position: .back) localAudioTrack = LocalAudioTrack()

    if (frontCamera != nil || backCamera != nil) {
        // Preview our local camera track in the local video preview view.
        camera = CameraSource(options:options,delegate: self)

        if let camera = camera {
            localVideoTrack = LocalVideoTrack(source: camera, enabled: true, name: "Camera")

                // Discover a simulcast format for the front camera
                let format = CaptureDeviceUtils.selectFormatBySize(device: frontCamera!,
                                                                   targetSize: CaptureDeviceUtils.kSimulcastVideoDimensions)

                // Lower the frame rate to reduce CPU load, but still produce 3 temporal layers (f, f/2, f/4)
                format.frameRate = CaptureDeviceUtils.kSimulcastVideoFrameRate

                // Apply slight cropping to reduce CPU load, and provide square-ish video
                let croppedFormat = VideoFormat.init()
                croppedFormat.dimensions = CaptureDeviceUtils.kSimulcastVideoDimensions
                camera.requestOutputFormat(croppedFormat)
            localVideoTrack!.addRenderer(localView)
            if (frontCamera != nil && backCamera != nil) {
                // We will flip camera on tap.
                let tap = UITapGestureRecognizer(target: self, action: #selector(VideoCallViewController.getFlipLocalView(gesture:)))
                localView.addGestureRecognizer(tap)
            }

            camera.startCapture(device: frontCamera != nil ? frontCamera! : backCamera!) { (captureDevice, videoFormat, error) in
                if let error = error {

                } else {

                    localView.shouldMirror = (captureDevice.position == .front)
                }
            }
        }`

Twilio connect with room:

`func doConnectTwilio(twilioToken: String){ prepareLocalMedia() let connectionOption = ConnectOptions.init(token: twilioToken) { builder in

      // builder.preferredVideoCodecs =   [TVIVideoCodec.H264.rawValue]
        //new added code

        if let audioTrack = self.localAudioTrack {
            builder.audioTracks = [audioTrack]
        }
        if let videoTrack = self.localVideoTrack {
            builder.videoTracks = [videoTrack]
        }
        builder.isNetworkQualityEnabled = true
        builder.isDominantSpeakerEnabled = true
        builder.roomName = self.roomID

        builder.networkQualityConfiguration =
        NetworkQualityConfiguration(localVerbosity: .minimal, remoteVerbosity: .minimal)
      builder.encodingParameters = EncodingParameters(audioBitrate:16, videoBitrate:1800)
        builder.preferredVideoCodecs = [Vp8Codec(simulcast: true)]
    }
    self.room = TwilioVideoSDK.connect(options: connectionOption, delegate: self)

}`