GetStream / webrtc-android

🛰️ A versatile WebRTC pre-compiled Android library that reflects the recent WebRTC updates to facilitate real-time video chat for Android and Compose.
https://getstream.github.io/webrtc-android/
Apache License 2.0
516 stars 54 forks source link

"java.lang.IllegalStateException: There is no matched resolution!" #152

Open xxrraa opened 3 weeks ago

xxrraa commented 3 weeks ago

Hi all, thanks for the amazing release! I'm having a really weird issue. Everything was working fine and then I messed w the code and versions of java, gradle kotlin, etc via homebrew and now the app crashes on start and logcat shows the error in the title of this issue. Some background info/things I've tried

Full error below, thanks for your time, any help is greatly appreciated

FATAL EXCEPTION: main Process: io.getstream.webrtc.sample.compose, PID: 3235 java.lang.IllegalStateException: There is no matched resolution! at io.getstream.webrtc.sample.compose.webrtc.sessions.WebRtcSessionManagerImpl.getResolution(WebRtcSessionManagerImpl.kt:105) at io.getstream.webrtc.sample.compose.webrtc.sessions.WebRtcSessionManagerImpl.access$getResolution(WebRtcSessionManagerImpl.kt:62) at io.getstream.webrtc.sample.compose.webrtc.sessions.WebRtcSessionManagerImpl$videoSource$2.invoke(WebRtcSessionManagerImpl.kt:117) at io.getstream.webrtc.sample.compose.webrtc.sessions.WebRtcSessionManagerImpl$videoSource$2.invoke(WebRtcSessionManagerImpl.kt:114) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at io.getstream.webrtc.sample.compose.webrtc.sessions.WebRtcSessionManagerImpl.getVideoSource(WebRtcSessionManagerImpl.kt:114) at io.getstream.webrtc.sample.compose.webrtc.sessions.WebRtcSessionManagerImpl.access$getVideoSource(WebRtcSessionManagerImpl.kt:62) at io.getstream.webrtc.sample.compose.webrtc.sessions.WebRtcSessionManagerImpl$localVideoTrack$2.invoke(WebRtcSessionManagerImpl.kt:123) at io.getstream.webrtc.sample.compose.webrtc.sessions.WebRtcSessionManagerImpl$localVideoTrack$2.invoke(WebRtcSessionManagerImpl.kt:121) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at io.getstream.webrtc.sample.compose.webrtc.sessions.WebRtcSessionManagerImpl.getLocalVideoTrack(WebRtcSessionManagerImpl.kt:121) at io.getstream.webrtc.sample.compose.webrtc.sessions.WebRtcSessionManagerImpl.onSessionScreenReady(WebRtcSessionManagerImpl.kt:195) at io.getstream.webrtc.sample.compose.ui.screens.video.VideoCallScreenKt$VideoCallScreen$1.invokeSuspend(VideoCallScreen.kt:48) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81) at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41) at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@b1ea14a, androidx.compose.runtime.BroadcastFrameClock@a6b68bb, StandaloneCoroutine{Cancelling}@546c1d8, AndroidUiDispatcher@3408931] 2024-06-11 20:10:24.659 2308-2396 WorkSourceUtil com.google.android.gms E Could not find package: io.getstream.webrtc.sample.compose

xxrraa commented 3 weeks ago

I've done some more troubleshooting since posting this and was able to get the app not to crash by changing

private val resolution: CameraEnumerationAndroid.CaptureFormat get() { val frontCamera = cameraEnumerator.deviceNames.first { cameraName -> cameraEnumerator.isFrontFacing(cameraName) } val supportedFormats = cameraEnumerator.getSupportedFormats(frontCamera) ?: emptyList() return supportedFormats.firstOrNull { (it.width == 720 || it.width == 480 || it.width == 360) } ?: error("There is no matched resolution!") }

to this

private val resolution: CameraEnumerationAndroid.CaptureFormat get() { val frontCamera = cameraEnumerator.deviceNames.first { cameraName -> cameraEnumerator.isFrontFacing(cameraName) } val supportedFormats = cameraEnumerator.getSupportedFormats(frontCamera) ?: emptyList() return supportedFormats.firstOrNull { (it.width == 720 || it.width == 480 || it.width == 360) } ?: CameraEnumerationAndroid.CaptureFormat(640, 480, CameraEnumerationAndroid.CaptureFormat.FramerateRange(15, 120)) // Default resolution if no match found }

Now, the audio/video from the blackberry is displayed on the virtual device in android studio perfectly, but the virtual machine's video, which used to display a pixelated green android avatar, now shows a checkered background with a red box in it

Additional troubleshooting results: With the original code (after my hard to diagnose hiccup), no combination of front/back camera and None, Emulated, Webcam prevents crashing. But with the modified code, if I set front to webcam it crashes, if I set it to emulate it doesn't crash, and while it's set to emulate, back can be set to webcam and work perfectly

Thanks again for any help