twilio / video-quickstart-android

Twilio Video Quickstart for Android
MIT License
212 stars 159 forks source link

Remote video session is blank for some seconds #748

Closed VivekKannaV closed 9 months ago

VivekKannaV commented 11 months ago

Description

Screen mirror starts after ~25 seconds to remote device in some cases. This happens even after publisher gets onVideoTrackPublished callback & subscriber receives onVideoTrackSubscribed

Steps to Reproduce

  1. Raise connection request.
  2. Cancel the request for the first time.
  3. Again raise the connection request after some seconds (15-30 sec).
  4. Screen share permission pops up to publish video track.
  5. Now accept the request to start screencast

PF video link - https://drive.google.com/file/d/1PXMMN9EkxoxNENfpTrRrPXLS0rYN03i1/view?usp=share_link

Note:

  1. The screen behind the permission popup should be a static page (eg. Just a button not like progressbar)
  2. In our subscriber web app the video is successfully subscribed but the video track is received with null width and height. Also we noticed that packets received with empty bytes for some seconds & resolved after a few secs.

Code

val options = ConnectOptions.Builder(accessToken)
            .roomName(roomId)
            .enableNetworkQuality(true)
            .encodingParameters(EncodingParameters(16, 0))
            .build()

val activeRoom = Video.connect(context, options, this)
override fun onConnected(room: Room) {
        activeRoom.localParticipant.setListener(this)
}

This code will be invoked on user accepts the permission

fun startScreenShare(mediaInputResult: ActivityResult) {
        val screenCapturer = ScreenCapturer(context, mediaInputResult.resultCode, mediaInputResult.data!!, listener)
        val localVideoTrack = LocalVideoTrack.create(context, true, screenCapturer)
        if (localVideoTrack != null) {
            activeRoom?.localParticipant?.publishTrack(localVideoTrack)
        }
}
override fun onVideoTrackPublished(localParticipant: LocalParticipant, localVideoTrackPublication: LocalVideoTrackPublication) {
        // Video track successfully published
}

Expected Behavior

Screencast starts immediately without much delay when we have good bandwidth

Actual Behavior

Screencast starts after ~25 seconds even when we have good bandwidth

Reproduces how Often

80%

Logs

Twilio Video Publisher - MobileApp.txt Twilio Video Subscriber - WebApp.txt

Versions

KOTLIN = "1.8.21" GRADLE_TOOLS = "8.0.1" TARGET_SDK_VERSION = 33 BUILD_TOOLS_VERSION = "33.0.2" JVM_TARGET_VERSION = "17"

Video Android SDK

7.6.1

Android API

TARGET_SDK = 33 Android SDK: 30, Release: 11

Android Device

Samsung Tab Active A Model: SM-T295 Hardware: qcom

ocarevs commented 11 months ago

@VivekKannaV I've been unable to reproduce this issue so far. Does this delayed screen share happen also when you don't cancel the first permission request; that is, you allow screen share on the first popup? Does this happen on the specified device only? Does this only happen when screen sharing onto JS client?

VivekKannaV commented 11 months ago

@ocarevs

Does this delayed screen share happen also when you don't cancel the first permission request?

No never happens with v7.6.1 but Sometimes Yes with 7.6.3.

Does this happen on the specified device only?

No, we have tested with multiple Samsung devices & results are same in all.

Does this only happen when screen sharing onto JS client?

Maybe but not sure. In our solution, we share sessions between Android to Web app only, not in any other combinations.

afalls-twilio commented 10 months ago

@VivekKannaV do you have any captured logcat logs of when this is happening?

VivekKannaV commented 10 months ago

@afalls-twilio Pls check the logs section in the very first comment. It's updated & attached.

afalls-twilio commented 10 months ago

@VivekKannaV what happens when you interact with the device which you are sharing the screen of after you after you initiate the share? does the delay go away (ie is it not sending the frame due to inactivity)?

Also, I have created a demo of screen-sharing that we can use to help narrow down the issue. It logs all the events including when it receives and sends the first frame of video. Lets use this demo going forward so that we are both using the same code.

VivekKannaV commented 10 months ago

@afalls-twilio Yes, the screen share starts immediately after the user interaction.

As I mentioned in the top description, this issue happens only in below highlighted scenario. This issue will not occur If screen has progress bar / delay gone away quickly if the user interacts.

The screen behind the permission popup should be a static page (eg. Just a button not like progressbar).

Great & thanks for sharing the demo code. Let me use when the time arrives. Appreciate your effort.

afalls-twilio commented 9 months ago

@VivekKannaV This issue has been fixed in the upcoming release (7.6.4)