lsp-plugins icon indicating copy to clipboard operation
lsp-plugins copied to clipboard

VST3 builds have incorrect window position and causes DAW crash.

Open Olnium opened this issue 1 year ago • 15 comments

VST3 versions of the plugins build without errors, however, upon loading in DAW, the plugin GUI is shifted down and to the right, leaving a blank grey border to the top and left of the plugin window. System then locks up and causes DAW to crash (Plugin crashes should be contained in Bitwig's plugin sandbox). See attached image. LV2, CLAP & VST2 build without errors and run without issue.

Build System: MinGW-w64 Build Target: Windows x64 Build Platform: Windows 11 Pro; AMD Ryzen DAW: Bitwig Studio

LSP-VST3

Olnium avatar Mar 06 '24 03:03 Olnium

Fixed the incorrect position of the window in Bitwig.

Meanwhile, I tried to investigate the problem about why plugins hang up the Bitwig and it seems to be the following.

LSP Plugins use extensive VST3 message exchange mechanism: they form a message, fill it with content and send it to a peer. Both sides (Controller and Processor) can generate messages but Processor does it regularly for sending music position to the Controller or mesh data.

According to unknown reason, when this exchange occurs, the memory used by Bitwig starts to grow and finally it goes out of memory. When there is no message allocation and disposal cycles, the memory does not grow and all works fine except that UI does not show graphic data on a graph because did not receive it from backend.

Messages are reference-counted objects and I validated that the number of references to the message is proper (that means one) before it becomes disposed. But I'm not sure that it gets disposed or gets disposed completely/correct.

I suppose that it is someway related to the Bitwig because REAPER DAW that also is used for tests doesn't leak memory under the same conditions and it is a good reason to ask Bitwig developers about the proper implementation of the Steinberg::Vst::IMessage disposal.

sadko4u avatar Mar 21 '24 00:03 sadko4u

Hi @sadko4u, Maybe you're not doing the ref counting right.

Keep in mind that when you ask the host to create the Message object for you, it already has a refcount of 1.

#define FUNKNOWN_CTOR	{ __funknownRefCount = 1; }

abique avatar Mar 29 '24 12:03 abique

@abique No. I do the refcounting in the following manner:

message.acquire();
uint32_t count = message.release();

lsp_trace("message references=%d", int(count));

sadko4u avatar Mar 29 '24 17:03 sadko4u

The interesting part is where you create the message.

abique avatar Mar 29 '24 17:03 abique

Here is an example how the message becomes created and sent: https://github.com/lsp-plugins/lsp-plugin-fw/blob/f4a725c5366b5540b6e11155bdf6454111cc25b5/include/lsp-plug.in/plug-fw/wrap/vst3/impl/wrapper.h#L2999-L3054

The alloc_message function: https://github.com/lsp-plugins/lsp-plugin-fw/blob/f4a725c5366b5540b6e11155bdf6454111cc25b5/include/lsp-plug.in/plug-fw/wrap/vst3/helpers.h#L655-L671

sadko4u avatar Mar 29 '24 17:03 sadko4u

@abique any ideas?

sadko4u avatar Mar 30 '24 13:03 sadko4u

Hi @abique !

I did one more investigation and just replaced the Bitwig's implementation of Steinberg::Vst::IMessage by mine trivial one:

https://github.com/lsp-plugins/lsp-plugin-fw/blob/devel/include/lsp-plug.in/plug-fw/wrap/vst3/message.h https://github.com/lsp-plugins/lsp-plugin-fw/blob/devel/include/lsp-plug.in/plug-fw/wrap/vst3/impl/message.h

After activating this line the memory stopped leaking in Bitwig: https://github.com/lsp-plugins/lsp-plugin-fw/blob/f95db8ee03e646b5288d065a27d4ad3bbb24c637/include/lsp-plug.in/plug-fw/wrap/vst3/helpers.h#L674

So now I for sure consider the message exchange mechanism being broken in @bitwig.

@vosc @kurasu FYI

sadko4u avatar Apr 03 '24 19:04 sadko4u

I'll try it tomorrow.

abique avatar Apr 03 '24 19:04 abique

By the way do you have plans to update the arch package to bundle vst3 as well?

abique avatar Apr 03 '24 19:04 abique

@abique I'm not responsible for packaging LSP for Arch Linux. I think @dvzrv is the right person to ask for it.

sadko4u avatar Apr 03 '24 20:04 sadko4u

Added workaround that enables LSP's implemented Steinberg::Vst::IMessage interface for Bitwig Studio.

sadko4u avatar Apr 03 '24 22:04 sadko4u

I think I found the problem in Bitwig's code. About to test it.

abique avatar Apr 04 '24 07:04 abique

I've tried to build the plugin, but it didn't build vst3 it seems.

abique avatar Apr 04 '24 07:04 abique

Ah, there's a binary distribution here: https://sourceforge.net/projects/lsp-plugins/files/lsp-plugins/1.2.15/Linux-x86_64/

abique avatar Apr 04 '24 07:04 abique

Memory isn't growing here. I believe I've fixed it.

Thanks for the report :+1:, will likely be in 5.1.8.

abique avatar Apr 04 '24 07:04 abique

Fixes and workarounds in 1.2.16!

sadko4u avatar May 22 '24 21:05 sadko4u

Window position confirmed fixed with latest release. Will monitor stability going forward.

Olnium avatar May 22 '24 22:05 Olnium