mrousavy / react-native-vision-camera

๐Ÿ“ธ A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7k stars 1.03k forks source link

๐Ÿ› [Android] Native method - jdk.internal.misc.Unsafe.park Input dispatching timed out #2874

Open short-dsb opened 2 months ago

short-dsb commented 2 months ago

What's happening?

Seeing this issue in production logs. Have not been able to reproduce it locally.

Uploading the log here versus pasting it below: stacktrace.log

Reproduceable Code

const device = useCameraDevice("back", {
  physicalDevices: [
    "ultra-wide-angle-camera",
    "wide-angle-camera",
    "telephoto-camera",
  ],
});
// ...
<Camera
  ref={camera}
  device={device}
  isActive={isActive}
  photo={true}
  style={styles.camera}
/>

Relevant log output

"main" tid=1 Timed Waiting
  at jdk.internal.misc.Unsafe.park (Native method)
  at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:252)
  at kotlinx.coroutines.BlockingCoroutine.joinBlocking (Builders.kt:88)
  at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking (Builders.kt:59)
  at kotlinx.coroutines.BuildersKt.runBlocking (unavailable:1)
  at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default (Builders.kt:38)
  at kotlinx.coroutines.BuildersKt.runBlocking$default (unavailable:1)
  at com.mrousavy.camera.core.CameraSession.close (CameraSession.kt:92)
  at com.mrousavy.camera.CameraView.destroy (CameraView.kt:135)
  at com.mrousavy.camera.CameraViewManager.onDropViewInstance (CameraViewManager.kt:38)
  at com.mrousavy.camera.CameraViewManager.onDropViewInstance (CameraViewManager.kt:16)
  at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView (NativeViewHierarchyManager.java:635)
  at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren (NativeViewHierarchyManager.java:499)
  at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute (UIViewOperationQueue.java:217)
  at com.facebook.react.uimanager.UIViewOperationQueue$1.run (UIViewOperationQueue.java:926)
  at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches (UIViewOperationQueue.java:1037)
  at com.facebook.react.uimanager.UIViewOperationQueue.-$$Nest$mflushPendingBatches (unavailable)
  at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded (UIViewOperationQueue.java:1097)
  at com.facebook.react.uimanager.GuardedFrameCallback.doFrame (GuardedFrameCallback.java:29)
  at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame (ReactChoreographer.java:175)
  at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame (ChoreographerCompat.java:85)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1035)
  at android.view.Choreographer.doCallbacks (Choreographer.java:845)
  at android.view.Choreographer.doFrame (Choreographer.java:775)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1022)
  at android.os.Handler.handleCallback (Handler.java:978)
  at android.os.Handler.dispatchMessage (Handler.java:104)
  at android.os.Looper.loopOnce (Looper.java:238)
  at android.os.Looper.loop (Looper.java:357)
  at android.app.ActivityThread.main (ActivityThread.java:8103)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1026)

"mqt_native_modules" tid=45 Blocked
  at com.facebook.react.uimanager.NativeViewHierarchyManager.getRootViewNum (unavailable)
  at com.facebook.react.uimanager.UIImplementation.getRootViewNum (UIImplementation.java:181)
  at com.facebook.react.uimanager.UIManagerModule.onBatchComplete (UIManagerModule.java:725)
  at com.facebook.react.bridge.NativeModuleRegistry.onBatchComplete (NativeModuleRegistry.java:118)
  at com.facebook.react.bridge.CatalystInstanceImpl$BridgeCallback.onBatchComplete (CatalystInstanceImpl.java:170)
  at com.facebook.jni.NativeRunnable.run (Native method)
  at android.os.Handler.handleCallback (Handler.java:978)
  at android.os.Handler.dispatchMessage (Handler.java:104)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:29)
  at android.os.Looper.loopOnce (Looper.java:238)
  at android.os.Looper.loop (Looper.java:357)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:234)
  at java.lang.Thread.run (Thread.java:1012)

Camera Device

// Unable to log this as it's occurring in production.

Device

Multiple, e.g., motorola ellis (moto g pure), samsung dm3q (Galaxy S23 Ultra)

VisionCamera Version

4.0.3

Can you reproduce this issue in the VisionCamera Example app?

No, I cannot reproduce the issue in the Example app

Additional information

mrousavy commented 2 months ago

Hm, that doesn't look like a crash though? It's just a lock being in waiting state. What's the crash messsage?

short-dsb commented 2 months ago

Good morning! ๐Ÿ™‚ This is an ANR, not a crash. We had been on v2 until recently and didnโ€™t start seeing this issue on our dashboard until after upgrading to v4.

At the moment, itโ€™s our third most reported issue and on the verge of exceeding our bad behavior threshold, which will negatively impact our appโ€™s discoverability.

Any help you can provide would be appreciated.

mrousavy commented 2 months ago

Ah okay - well I currently have a lot of other things to work on, if you want to prioritize that issue consider sponsoring me through your company :)

short-dsb commented 2 months ago

We did! ๐Ÿ™‚ Although our priority is the RN 0.74 upgrade, it would be nice to uncover the root cause of this issue as well.

Thanks for all your work.

mrousavy commented 2 months ago

Ah sorry with which company?

Although our priority is the RN 0.74 upgrade

Yep, that's high prio for me as well - just lots of effort

short-dsb commented 2 months ago

Ah sorry with which company?

Sent you an email. ๐Ÿ™‚

KennethF86 commented 3 weeks ago

Whats the status on this anr? we also seeing this on our app.