mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Increase Win32 message limit for JUCE plugins
They aggressively use the message loop when parts of a plugin's UI change, sometimes sending as many is 2300 events at once. The old 20 messages per tick limit would cause severe slowdowns in this case.
This commit is contained in:
@@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic
|
||||
Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed sluggish UIs in _Output's Thermal_ and likely a handful of other
|
||||
JUCE-based plugins. These plugins would emit hundreds to thousands of events
|
||||
when the GUI changes. Yabridge now detects this, and removes the throttling we
|
||||
have in place to prevent certain other plugins from getting stuck in infinite
|
||||
loops.
|
||||
|
||||
## [3.7.0] - 2021-11-21
|
||||
|
||||
### Added
|
||||
|
||||
@@ -31,6 +31,22 @@
|
||||
*/
|
||||
constexpr int max_win32_messages = 20;
|
||||
|
||||
/**
|
||||
* Some JUCE based plugins however send thousands of `WM_USER+123` events
|
||||
* at once from the GUI. So while the limit from `win32_message_limit`
|
||||
* needs to exist, it also causes some other plugins to feel sluggish.
|
||||
* When we encounter these events, we'll assume we're dealing with a JUCE
|
||||
* plugin and increase the limit. Examples of affected plugins are:
|
||||
*
|
||||
* - Thermal by Output
|
||||
*/
|
||||
constexpr int extended_max_win32_messages = 8192;
|
||||
/**
|
||||
* The Win32 message ID that needs to trigger the behaviour described for
|
||||
* `juce_win32_message_limit`.
|
||||
*/
|
||||
constexpr unsigned int juce_message_id = WM_USER + 123;
|
||||
|
||||
HostBridge::HostBridge(MainContext& main_context,
|
||||
boost::filesystem::path plugin_path,
|
||||
pid_t parent_pid)
|
||||
@@ -45,9 +61,14 @@ HostBridge::~HostBridge() noexcept {}
|
||||
void HostBridge::handle_events() noexcept {
|
||||
MSG msg;
|
||||
|
||||
for (int i = 0;
|
||||
i < max_win32_messages && PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE);
|
||||
int limit = max_win32_messages;
|
||||
for (int i = 0; i < limit && PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE);
|
||||
i++) {
|
||||
// HACK: See the docstring on `juce_win32_message_limit`
|
||||
if (msg.message == juce_message_id) {
|
||||
limit = extended_max_win32_messages;
|
||||
}
|
||||
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user