joelpurra / uvcc

USB Video Class (UVC) device configurator. Used for webcams, camcorders, etcetera. Command line interface for automation.
https://joelpurra.com/projects/uvcc/
GNU General Public License v3.0
95 stars 5 forks source link

package errors after node/npm upgrade #19

Closed ymendel closed 2 years ago

ymendel commented 2 years ago

After a recent node/npm upgrade, uvcc has stopped working for me. Simple commands like uvcc help work, but trying to change anything or get a list of devices fails, and looking through this output I can't tell why:

$ uvcc devices
FATAL ERROR:  
 1: 0x10a5eb70c node::Abort() [/usr/local/bin/node]
 2: 0x10a5ec73d node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0x10a5ec5a6 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x10a5b94a3 napi_open_callback_scope [/usr/local/bin/node]
 5: 0x10ec7f79a  [/usr/local/lib/node_modules/uvcc/node_modules/usb/prebuilds/darwin-x64+arm64/node.napi.node]
 6: 0x10ec91cec handleCompletion(Transfer*) [/usr/local/lib/node_modules/uvcc/node_modules/usb/prebuilds/darwin-x64+arm64/node.napi.node]
 7: 0x10ec85ca5 Napi::ThreadSafeFunction::CallJS(napi_env__*, napi_value__*, void*, void*) [/usr/local/lib/node_modules/uvcc/node_modules/usb/prebuilds/darwin-x64+arm64/node.napi.node]
 8: 0x10a5bb1d1 v8impl::(anonymous namespace)::ThreadSafeFunction::AsyncCb(uv_async_s*) [/usr/local/bin/node]
 9: 0x10c84da10 uv__async_io [/usr/local/opt/libuv/lib/libuv.1.dylib]
10: 0x10c85d773 uv__io_poll [/usr/local/opt/libuv/lib/libuv.1.dylib]
11: 0x10c84de46 uv_run [/usr/local/opt/libuv/lib/libuv.1.dylib]
12: 0x10a595990 node::Environment::CleanupHandles() [/usr/local/bin/node]
13: 0x10a595acc node::Environment::RunCleanup() [/usr/local/bin/node]
14: 0x10a51e15f node::FreeEnvironment(node::Environment*) [/usr/local/bin/node]
15: 0x10a62a343 node::NodeMainInstance::Run(node::EnvSerializeInfo const*) [/usr/local/bin/node]
16: 0x10a5b8270 node::Start(int, char**) [/usr/local/bin/node]
17: 0x7fff2040bf3d start [/usr/lib/system/libdyld.dylib]
18: 0x3 
Abort trap: 6

From looking at another issue, I tried uninstalling and re-installing with uvcc@latest, and it's still erroring.

More info for you:

$ node --version
v17.0.1
$ npm --version
8.1.0
$ npm list --global
/usr/local/lib
├── npm@8.1.0
└── uvcc@5.0.0

on MacOS Big Sur, v11.6

joelpurra commented 2 years ago

@ymendel: thanks for the report! Looking at the log output, this seems related to https://github.com/node-usb/node-usb/issues/418, which specifically mentions ThreadSafeFunction and was closed a couple of days ago. That fix is included in node-usb v1.8.1 (and v1.9.0), but it seems they don't work as expected for everyone. I don't see the same issue on my machine, perhaps due to having some debug versions of some libraries installed, so would appreciate if you can report the bug to https://github.com/node-usb/node-usb!

By the way, you can also check the version of node-usb currently in use with:

npm list --global usb

Sample output:

.../npm/lib
└─┬ uvcc@5.0.1
  └─┬ uvc-control@2.0.0 invalid: "github:joelpurra/node-uvc-control#v2" from node_modules/uvcc
    └── usb@1.8.0

Since node-usb v1.8.0 was confirmed to work with uvcc v5.0.0 in https://github.com/joelpurra/uvcc/issues/18, I'll pin that version for now (despite delays at program exit reported in https://github.com/joelpurra/uvcc/issues/16).

Just published uvcc v5.0.1. Install/upgrade with:

npm install --global uvcc@latest

Does this version work?

ymendel commented 2 years ago

@joelpurra : Cool, v5.0.1 definitely works, but it does have that unfortunate delay of program exit you mentioned in #16 . I mean, this output from time uvcc devices is no fun, but it's still better than things not working 😒

real    0m8.897s
user    0m0.275s
sys 0m0.104s

I'll definitely go over to node-usb and see what's going on there. Thanks a lot for the quick response, and for making it easy to keep my face from being too bright and blown-out in all the video meetings I have nowadays.

joelpurra commented 2 years ago

@ymendel: glad to hear, thanks for confirming! Closing the issue, but please report back if there's progress upstream.

If you want a hacky workaround, you can always do something like:

time timeout 0.5s uvcc devices

The minimum timeout is system dependent. An alias could cement the hack. See GNU coreutils and documentation for timeout.