Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

FabFilter VST windows don't resize correctly on initial open on non-100% DPI #107

Open
KLszTsu opened this issue Feb 3, 2022 · 6 comments

Comments

@KLszTsu
Copy link

KLszTsu commented Feb 3, 2022

Operating System Info

Windows 10

Other OS

No response

OBS Studio Version

Other

OBS Studio Version (Other)

OBS 26 and above, including 27.2.0-rc1

OBS Studio Log URL

https://obsproject.com/logs/pmNFddnzLY3h8Jia

OBS Studio Crash Log URL

No response

Expected Behavior

25 0 8

Current Behavior

27 2 0-rc1

Steps to Reproduce

  1. Add a VST audio plugin - tested with FabFilter and d16 group plugins.
  2. Open plugin interface

Anything else we should know?

No response

@WizardCM WizardCM transferred this issue from obsproject/obs-studio Feb 3, 2022
@WizardCM
Copy link
Member

WizardCM commented Feb 3, 2022

I cannot reproduce this in "any audio plugin". I spent a lot of time recently familiarising myself with how Qt and VSTs resize

Your log explicitly mentions VST plugins "FabFilter Pro-C 2" and "FabFilter Pro-Q 3" - I've updated the ticket description & title to match.

I have downloaded both and I will test this later.

@WizardCM WizardCM changed the title OBS Studio didn't render VST plugin window correctly FabFilter VST windows don't resize correctly on initial open Feb 3, 2022
@WizardCM
Copy link
Member

WizardCM commented Feb 3, 2022

Additionally, what DPI is your monitor set to?

@KLszTsu
Copy link
Author

KLszTsu commented Feb 3, 2022

Additionally, what DPI is your monitor set to?

Yeah. That seems to be where the problem is at.
I was at 125% and by setting it back to 100% will it renders properly.

@WizardCM
Copy link
Member

WizardCM commented Feb 3, 2022

I feared that would be the case. 26 is around the time we properly started reporting to the operating system that OBS handles DPI correctly, but it seems VSTs don't and the window size calculation doesn't take that into consideration. I believe we handle this somewhere else too.. maybe in the browser code? I will have to do some digging.

@WizardCM WizardCM changed the title FabFilter VST windows don't resize correctly on initial open FabFilter VST windows don't resize correctly on initial open on non-100% DPI Feb 3, 2022
@WizardCM
Copy link
Member

WizardCM commented Feb 3, 2022

Right, so firstly I can confirm OBS + High DPI + VSTs don't work well together.

Secondly, I'm having trouble fixing this. This documentation provides an example that should work perfectly with our code, however it results in Qt not correctly repositioning the resulting window (that is - it doesn't sit within the container, just gets locked at 0,0).

Example suitable for us:
image

The code change I made:

diff --git a/win/EditorWidget-win.cpp b/win/EditorWidget-win.cpp
index e3f05e3..3bb09d6 100644
--- a/win/EditorWidget-win.cpp
+++ b/win/EditorWidget-win.cpp
@@ -28,8 +28,10 @@ void EditorWidget::buildEffectContainer(AEffect *effect)
        RegisterClassExW(&wcex);

        const auto style = WS_CAPTION | WS_THICKFRAME | WS_OVERLAPPEDWINDOW;
+       DPI_AWARENESS_CONTEXT previousDpi = SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
        windowHandle =
                CreateWindowW(wcex.lpszClassName, TEXT(""), style, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr);
+       SetThreadDpiAwarenessContext(previousDpi);

        // set pointer to vst effect for window long
        LONG_PTR wndPtr = (LONG_PTR)effect;

And the end result:
image

If I move the SetThreadDpiAwarenessContext(previousDpi) call anywhere later, then the VST window just never renders.

I have a feeling both of these are Qt bugs, but I'm not 100% sure.


Additionally, with these changes there are certain VSTs that continue to behave incorrectly. If we get the above code working, I would be OK with providing a toggle in the VST properties allowing the user to disable VST DPI code if necessary.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants