Open SimovicIvan opened 2 months ago
Which version of LiveKit specifically is being used here? 2.0.0? Can you also check which version of io.github.webrtc-sdk is being used (run gradle dependencies
)?
implementation "io.livekit:livekit-android:2.0.0" io.github.webrtc-sdk:android-prefixed:114.5735.07@aar
How often would you say the error occurs, percentage wise?
Wait, you wrote a buildPeerConnectionFactory
method, but how does that PeerConnectionFactory get injected into our LiveKit SDK?
On my Pixel 6 android 14, it is happening often. I did about 6 test calls, it crashed twice. The crash is a bit confusing because it happens a few seconds after I end a call. so once it crashed after a call, the other time it crashed right after I started a new one, but I am assuming it is because I ended a call and started a new one very fast
private val peerConnectionFactory by lazy { buildPeerConnectionFactory() }
val localVideoSource: VideoSource = peerConnectionFactory.createVideoSource(false)
So I use that to create video sources. sorry about the confusion
Is there a reason why you're not going through LocalParticipant.createVideoTrack()
? It sounds like the association between two separate PeerConnectionFactories are causing the issue.
I am sending video with custom VideoCapturer
private suspend fun startLocalVideo(
context: Context
) {
val localVideoSource = peerConnectionFactory.createVideoSource(false)
val surfaceTextureHelper =
SurfaceTextureHelper.create(Thread.currentThread().name, rootEglBase.eglBaseContext)
videoCapturer = CustomVideoCapturer { ImageRepo.getInstance().getSegmentedImageForWebRTC() }
videoCapturer?.let { videoCapturer ->
(videoCapturer as VideoCapturer).initialize(
surfaceTextureHelper,
context,
localVideoSource.capturerObserver
)
localVideoTrack =
room?.localParticipant?.createVideoTrack(
RTCClient.LOCAL_TRACK_ID,
videoCapturer
)
localVideoTrack?.let { track ->
room?.localParticipant?.publishVideoTrack(
track
)
}
videoCapturer.startCapture(1280, 960, 24)
}
}
Is there a way I can get the capturerObserver from Livekit instead? or will i need to revert to 1.0 Livekit for now?
createVideoTrack
has an overload to pass in your own custom video capturers. You should try that.
I am doing that :). the problem is my custom video capturer need access to capturerObserver to send frames. and I get that from PeerConnectionFactory. its all in the code above.
val localVideoSource = peerConnectionFactory.createVideoSource(false)
(videoCapturer as VideoCapturer).initialize(
surfaceTextureHelper,
context,
localVideoSource.capturerObserver
)
@Synchronized
override fun initialize(
surfaceTextureHelper: SurfaceTextureHelper,
context: Context,
capturerObserver: CapturerObserver
) {
checkNotDisposed()
this.context = context
this.capturerObserver = capturerObserver
this.surfaceTextureHelper = surfaceTextureHelper
}
// and later
capturerObserver?.onFrameCaptured(videoFrame)
So how am I supposed to send a frame in my custom video capturer without creating a videoSource to get the capturer observer?
LiveKit handles creating the video source and calling VideoCapturer.initialize
with the appropriate capturerObserver from our internal PeerConnectionFactory. You don't need to call it yourself.
Hmm, I am a bit confused as to what my CustomVideoCapturer is supposed to do then. I have a function on it called trySendToServer that I call with a delay of 42 millis. there I fetch a bitmap from my ImageRepository, I do some GLES20/yuvConverter stuff and the part that I understand as crucial is capturerObserver?.onFrameCaptured(videoFrame)
Do you maybe have an example of how I can send my own frames with my custom video capturer?
The point is you can pass in your CustomVideoCapturer to createVideoTrack without calling initialize.
We will call initialize for you and supply you with the capture observer to use.
Basically, just remove your own creation of the video source and calling of initialize, as well as not creating your own PeerConnectionFactory.
I understand, thank you
I am getting a Fatal signal 11 (SIGSEGV). I think it started since upgrading to 2.0 of Livekit. the issue seems to be related to NetworkMonitor. I have disabledNetworkMonitor in options.
Reproduced both on Samsung A52 and Pixel 6
Seems to happen only when I end a call, but not always reproducable