RootEncoder icon indicating copy to clipboard operation
RootEncoder copied to clipboard

"main" tid=1 Waiting ```Input dispatching timed out (No focused window)```

Open bhavinatharva opened this issue 1 year ago • 1 comments

Describe the bug The app freezes when attempting to start the camera preview using the startPreview method from StreamBase. The main thread gets stuck in a waiting state at Unsafe.park, causing a deadlock. This issue seems related to the Camera2ApiManager class, particularly around semaphore handling.

To Reproduce Steps to reproduce the behavior:

  1. Go to the camera preview feature in the app.
  2. Click on 'Start Preview'.
  3. Observe the app freezing without starting the preview.
  4. Check the logcat to see the waiting state error in the stack trace.

Expected behavior The camera preview should start smoothly without causing the app to hang or enter a waiting state.

Screenshots No available

Smartphone (please complete the following information):

  • RAM (total memory): 2,048 MB (1,960 MB)
  • System on Chip (SOC): Spreadtrum T603
  • CPU: 4x ARM Cortex-A55 (1800 MHz), 4x ARM Cortex-A55 (1200 MHz)
  • ABI: armeabi-v7a, armeabi
  • Form factor: Phone
  • Screen size: 720x1612
  • Screen density (DPI): 320 (xhdpi)
  • Android version: Android 14 (SDK 34)
  • OpenGL ES version: 3.2
  • GPU: Imagination Tech PowerVR GE8322 (600 MHz)
  • Device: itel-A667L
  • Media server: [e.g. srs, version 5.0]
  • Class used: [e.g. RtmpCamera1]

Additional context Stack trace highlights:

"main" tid=1 Waiting
  at jdk.internal.misc.Unsafe.park (Native method)
  at java.util.concurrent.locks.LockSupport.park (LockSupport.java:211)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire (AbstractQueuedSynchronizer.java:715)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared (AbstractQueuedSynchronizer.java:1027)
  at java.util.concurrent.Semaphore.acquireUninterruptibly (Semaphore.java:341)
  at com.pedro.encoder.input.video.Camera2ApiManager.openCameraId (Camera2ApiManager.kt:616)
  at com.pedro.encoder.input.video.Camera2ApiManager.openCameraFacing (Camera2ApiManager.kt:431)
  at com.pedro.encoder.input.sources.video.Camera2Source.start (Camera2Source.kt:55)
  at com.pedro.library.base.StreamBase.startPreview (StreamBase.kt:366)
  at com.pedro.library.base.StreamBase.startPreview (StreamBase.kt:344)
  at com.pedro.library.base.StreamBase.startPreview$default (StreamBase.kt:326)

Possible causes:

  • Semaphore not being released properly.
  • Deadlock due to improper synchronization.
  • Resource conflict with other threads accessing the camera.

using com.github.pedroSG94.RootEncoder:library:2.5.5

bhavinatharva avatar Feb 12 '25 05:02 bhavinatharva

Hello,

I'm not able to reproduce it. Can you debug the case to get more info? The semaphore should be released when any callback of camera is called (onOpened, onError or onDisconnected) but maybe anyone is called. I need you debug it and confirm that it is the case but this never should happen acording with the android documentation. Also, if you can't debug the case you can try use CameraXSource instead of Camera2Source

pedroSG94 avatar Feb 27 '25 11:02 pedroSG94