Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VST stupid hack to make Bitwig Linux work #109

Merged
merged 2 commits into from
Mar 12, 2020

Conversation

jpcima
Copy link
Collaborator

@jpcima jpcima commented Mar 9, 2020

The host-side X11 event loop is broken, it never notifies events.
Thankfully, we have a way of fixing Bitwig in the plugin. 🤡

Bitwig provides a working timer notification. This timer notification is a place where we are able to process X11 events.
Solution: create a periodic timer; as long as no events arrive in the X11 socket notifier, keep processing events in the callback of our timer.

@tank-trax

@jpcima
Copy link
Collaborator Author

jpcima commented Mar 9, 2020

Not really, there is still a case of failure if you

  1. open the editor
  2. open the sfz file chooser
  3. it hangs when trying to close if (only when step 2., otherwise fine)

Gdb stack of attached debugger to the plugin bridge process

Using host libthread_db library "/usr/lib/libthread_db.so.1".
0x00007fb5a92b099a in __lll_lock_wait_private () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007fb5a92b099a in __lll_lock_wait_private () from /usr/lib/libc.so.6
#1  0x00007fb5a92b604b in malloc () from /usr/lib/libc.so.6
#2  0x00007fb5a9337916 in backtrace_symbols () from /usr/lib/libc.so.6
#3  0x0000000000504e6e in base::core::getStackTrace() ()
#4  0x0000000000505bd2 in ?? ()
#5  <signal handler called>
#6  0x00007fb5a92b40fa in _int_malloc () from /usr/lib/libc.so.6
#7  0x00007fb5a92b6c05 in calloc () from /usr/lib/libc.so.6
#8  0x00007fb5a2efb54a in ?? () from /usr/lib/libcairo.so.2
#9  0x00007fb5a2f30ae9 in ?? () from /usr/lib/libcairo.so.2
#10 0x00007fb5a2f3130c in ?? () from /usr/lib/libcairo.so.2
#11 0x00007fb5a2f7f94d in ?? () from /usr/lib/libcairo.so.2
#12 0x00007fb5a2f716b9 in ?? () from /usr/lib/libcairo.so.2
#13 0x00007fb5a2ef4795 in cairo_device_finish () from /usr/lib/libcairo.so.2
#14 0x00007fb5a367272e in VSTGUI::X11::DrawHandler::~DrawHandler (this=0x1f9e6c8, __in_chrg=<optimized out>)
    at /home/jpc/documents/projects/sfizz/vst/external/VST_SDK/VST3_SDK/vstgui4/vstgui/lib/platform/linux/x11frame.cpp:136
#15 VSTGUI::X11::Frame::Impl::~Impl (this=0x1f9e6a0, __in_chrg=<optimized out>)
    at /home/jpc/documents/projects/sfizz/vst/external/VST_SDK/VST3_SDK/vstgui4/vstgui/lib/platform/linux/x11frame.cpp:283
#16 std::default_delete<VSTGUI::X11::Frame::Impl>::operator() (this=<optimized out>, __ptr=0x1f9e6a0)
    at /usr/include/c++/9.2.1/bits/unique_ptr.h:81
#17 std::default_delete<VSTGUI::X11::Frame::Impl>::operator() (this=0x7fb5a4001018, __ptr=0x1f9e6a0)
    at /usr/include/c++/9.2.1/bits/unique_ptr.h:75
#18 std::unique_ptr<VSTGUI::X11::Frame::Impl, std::default_delete<VSTGUI::X11::Frame::Impl> >::reset (__p=0x1f9e6a0, 
    this=0x7fb5a4001018) at /usr/include/c++/9.2.1/bits/unique_ptr.h:394
#19 VSTGUI::X11::Frame::~Frame (this=0x7fb5a4000ff0, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /home/jpc/documents/projects/sfizz/vst/external/VST_SDK/VST3_SDK/vstgui4/vstgui/lib/platform/linux/x11frame.cpp:581
#20 0x00007fb5a3672892 in VSTGUI::X11::Frame::~Frame (this=0x7fb5a4000ff0, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /home/jpc/documents/projects/sfizz/vst/external/VST_SDK/VST3_SDK/vstgui4/vstgui/lib/platform/linux/x11frame.cpp:579
#21 0x00007fb5a35fda31 in VSTGUI::SharedPointer<VSTGUI::IPlatformFrame>::operator= (_ptr=0x0, this=0x2356730)
    at /home/jpc/documents/projects/sfizz/vst/external/VST_SDK/VST3_SDK/vstgui4/vstgui/lib/vstguibase.h:438
#22 VSTGUI::CFrame::beforeDelete (this=0x7fb5a4001030)
    at /home/jpc/documents/projects/sfizz/vst/external/VST_SDK/VST3_SDK/vstgui4/vstgui/lib/cframe.cpp:169
#23 0x00007fb5a35b2699 in VSTGUI::ReferenceCounted<int>::forget (this=0x7fb5a4001030)
    at /home/jpc/documents/projects/sfizz/vst/external/VST_SDK/VST3_SDK/vstgui4/vstgui/lib/vstguibase.h:276
#24 VSTGUI::ReferenceCounted<int>::forget (this=0x7fb5a4001030)
    at /home/jpc/documents/projects/sfizz/vst/external/VST_SDK/VST3_SDK/vstgui4/vstgui/lib/vstguibase.h:276
#25 0x00007fb5a35afcba in SfizzVstEditor::close (this=0x1b58700) at /home/jpc/documents/projects/sfizz/vst/SfizzVstEditor.cpp:64
#26 0x00007fb5a3677de8 in Steinberg::Vst::VSTGUIEditor::removed (this=0x1b58700)
    at /home/jpc/documents/projects/sfizz/vst/external/VST_SDK/VST3_SDK/public.sdk/source/vst/vstguieditor.cpp:191
--Type <RET> for more, q to quit, c to continue without paging--
#27 0x0000000000524da1 in Vst3PluginInstance::closeGUI() ()
#28 0x000000000053534c in PluginHost::handleXcbEvent(xcb_generic_event_t const*) ()
#29 0x0000000000537ff1 in ?? ()
#30 0x0000000000503611 in base::core::Epoll::wait(int) ()
#31 0x0000000000538aed in PluginHost::run() ()
#32 0x00000000004cdf1f in main ()

@paulfd
Copy link
Member

paulfd commented Mar 11, 2020

Would this be related to the use of zenity for this dialog box?

@jpcima
Copy link
Collaborator Author

jpcima commented Mar 11, 2020

I sincerely don't know at this point.
It's very difficult debugging in Bitwig, given the plugin is under bridge and the main host is a Java-based thing. Difficult to deduce where crashes are coming from in this situation.

From what I can at least tell, Bitwig host is buggy in that it never notifies the plugin of X11 events.
I'm guessing Bitwig is using Steinberg hosting code from SDK, which has a know dumg bug polling the Fd, which I believe was discovered by one of iPlug guys.

@paulfd
Copy link
Member

paulfd commented Mar 11, 2020

Heh... Well, do they care enough to try and fix this?

@jpcima
Copy link
Collaborator Author

jpcima commented Mar 11, 2020

For reference, it's this inelegantly written bug report, the probable reason why fd select fails on Linux hosts.
steinbergmedia/vst3_public_sdk#16

@jpcima
Copy link
Collaborator Author

jpcima commented Mar 11, 2020

This makes Bitwig work and fixes all problems.
The loop processing in the idle callback is a little hack, but it's not different of VST2 originally works.

Note: to debug Bitwig, the way to do is substitute /opt/bitwig-studio/bin/BitwigPluginHost64 with a wrapper script that calls the real bridge in valgrind, and redirect the stderr to file.

@paulfd
Copy link
Member

paulfd commented Mar 12, 2020

Other than the small setEnable issue (which does not really pertain to this PR) I'm good with the changes :) We should probably add this to the current develop and tag the 0.3.1 release. The VST is marked as experimental anyway.

@jpcima jpcima merged commit 74f7290 into sfztools:develop Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants