mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +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
|
and this project adheres to [Semantic
|
||||||
Versioning](https://semver.org/spec/v2.0.0.html).
|
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
|
## [3.7.0] - 2021-11-21
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -31,6 +31,22 @@
|
|||||||
*/
|
*/
|
||||||
constexpr int max_win32_messages = 20;
|
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,
|
HostBridge::HostBridge(MainContext& main_context,
|
||||||
boost::filesystem::path plugin_path,
|
boost::filesystem::path plugin_path,
|
||||||
pid_t parent_pid)
|
pid_t parent_pid)
|
||||||
@@ -45,9 +61,14 @@ HostBridge::~HostBridge() noexcept {}
|
|||||||
void HostBridge::handle_events() noexcept {
|
void HostBridge::handle_events() noexcept {
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
for (int i = 0;
|
int limit = max_win32_messages;
|
||||||
i < max_win32_messages && PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE);
|
for (int i = 0; i < limit && PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE);
|
||||||
i++) {
|
i++) {
|
||||||
|
// HACK: See the docstring on `juce_win32_message_limit`
|
||||||
|
if (msg.message == juce_message_id) {
|
||||||
|
limit = extended_max_win32_messages;
|
||||||
|
}
|
||||||
|
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user