video-quickstart-android: Supported formats could not be retrieved because an error occurred connecting to the camera service

Description

App crashes due to the following error log. It did not crash before beta 5 version.

Steps to Reproduce

  1. Give permissions to camera.
  2. App crashes when local camera stream is created.

Logs

java.lang.RuntimeException: Unable to resume activity {to.go_internal/to.go.app.twilio.VideoConferenceActivity}: java.lang.IllegalStateException: Supported formats could not be retrieved because an error occurred connecting to the camera service
	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3486) ~[na:0.0]
	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3526) ~[na:0.0]
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1584) ~[na:0.0]
	at android.os.Handler.dispatchMessage(Handler.java:102) ~[na:0.0]
	at android.os.Looper.loop(Looper.java:163) ~[na:0.0]
	at android.app.ActivityThread.main(ActivityThread.java:6321) ~[na:0.0]
	at java.lang.reflect.Method.invoke(Native Method) ~[na:0.0]
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880) ~[na:0.0]
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770) ~[na:0.0]
Caused by: java.lang.IllegalStateException: Supported formats could not be retrieved because an error occurred connecting to the camera service
	at com.twilio.video.Preconditions.checkState(Preconditions.java:453) ~[na:0.0]
	at com.twilio.video.CameraCapturer.getSupportedFormats(CameraCapturer.java:347) ~[na:0.0]
	at com.twilio.video.LocalVideoTrack.create(LocalVideoTrack.java:154) ~[na:0.0]

Expected Behavior

App should not crash

Actual Behavior

App crashes

Reproduces how Often

100%

Versions

Video Android SDK

2.0.0 beta 5

Android API

23-27

Android Device

One Plus, Xiaomi

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 23 (9 by maintainers)

Most upvoted comments

I have this issue after exiting and then relaunching the app - it seems that the camera is not correctly released for some reason (despite calling videoTrack.release(). Calling cameraCapturer.stopCapture() when the activity is destroyed (app is exited) solved the problem for me.

I suspect there’s some sort of race condition preventing stopCapture() from executing correctly, perhaps if you quit the app too soon after starting iniitialisation of the camera capturer, then the capturer is not released.

Is it possible a video track is being created twice? Once in onRequestPermissionsResult and once in onResume or are you only creating the track in one of those callbacks?