Commit Graph

1816 Commits

Author SHA1 Message Date
Robbert van der Helm 62efc1c273 Also handle mutual recursion in *::getState()
VST3 plugins could freeze in REAPER when the plugin sends
`IComponentHandler::performEdit()` followed by
`IPlugFrame::resizeView()` when REAPER simultaneously tries to call
`*::getState()`. Here `*::getState()` gets called from the GUI thread,
while `IPlugFrame::resizeView()` has to be handled on REAPER's GUI
thread, resulting in a deadlock unless we use the plugin-side mutual
recursion mechanism.

I've seen this cause issues with PSPaudioware InfiniStrip.
2021-05-02 16:38:37 +02:00
Robbert van der Helm a83ff5a36a Fix wrong direction in cached VST3 call logging 2021-05-02 15:47:11 +02:00
Robbert van der Helm be984b342d Clarify the note about Ardour/Mixbus VST3 support
Outputs here refers to busses, but a bus can contain up to 64 channels.
2021-05-02 14:22:00 +02:00
Robbert van der Helm 5c88140c54 Also use mutual recursion for program list changes
The VST3 version of Voxengo TEOTE would deadlock in Ardour when Ardour
calls `IEditController::setState()`, the plugin calls
`IUnitHandler::notifyProgramListChange()` in response, and then when
Ardour calls `IUnitInfo::getProgramName()` while handling that callback.
All of these functions have to be called from the same thread in Voxengo
plugins.
2021-05-02 00:41:28 +02:00
Robbert van der Helm fd29c7d825 Skip X11 events when the window is not mapped
This fixes potential assertion failures in Ardour when Ardour unmaps
editor windows.
2021-05-01 23:22:59 +02:00
Robbert van der Helm 7bcc9ac181 Cancel group host shutdown timer with new request
Or else we will still shut down the host when loading the new plugin
takes a while.
2021-05-01 22:10:51 +02:00
Robbert van der Helm 448bfca0bc Reduce the initial shutdown timer on group hosts
This five seconds matches the five seconds on the first watchdog timer
proc.
2021-05-01 22:09:34 +02:00
Robbert van der Helm f3f2bfdc24 Fix deadlock caused by do_mutual_recursion_on_off_thread
Apparently the destructor for C++17/20 conditional initializers are only
run after the else branch, so this would keep the mutex locked while
executing `do_call()`.
2021-05-01 21:01:47 +02:00
Robbert van der Helm 459e7ac56b Fix syntax error in meson.build
As a result of 9daddb777b.
2021-05-01 19:31:44 +02:00
Robbert van der Helm 9daddb777b Fix unity builds
The version header was not being included in the correct unit,
sometimes.
2021-05-01 19:28:00 +02:00
Robbert van der Helm b103723df2 Make the watchdog much more aggressive
For individually hosted plugins this will behave the same. For plugin
groups it would have been nice if we could shut down individual plugins,
but dangling threads are apparently a real issue. This should be
equivalent in all use cases.

This also reverts commit bda9a0b75f.
2021-05-01 19:05:55 +02:00
Robbert van der Helm bbc93d7413 Catch all exceptions during initialization 2021-05-01 18:48:46 +02:00
Robbert van der Helm 5c2da36ecd Use a shorter delay for the first watchdog check 2021-05-01 18:47:45 +02:00
Robbert van der Helm 4ff538c7e1 Let group hosts shut down on their own if unused
We would never try to shut the group host down if nothing ever tried to
connect to it. This could happen when the native host gets killed after
initializing the yabridge plugin but before it gets the chance to
request the group host process to host a plugin.
2021-05-01 18:38:18 +02:00
Robbert van der Helm a91c1a3733 Reword the watchdog changelog entry 2021-05-01 18:12:42 +02:00
Robbert van der Helm 1065095ee2 Add a changelog entry for the watchdog 2021-05-01 18:08:05 +02:00
Robbert van der Helm 56afefeb53 Terminate all threads when initialization fails
With this the watchdog can correctly terminate VST2 bridges that get
stuck during initialization.
2021-05-01 17:58:46 +02:00
Robbert van der Helm bda9a0b75f Catch exceptions in failing host callbacks
This will let us more or less gracefully handle failing host callbacks
during initialization. We cannot catch this from anywhere else since
this these functions get called from unmanaged code.
2021-05-01 17:57:41 +02:00
Robbert van der Helm 832089d4d1 Implement the Wine host process watchdog
This will shut down a bridge's sockets when the connected native host
process exits, to prevent dangling Wine processes.
2021-05-01 17:54:22 +02:00
Robbert van der Helm e912bdd302 Also make sure that all group host threads exit
I actually don't know if this is necessary, but it was necessary for
individually hosted plugins, so presumably it's also needed here.
2021-05-01 17:20:13 +02:00
Robbert van der Helm 757fb6d372 Pass the PID of the native host to the Wine hosts
We need this for our watchdog.
2021-05-01 17:13:16 +02:00
Robbert van der Helm 071bb157ad Move the pid_running() function to common utils
We're going to need this for our watchdog.
2021-05-01 17:08:47 +02:00
Robbert van der Helm 131d749ba6 Register the Wine host bridge watchdog
It doesn't do anything yet.
2021-05-01 16:52:05 +02:00
Robbert van der Helm d8ca4022d1 Add universal way to shutdown sockets on Wine side 2021-05-01 16:51:55 +02:00
Robbert van der Helm 0f2db64aeb Add the pieces for a watchdog for dangling plugins
Once we register our plugins here, we should be able to gracefully shut
down any plugins whose remote process got killed.
2021-05-01 16:51:55 +02:00
Robbert van der Helm 167784f93b Prevent unnecessary copies in ScopedValueCache 2021-05-01 16:28:14 +02:00
Robbert van der Helm 7881e0116e Rename host_guard_handler to host_watchdog_handler
To keep the terminology consistent.
2021-05-01 15:46:27 +02:00
Robbert van der Helm aeca37d795 Rearrange src/wine-host/utils.h
We're going to need to spawn a Win32Thread in the MainContext to act as
a watchdog.
2021-05-01 15:46:27 +02:00
Robbert van der Helm b22f207aee Move the MainContext to HostBridge
We'll use this to create a watchdog timer that shuts down the sockets
when the native host gets terminated.
2021-05-01 15:06:13 +02:00
Robbert van der Helm 564e047b4b Remove the Ardour warning for VST3 plugins 2021-05-01 12:53:38 +02:00
Robbert van der Helm 5b28d44797 Define a static library for the Wine hosts
This means we only have to compile everything two times, instead of four
times. We sadly still need to compile lots of files at least three
times. (once for native, once for 64-bit Wine, and once for 32-bit Wine)
2021-05-01 01:09:58 +02:00
Robbert van der Helm 177431e202 Fix performEdit() deadlock in Ardour/Mixbus
Those DAWs would immediately call `IEditController::performEdit()` with
the same parameter change the plugin has just announced, which would
result in a deadlock. Hopefully this helps with #100.
2021-04-30 20:50:54 +02:00
Robbert van der Helm 2fe6b1c48d Clean up the main VST3 mutual recursion function 2021-04-30 20:44:50 +02:00
Robbert van der Helm 89d6c1b2e0 Fix assertion failure when reading end of stream
Getting the address of the end of a vector apparently raises an
assertion failure now, even if we didn't do anything with it.
2021-04-30 17:00:04 +02:00
Robbert van der Helm 588a8fd590 Better structure the meson.build file
It's been growing a bit over the last year.
2021-04-30 16:16:35 +02:00
Robbert van der Helm 5680ed5035 Enable additional assertions in debug builds 2021-04-30 16:06:50 +02:00
Robbert van der Helm 66be22b902 Clarify the REAPER context menu regression 2021-04-30 12:47:16 +02:00
Robbert van der Helm 36b3636072 Handle mutual recursion in context menus
REAPER will call `getState()` while the context menu is open, and that
also has to be handled from the GUI thread.
2021-04-30 02:49:54 +02:00
Robbert van der Helm 52428c8749 Also fix mutual recursion across both components
When setting the state on the audio processor, it can happen that plugin
triggers a resize from the edit controller. We should also be able to
handle that situation.
2021-04-30 02:11:24 +02:00
Robbert van der Helm 949ddaf673 Use mutual recursion for IEditController::setState
With this we should be able to handle `setState()`s that try to resize
the currently open editor. This could pop up when using the preset
browser in REAPER with plugins that recall their old size when loading a
preset.
2021-04-30 01:15:18 +02:00
Robbert van der Helm 0536256217 Add clamping to IBStream implementation seek 2021-04-29 23:40:42 +02:00
Robbert van der Helm cb07fd07a2 Handle mutual recursion while loading presets 2021-04-29 23:40:42 +02:00
Robbert van der Helm 74dd7f61a2 Fix ISizeableStream::getStreamSize implementation 2021-04-29 22:49:16 +02:00
Robbert van der Helm 4a92034620 Remove the recommendation for preferring VST3
At least for performance reasons, since with the changes in yabridge
3.2.0 they VST2 plugins perform as good or better depending on the
plugin groups settings. Using plugin groups is still less preferable
than using the VST3 version of course.
2021-04-29 19:21:19 +02:00
Robbert van der Helm 0f506f75e4 Bypass connection point proxies when possible
This greatly improves compatibility with VST3 plugins in Ardour and
Mixbus. Most notably the FabFilter plugins would previously freeze when
having the GUI open while duplicating or inserting new instances.
2021-04-29 15:36:28 +02:00
Robbert van der Helm e4177f2856 Avoid IAudioProcessor::isActive() on GUI thread
I haven't seen this cause any issues this way, and I could imagine that
this could cause some hangs when initializing a second instance of a
plugin while you're interacting with the GUI of the first instance.
2021-04-29 14:29:15 +02:00
Robbert van der Helm a56e4b337f Rename the VST3 mutual recursion functions 2021-04-29 14:03:15 +02:00
Robbert van der Helm 45d83ad9a1 Revert "Separate mutual recursion on GUI and other threads"
This reverts commit a495f1a67f.

This ended up not being an issue. What we _do_ have to do, sadly, is to
have a mutual recursion context stack per plugin. Otherwise multiple
plugin instances can deadlock eachother.
2021-04-29 13:54:48 +02:00
Robbert van der Helm a2e3e691d2 Change wording in the changelog 2021-04-29 12:30:19 +02:00
Robbert van der Helm a0abfed689 Merge the two prefetching changelog entries 2021-04-29 12:25:54 +02:00