question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug at CameraXBasic example : camera switch

See original GitHub issue

When calling bindCameraUseCases at camera_switch_button click listener, it doesn’t work correctly with Galaxy S10+, Note 8

If I add CameraX.unbindAll() code to bindCameraUseCases() function at start line, it works normarlly.

private fun bindCameraUseCases() {
        CameraX.unbindAll()
        ...
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
owahltinezcommented, Jul 23, 2019

OK, the problem is that when the camera switch button is pressed, we are trying to bind all camera use cases without unbinding the previous ones first. Thanks for flagging!

I think that the proper solution here would be to call CameraX.unbindAll() inside of the switch button callback, rather than inside of the bindCameraUseCases() function.

0reactions
davinnovationcommented, Jul 18, 2019

@owahltinez Yes. When I press the switch button, 100%. - Galaxy S10+ confirmed

In logcat, error occurred just one time with this message

2019-07-18 20:24:29.535 4188-4239/com.android.example.cameraxbasic E/Camera: CameraDevice.onError(): 1 with error: ERROR_MAX_CAMERAS_IN_USE

After this, error message doesn’t shown and only this message has logged when press switch button.

2019-07-18 20:23:13.619 392-392/com.android.example.cameraxbasic D/ViewRootImpl@705f68f[MainActivity]: ViewPostIme pointer 0
2019-07-18 20:23:13.644 392-392/com.android.example.cameraxbasic D/ViewRootImpl@705f68f[MainActivity]: ViewPostIme pointer 1

And if I add CameraX.unbindAll() to bindCameraUseCases() function, it works properly without any error message

Read more comments on GitHub >

github_iconTop Results From Across the Web

CameraXBasic crash on Android 9.1 ... - Issue Tracker
When I run CameraXBasic, I can observe a series of internal/managed exceptions up to this code: /** Initialize CameraX, and prepare to bind...
Read more >
Android-CameraX: Switch between multiple front cameras
When you bind use cases, CameraX chooses the first camera that meets the use cases requirements. For example, 2 different back cameras may...
Read more >
Camera screen turns black while opening camera and go to ...
when user came back to camera activity by pressing back button user seeing black preview. This is only reproduce in Redmi Note 8....
Read more >
Facebook bug shows camera activated in background ... - CNET
Some people have complained their cameras got turned on while they were looking through Facebook's app.
Read more >
CameraX overview - Android Developers
CameraX is a Jetpack library, built to help make camera app development easier. For new apps, we recommend starting with CameraX.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found