Ruddle / RemoteCam

Your android camera streamed on your desktop: use as a source for OBS, or as a webcam with v4l2. Free✅, No Ads✅, Open Source✅
MIT License
496 stars 56 forks source link

java.lang.IllegalArgumentException: Surface was abandoned #19

Open std-microblock opened 8 months ago

std-microblock commented 8 months ago

for some reason the surface is abandoned, a simple retry fixes the problem

    private suspend fun createCaptureSession(
        device: CameraDevice, targets: List<Surface>, handler: Handler? = null
    ): CameraCaptureSession? = suspendCoroutine { cont ->
        if (targets.any {
            !it.isValid
            }) {
            // re-initialize the camera
            Log.w("CamEngine", "Invalid surface targets, re-initializing camera")
            cont.resume(null);
            return@suspendCoroutine
        }
  // .....

        session = createCaptureSession(camera, targets, cameraHandler)
        if (session == null) {
            Log.i("CAMERA", "session is null")
            return initializeCamera();
        }