webaudio-raub
webaudio-raub copied to clipboard
Not working on OX 11.6 (Big Sur) and won't compile either
Trying to npm install this on Big Sur and running one of the examples I get the following unhelpful error message:
FATAL ERROR: Error::New napi_get_last_error_info
1: 0x1060efd75 node::Abort() [/usr/local/bin/node]
2: 0x1060efef7 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
3: 0x1060efd8b node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
4: 0x1060c65d8 napi_fatal_error [/usr/local/bin/node]
5: 0x115b35e1b Napi::Error::Fatal(char const*, char const*) [/Users/vabrams/popeye/webaudio-raub/bin-osx/webaudio.node]
6: 0x115b4ce0b Napi::Error::New(napi_env__*) [/Users/vabrams/popeye/webaudio-raub/bin-osx/webaudio.node]
7: 0x115b4d6a8 Napi::Function::Call(napi_value__*, unsigned long, napi_value__* const*) const [/Users/vabrams/popeye/webaudio-raub/bin-osx/webaudio.node]
8: 0x115b46843 BaseAudioContext::_destroy() [/Users/vabrams/popeye/webaudio-raub/bin-osx/webaudio.node]
9: 0x115b46730 BaseAudioContext::~BaseAudioContext() [/Users/vabrams/popeye/webaudio-raub/bin-osx/webaudio.node]
10: 0x115b45aea BaseAudioContext::_finalizeEs5(napi_env__*, void*, void*) [/Users/vabrams/popeye/webaudio-raub/bin-osx/webaudio.node]
11: 0x1060c903f node::CallbackQueue<void, node::Environment*>::CallbackImpl<node_napi_env__::CallFinalizer(void (*)(napi_env__*, void*, void*), void*, void*)::$_0>::Call(node::Environment*) [/usr/local/bin/node]
12: 0x1060a2239 node::Environment::RunAndClearNativeImmediates(bool)::$_7::operator()(node::CallbackQueue<void, node::Environment*>*) const [/usr/local/bin/node]
13: 0x1060a1cb7 node::Environment::RunAndClearNativeImmediates(bool) [/usr/local/bin/node]
14: 0x1060a17b8 node::Environment::CheckImmediate(uv_check_s*) [/usr/local/bin/node]
15: 0x10843226b uv__run_check [/usr/local/opt/libuv/lib/libuv.1.dylib]
16: 0x10842ce56 uv_run [/usr/local/opt/libuv/lib/libuv.1.dylib]
17: 0x10603c4f7 node::SpinEventLoop(node::Environment*) [/usr/local/bin/node]
18: 0x1061288ff node::NodeMainInstance::Run(int*, node::Environment*) [/usr/local/bin/node]
19: 0x106128592 node::NodeMainInstance::Run(node::EnvSerializeInfo const*) [/usr/local/bin/node]
20: 0x1060c4e8a node::Start(int, char**) [/usr/local/bin/node]
21: 0x7fff203fcf3d start [/usr/lib/system/libdyld.dylib]
22: 0x2
In order to resolve it I attempted to rebuild this using node-gyp rebuild
, but this fails as well
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:4031:5: error: static_assert failed due to requirement 'is_constructible<lab::AnalyserNode>::value' "Can't construct object in make_shared"
static_assert(is_constructible<_Tp, _Args...>::value, "Can't construct object in make_shared");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../cpp/analyser-node.cpp:30:22: note: in instantiation of function template specialization 'std::__1::make_shared<lab::AnalyserNode>' requested here
reset(context, std::make_shared<lab::AnalyserNode>());
^
In file included from ../cpp/analyser-node.cpp:1:
In file included from ../cpp/analyser-node.hpp:4:
In file included from ../cpp/common.hpp:4:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:1917:46: error: no matching constructor for initialization of 'lab::AnalyserNode'
__compressed_pair_elem(__value_init_tag) : __value_() {}
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:2010:42: note: in instantiation of member function 'std::__1::__compressed_pair_elem<lab::AnalyserNode, 1, false>::__compressed_pair_elem' requested here
: _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:3291:12: note: in instantiation of function template specialization 'std::__1::__compressed_pair<std::__1::allocator<lab::AnalyserNode>, lab::AnalyserNode>::__compressed_pair<std::__1::allocator<lab::AnalyserNode>, std::__1::__value_init_tag>' requested here
: __data_(_VSTD::move(__a), __value_init_tag()) {}
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:4038:26: note: in instantiation of member function 'std::__1::__shared_ptr_emplace<lab::AnalyserNode, std::__1::allocator<lab::AnalyserNode>>::__shared_ptr_emplace' requested here
::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...);
^
../cpp/analyser-node.cpp:30:22: note: in instantiation of function template specialization 'std::__1::make_shared<lab::AnalyserNode>' requested here
reset(context, std::make_shared<lab::AnalyserNode>());
^
/Users/vabrams/popeye/deps-labsound-raub/include/LabSound/core/AnalyserNode.h:32:5: note: candidate constructor not viable: requires single argument 'ac', but no arguments were provided
AnalyserNode(AudioContext & ac);
^
/Users/vabrams/popeye/deps-labsound-raub/include/LabSound/core/AnalyserNode.h:21:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
class AnalyserNode : public AudioBasicInspectorNode
^
/Users/vabrams/popeye/deps-labsound-raub/include/LabSound/core/AnalyserNode.h:33:5: note: candidate constructor not viable: requires 2 arguments, but 0 were provided
AnalyserNode(AudioContext & ac, int fftSize);
^
It looks like make_shared requires a constructor without parameters to function. Not sure why this wasn't failing previously. Any tips on how to fix it?
So I sorted the build error. Apparently this was built with the 2.0.0 tag of deps-labsound-raub and hasn't yet been updated to use the new libsound headers. Unfortunately, despite now being able to build the module, I haven't yet been able to get it to run. i managed to build the v2.0.0 tag of deps-labsound-raub, but when I rebuild this module against that version I seem to be missing some symbols:
dyld: lazy symbol binding failed: Symbol not found: __ZN3lab19MakeAudioDeviceListEv
Referenced from: /Users/vabrams/popeye/webaudio-raub/bin-osx/webaudio.node
Expected in: flat namespace
dyld: Symbol not found: __ZN3lab19MakeAudioDeviceListEv
Referenced from: /Users/vabrams/popeye/webaudio-raub/bin-osx/webaudio.node
Expected in: flat namespace
Abort trap: 6
So the ldflags were not making it into the build. It looks like node-gyp doesn't like this way of specifying ldflags any more on osx. I had to switch it to:
diff --git a/src/binding.gyp b/src/binding.gyp
index 4225cb8..13e474f 100644
--- a/src/binding.gyp
+++ b/src/binding.gyp
@@ -70,7 +70,8 @@
'OS=="mac"',
{
'cflags_cc': ['-w'],
- 'ldflags': [
+ "xcode_settings": {
+ "OTHER_LDFLAGS": [
'-L<(ls_bin)',
'-Wl,-rpath,@loader_path',
'-Wl,-rpath,@loader_path/../node_modules/deps-labsound-raub/<(bin)',
@@ -79,7 +80,8 @@
'-framework AudioUnit',
'-framework CoreAudio',
'-framework AudioToolbox',
- ],
+ ]
+ },
I then had to rename LabSound.a to libLabSound.a to get the linker to find it. That got me past the symbol not found error, but I am unfortunately back to the original napi error.
So, interestingly, the initial bug only happens if i create the audio context and immediately let it go out of scope. If i delay for a while the napi error goes away. So definitely made some progress. Unfortunately, i don't actually hear any sound from the speakers :(. So one step forward and two steps back
Hello! @vishvananda I'm not sure if that helps, but we could try and see if LabSound would work on OSX - https://github.com/LabSound/LabSound .
deps-labsound-raub - exists to deliver the LabSound binaries and headers from NPM and GitHub (and set up the correct paths for Node.js to reach them).
webaudio-raub - works to map the LabSound API to something close to WebAudio. Then if LabSound works for you (if you actually hear the sound) on its own, it means there is something wrong in webaudio-raub. Either it is something connected to building it, or there is an issue with controlling the LabSound backend properly.
I don't have an OSX machine and only use GitHub actions to build the libraries. I can't test if it actually makes any sound in case of a successful OSX build. This is why I've never had a way to debug it properly on OSX.
Also, I had been in the middle of a major update, at some point. LabSound had changed a lot in their API since [email protected] and that is reflected in https://github.com/node-3d/deps-labsound-raub/releases/tag/v3.0.1 . But I'm yet to sort out the build issues with that version.
@vishvananda can you try the new version 3.0.0? it seems to work in GitHub actions on macos-11
If you have a problem on mac with the latest LabSound version, let me know (on the LabSound Issues page). The main branch of LabSound has been stable for some months now, so I expect it to work for you.
@raub if you have any issues with new changes, please let me know. Hopefully everything is straight forward, and stable.