Hi @ed95
Thanks for the quick reply.
Cantabile has a couple of options to control the DPI mode it runs. The one where these problems are occurring is with Per-Monitor V2 support enabled where:
- Cantabile’s main window runs
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
- Plugin windows run in
DPI_AWARENESS_CONTEXT_UNAWARE
The idea here is to enable HiDPI support for Cantabile’s windows, but let Windows scale up plugins so they’re not so tiny.
In order for this to work successfully, Cantabile sets the dpi awareness context on every call into the plugin: initialization, any dispatch calls, VST 3 interface methods, when creating the editor window etc… It even hooks SetTimer callbacks and inserts a stub to setup the context for those callbacks too.
What it doesn’t do however is setup the DPI awareness for any threads created by the plugin that deal with the UI - which is what seems to be happening with Juce plugins (well at least the one I’ve looked into - Helm) where it’s using OpenGL on a worker thread to do the rendering.
As an experiment, I just hacked in the following into the top of Juce’s OpenGLContext::runJob()
and it fixes the issue:
auto oldCtx = SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
auto oldAwareness = GetAwarenessFromDpiAwarenessContext(oldCtx);
Obviously the above is just a hack and the correct fix would be to set it to the DPI awareness of the thread used to create plugins’ UI (eg: from effOpenEdit handler). The oldAwareness
is just there for curiosity - it’s returning DPI_AWARENESS_SYSTEM_AWARE
which must be the default for a thread, unless Juce is setting it somewhere.
The other possibility here would be for Cantabile to hook thread creation and explicitly override the thread’s DPI context. That sounds sketchy but I’ll have a play with that today to see if I can make it work. Either way it’d be nice if this was fixed in Juce too.
To answer your other questions:
- Cantabile is not built using Juce.
- It happens when hosting plugins built with Juce. I’m not sure if all Juce plugins but at least some. As mentioned Helm and I know Arturia plugins suffer this problem too - I think they’re built with Juce right?
- Current public releases of Cantabile only support VST 2 however VST 3 support is currently under development and these issues occur with both the VST 2 and VST 3 versions of Helm.
If you want to reproduce this, just install Cantabile and go to Options -> General -> User Interface and enable these two options, insert a Juce plugin and open it’s editor.
Brad