aws-samples / amazon-ivs-broadcast-android-sample

MIT No Attribution
9 stars 8 forks source link

Play in the background for more than 10 seconds, CameraSource log error "AmazonIVS: Camera error 3" #24

Open xlg opened 2 years ago

xlg commented 2 years ago

The Steps: 1.The connection is established and the push stream is successful 2.Back to the background for more than 10 seconds then CameraSource will log error "AmazonIVS: Camera error 3" At this point, go back to the front, you will find that audio stream will resume but preview screen stuck. onDeviceAdded() will be called back,if i call attachCameraDevice again,the screen will return to normal.But the audience still can't see it, it's just that the preview is not stuck. I would like to know, how to resume video streaming at this point. Thanks!

caleighm commented 2 years ago

Hi @xlg, "Camera error 3" is the following error: https://developer.android.com/reference/android/hardware/camera2/CameraDevice.StateCallback#ERROR_CAMERA_DISABLED

This typically indicates a permission issue. You don't mention the Android version that your app is targeting, but I note that you're seeing the problem when you background your app. See this relevant change in Android 11: https://developer.android.com/about/versions/11/privacy/foreground-services

I recommend that you look into missing camera permissions, if possible.

Let me know if this helps or if you still see the problem after fixing any potential permission issues.