PeculiarVentures / GammaCV

GammaCV is a WebGL accelerated Computer Vision library for browser
https://gammacv.com
MIT License
178 stars 23 forks source link

Question: Crash on capture #196

Open rmdvector opened 8 months ago

rmdvector commented 8 months ago

I'm not sure this is related to GammaCV, hence put in as a question rather than an issue report. On executing the following:

  const im_mat = new gm.MediaInput(video, [video.videoHeight, video.videoWidth, 4])
  const operation = gm.upsample(im_mat, 1)
  const tensor = gm.tensorFrom(im_mat)
  const sess = new gm.Session()
  sess.init(operation)
  sess.runOp(operation, 0, tensor)

I'll get the following crash very intermittently: I've seen a few reports, it seems to be related to attempting to lock the video stream itself. It happens more often on slower devices. This specifically happened on mobile firefox on a Pixel 7, but it also happens on Chrome.

Abort message: 'FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7565f75238)
02-13 10:27:17.908 23727 23765 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 23765 (binder:23727_3),
pid 23727 (main)
02-13 10:27:18.617 30061 30061 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-13 10:27:18.617 30061 30061 F DEBUG   : Build fingerprint: 'google/panther/panther:14/UQ1A.240105.004/11206848:user/
release-keys'
02-13 10:27:18.617 30061 30061 F DEBUG   : Revision: 'MP1.0'
02-13 10:27:18.617 30061 30061 F DEBUG   : ABI: 'arm64'
02-13 10:27:18.617 30061 30061 F DEBUG   : Timestamp: 2024-02-13 10:27:18.023913426-0800
02-13 10:27:18.617 30061 30061 F DEBUG   : Process uptime: 445s
02-13 10:27:18.617 30061 30061 F DEBUG   : Cmdline: app_process /data/local/tmp/.studio com.android.tools.screensharing
.Main --socket=screen-sharing-agent-63068 --max_size=1750,3118 --codec=vp8
02-13 10:27:18.617 30061 30061 F DEBUG   : pid: 23727, tid: 23765, name: binder:23727_3  >>> app_process <<<
02-13 10:27:18.617 30061 30061 F DEBUG   : uid: 2000
02-13 10:27:18.617 30061 30061 F DEBUG   : tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
02-13 10:27:18.617 30061 30061 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
02-13 10:27:18.617 30061 30061 F DEBUG   : Abort message: 'FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7
565f75238)'
02-13 10:27:18.617 30061 30061 F DEBUG   :     x0  0000000000000000  x1  0000000000005cd5  x2  0000000000000006  x3  00
00007574327290
02-13 10:27:18.617 30061 30061 F DEBUG   :     x4  6b6b60621f6a626e  x5  6b6b60621f6a626e  x6  6b6b60621f6a626e  x7  7f
7f7f7f7f7f7f7f
02-13 10:27:18.617 30061 30061 F DEBUG   :     x8  00000000000000f0  x9  00000078ef691050  x10 0000000000000001  x11 00
000078ef6dab60
02-13 10:27:18.617 30061 30061 F DEBUG   :     x12 00000078f7e40020  x13 000000007fffffff  x14 0000000003e8c534  x15 00
00097a8ebec5f6
02-13 10:27:18.617 30061 30061 F DEBUG   :     x16 00000078ef746cf8  x17 00000078ef723470  x18 000000756cb60000  x19 00
00000000005caf
02-13 10:27:18.617 30061 30061 F DEBUG   :     x20 0000000000005cd5  x21 00000000ffffffff  x22 0000000003141592  x23 00
00007574329000
02-13 10:27:18.617 30061 30061 F DEBUG   :     x24 0000007574327600  x25 0000000000000001  x26 0000000000000960  x27 00
00000000000438
02-13 10:27:18.617 30061 30061 F DEBUG   :     x28 0000007574329000  x29 0000007574327310
02-13 10:27:18.617 30061 30061 F DEBUG   :     lr  00000078ef6cb178  sp  0000007574327270  pc  00000078ef6cb1a4  pst 00
00000000001000
02-13 10:27:18.617 30061 30061 F DEBUG   : 31 total frames
02-13 10:27:18.617 30061 30061 F DEBUG   : backtrace:
02-13 10:27:18.617 30061 30061 F DEBUG   :       #00 pc 000000000005c1a4  /apex/com.android.runtime/lib64/bionic/libc.s
o (abort+164) (BuildId: 19c32900d9d702c303d2b4164fbba76c)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #01 pc 000000000005e10c  /apex/com.android.runtime/lib64/bionic/libc.s
o (__fortify_fatal(char const*, ...)+124) (BuildId: 19c32900d9d702c303d2b4164fbba76c)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #02 pc 00000000000cb08c  /apex/com.android.runtime/lib64/bionic/libc.s
o (HandleUsingDestroyedMutex(pthread_mutex_t*, char const*)+60) (BuildId: 19c32900d9d702c303d2b4164fbba76c)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #03 pc 00000000000caf20  /apex/com.android.runtime/lib64/bionic/libc.s
o (pthread_mutex_lock+208) (BuildId: 19c32900d9d702c303d2b4164fbba76c)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #04 pc 000000000004e0a8  /apex/com.android.vndk.v34/lib64/libc++.so (s
td::__1::mutex::lock()+8) (BuildId: b943576b13bab3840a43769b64a94e88)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #05 pc 0000000000022144  /vendor/lib64/hw/android.hardware.graphics.ma
pper@4.0-impl.so (BufferManager::retain(native_handle const*)+84) (BuildId: e65795567f90475a14dff55aed4c7dd6)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #06 pc 0000000000012b08  /vendor/lib64/hw/android.hardware.graphics.ma
pper@4.0-impl.so (arm::mapper::common::importBuffer(android::hardware::hidl_handle const&, std::__1::function<void (and
roid::hardware::graphics::mapper::V4_0::Error, void*)>)+120) (BuildId: e65795567f90475a14dff55aed4c7dd6)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #07 pc 00000000000113ac  /vendor/lib64/hw/android.hardware.graphics.ma
pper@4.0-impl.so (arm::mapper::GrallocMapper::importBuffer(android::hardware::hidl_handle const&, std::__1::function<vo
id (android::hardware::graphics::mapper::V4_0::Error, void*)>)+124) (BuildId: e65795567f90475a14dff55aed4c7dd6)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #08 pc 0000000000016634  /system/lib64/android.hardware.graphics.mappe
r@4.0.so (android::hardware::graphics::mapper::V4_0::BsMapper::importBuffer(android::hardware::hidl_handle const&, std:
:__1::function<void (android::hardware::graphics::mapper::V4_0::Error, void*)>)+132) (BuildId: 5b7788f34d654d544830e5fb
59ec2e63)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #09 pc 000000000003e8c8  /system/lib64/libui.so (android::Gralloc4Mapp
er::importBuffer(native_handle const*, native_handle const**) const+120) (BuildId: 7572b8a958e72a3ff726aeef7f8f37b4)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #10 pc 00000000000318ec  /system/lib64/libui.so (android::GraphicBuffe
rMapper::importBuffer(native_handle const*, unsigned int, unsigned int, unsigned int, int, unsigned long, unsigned int,
 native_handle const**)+108) (BuildId: 7572b8a958e72a3ff726aeef7f8f37b4)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #11 pc 0000000000034d3c  /system/lib64/libui.so (android::GraphicBuffe
r::unflatten(void const*&, unsigned long&, int const*&, unsigned long&)+444) (BuildId: 7572b8a958e72a3ff726aeef7f8f37b4
)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #12 pc 0000000000026128  /system/lib64/libmedia_omx.so (android::hardw
are::media::omx::V1_0::utils::convertTo(android::GraphicBuffer*, android::hardware::media::V1_0::AnwBuffer const&)+376)
 (BuildId: c541d41a23e7ff4ec3ce17cd40c544c8)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #13 pc 0000000000025e00  /system/lib64/libmedia_omx.so (android::hardw
are::media::omx::V1_0::utils::convertTo(android::OMXBuffer*, android::hardware::media::omx::V1_0::CodecBuffer const&)+4
00) (BuildId: c541d41a23e7ff4ec3ce17cd40c544c8)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #14 pc 00000000000255e4  /system/lib64/libmedia_omx.so (android::hardw
are::media::omx::V1_0::utils::TWOmxNode::emptyBuffer(unsigned int, android::hardware::media::omx::V1_0::CodecBuffer con
st&, unsigned int, unsigned long, android::hardware::hidl_handle const&)+100) (BuildId: c541d41a23e7ff4ec3ce17cd40c544c
8)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #15 pc 000000000003dd78  /system/lib64/libstagefright_omx.so (android:
:hardware::media::omx::V1_0::implementation::TWGraphicBufferSource::TWOmxNodeWrapper::emptyBuffer(int, unsigned int, an
droid::sp<android::GraphicBuffer> const&, long, int)+312) (BuildId: 8d716a2cf486804a50b1fe56fc45686a)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #16 pc 000000000000c260  /system/lib64/libstagefright_bufferqueue_help
er.so (android::GraphicBufferSource::submitBuffer_l(android::GraphicBufferSource::VideoBuffer const&)+752) (BuildId: 46
a728db4640bd335560d48cbec1b27e)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #17 pc 000000000000b758  /system/lib64/libstagefright_bufferqueue_help
er.so (android::GraphicBufferSource::fillCodecBuffer_l()+968) (BuildId: 46a728db4640bd335560d48cbec1b27e)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #18 pc 000000000000a9d4  /system/lib64/libstagefright_bufferqueue_help
er.so (android::GraphicBufferSource::onFrameAvailable(android::BufferItem const&)+292) (BuildId: 46a728db4640bd335560d4
8cbec1b27e)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #19 pc 0000000000009d58  /system/lib64/libstagefright_bufferqueue_help
er.so (android::GraphicBufferSource::ConsumerProxy::onFrameAvailable(android::BufferItem const&)+104) (BuildId: 46a728d
b4640bd335560d48cbec1b27e)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #20 pc 00000000000ef4ec  /system/lib64/libgui.so (android::BufferQueue
::ProxyConsumerListener::onFrameAvailable(android::BufferItem const&)+92) (BuildId: c76ca08a7f5b2af5ba32a74bee6ae2e9)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #21 pc 00000000000df17c  /system/lib64/libgui.so (android::BufferQueue
Producer::queueBuffer(int, android::IGraphicBufferProducer::QueueBufferInput const&, android::IGraphicBufferProducer::Q
ueueBufferOutput*)+2316) (BuildId: c76ca08a7f5b2af5ba32a74bee6ae2e9)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #22 pc 00000000001169c4  /system/lib64/libgui.so (android::BnGraphicBu
fferProducer::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+612) (BuildId: c76ca08a7
f5b2af5ba32a74bee6ae2e9)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #23 pc 0000000000068088  /system/lib64/libbinder.so (android::BBinder:
:transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+248) (BuildId: 66b89443e02390ede8efed54
005902da)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #24 pc 0000000000066d34  /system/lib64/libbinder.so (android::IPCThrea
dState::executeCommand(int)+500) (BuildId: 66b89443e02390ede8efed54005902da)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #25 pc 0000000000085df4  /system/lib64/libbinder.so (android::IPCThrea
dState::joinThreadPool(bool)+596) (BuildId: 66b89443e02390ede8efed54005902da)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #26 pc 0000000000085b88  /system/lib64/libbinder.so (android::PoolThre
ad::threadLoop()+24) (BuildId: 66b89443e02390ede8efed54005902da)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #27 pc 000000000000fd70  /system/lib64/libutils.so (android::Thread::_
threadLoop(void*)+480) (BuildId: 4ce5249405dff1a8480d738901c940d4)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #28 pc 00000000000e719c  /system/lib64/libandroid_runtime.so (android:
:AndroidRuntime::javaThreadShell(void*)+140) (BuildId: 151eb211a9e62bdd846be20679c2a65c)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #29 pc 00000000000c9ccc  /apex/com.android.runtime/lib64/bionic/libc.s
o (__pthread_start(void*)+204) (BuildId: 19c32900d9d702c303d2b4164fbba76c)
02-13 10:27:18.617 30061 30061 F DEBUG   :       #30 pc 000000000005db00  /apex/com.android.runtime/lib64/bionic/libc.s
o (__start_thread+64) (BuildId: 19c32900d9d702c303d2b4164fbba76c)
02-13 12:46:29.855 32182 19402 E AndroidRuntime: FATAL EXCEPTION: Thread-650
02-13 12:46:29.855 32182 19402 E AndroidRuntime: Process: org.mozilla.firefox, PID: 32182
02-13 12:46:29.855 32182 19402 E AndroidRuntime: android.opengl.GLException: Failed to create EGL context: 0x3000
02-13 12:46:29.855 32182 19402 E AndroidRuntime:        at org.webrtc.EglBase14Impl$EglConnection.<init>(EglBase14Impl.
java:20)
02-13 12:46:29.855 32182 19402 E AndroidRuntime:        at org.webrtc.EglBase14Impl.<init>(EglBase14Impl.java:10)
02-13 12:46:29.855 32182 19402 E AndroidRuntime:        at org.webrtc.EglBase$-CC.create(EglBase.java:6)
02-13 12:46:29.855 32182 19402 E AndroidRuntime:        at org.webrtc.videoengine.VideoCaptureAndroid.<init>(VideoCaptu
reAndroid.java:94)
WorldThirteen commented 8 months ago

@rmdvector, could you share the video size configuration you are trying to use. I might try to reproduce on device simulator or manage to find physical device.

I also think it is not related to GammaCV directly, as it uses standard WebGL API and can not get any lower. And for the date have not seen such an issue before.

rmdvector commented 8 months ago

Width is passed in as 3000, height as 4000, the intent to get 3072 x 2144


      audio: false,
      video: {
        facingMode: 'environment',
        width: { ideal: width },
        height: { ideal: height },
      },
    };```
rmdvector commented 8 months ago

Though I seem to get 1920x1920