Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CameraView.destroy CameraEngine.destroy ANR (java.util.concurrent.CountDownLatch.await(CountDownLatch.java:278)) #1261

Open
BruceLiuTao opened this issue Dec 8, 2023 · 1 comment

Comments

@BruceLiuTao
Copy link

Describe the bug

  • CameraView version: In September 2323, the main branch
  • Camera engine used: camera2
  • Device / Android version: Pixel, API 28
  • I have read the FAQ page: yes

To Reproduce

private fun initCameraView() {
camera.setLifecycleOwner(this)
camera.addCameraListener(Listener())
}

override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<String?>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
val valid = grantResults.all { it == PackageManager.PERMISSION_GRANTED }
if (valid && !camera.isOpened) {
camera.open()
} else if (!valid) {
ToastUtils.showShort("打开失败,请授予相机权限")
}
}

XML layout

<com.otaliastudios.cameraview.CameraView
android:id="@+id/camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:gravity="center"
android:keepScreenOn="true"
app:cameraExperimental="true"
app:cameraEngine="camera2"
app:cameraPreview="texture"
app:cameraPlaySounds="true"
app:cameraGrid="off"
app:cameraFlash="torch"
app:cameraWhiteBalance="auto"
app:cameraHdr="off"
app:cameraPictureMetering="true"
app:cameraAudio="off"
app:cameraFacing="back"
app:cameraGestureTap="autoFocus"
app:cameraGestureLongTap="none"
app:cameraGesturePinch="zoom"
app:cameraGestureScrollHorizontal="none"
app:cameraGestureScrollVertical="none"
app:cameraMode="picture"
app:cameraPictureFormat="jpeg"
app:cameraAutoFocusMarker="@string/cameraview_default_autofocus_marker"/>


### Logs
"main" prio=5 tid=1 TimedWaiting
  | group="main" sCount=0 dsCount=0 flags=0 obj=0x7177b168 self=0xe1c05410
  | sysTid=28527 nice=-10 cgrp=default sched=0/0 handle=0xea4e4470
  | state=? schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
  | stack=0xff0dc000-0xff0de000 stackSize=8192KB
  | held mutexes=
  at sun.misc.Unsafe.park(Native method)
  - waiting on an unknown object
  at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1063)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1358)
  at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:278)
  at com.otaliastudios.cameraview.engine.CameraEngine.destroy(CameraEngine.java:313)
  at com.otaliastudios.cameraview.engine.CameraEngine.destroy(CameraEngine.java:325)
  at com.otaliastudios.cameraview.engine.CameraEngine.destroy(CameraEngine.java:289)
  at com.otaliastudios.cameraview.CameraView.destroy(CameraView.java:893)


@Foolwithgenius
Copy link

@natario1 I also found this problem in the operation of the camera in the project, which can basically reach one-tenth of the probability in the scene where the camera is frequently turned on and off. Is there any way to avoid it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants