steinbergmedia / vstgui

A user interface toolkit mainly for audio plug-ins
Other
869 stars 123 forks source link

ui built on ver 4.11+ will flicker especially run on vst3plugintesthost 64bit #293

Closed setoutsoft closed 8 months ago

setoutsoft commented 1 year ago

We are building a vst3 plugin using vstgui. However, we design a view which is used to display frequency spectrum for every 2 frames of input audio. That is to say, the view will refresh very high. While using the latest version of vstgui (4.12), we found the view will flicker from time to time especially run on vst3plugintesthost 64bit. I don't know what the problem is. Finally, we switched to a commit: 03b61ef3f85fc8d58fd47d68c38ca574a9dbd44d (2021/1/14 23:05:16, ver:4.10), and the problem was gone. We had tried 4.11, the is same as 4.12. Do you know what the question?

scheffle commented 1 year ago

How do you trigger a redraw?

setoutsoft commented 1 year ago

invalid and setDirty both. results were same.

scheffle commented 1 year ago

Can you provide a simple test app/plugin for this. I cannot reproduce the issue.

setoutsoft commented 1 year ago

OK, I will prepare a demo for this as soon as possible

setoutsoft commented 1 year ago

@scheffle vstplugin_demo.zip Before building the demo, add VSTSDK_HOME to environment variable that ref to path of vst sdk, or simply modify CMakelists.txt to use your vst sdk.

In this demo, mainly, 3 steps were done. //firstly, every 3 frames, we post a message to controller. tresult PLUGIN_API RaccoonXProcessor::process (Vst::ProcessData& data) { //--- First : Read inputs parameter changes----------- bool bParamUpdated = false; if (data.inputParameterChanges) { bParamUpdated = updateParameter(data); }

if (++m_nFrames == 3) {
    //post a message to Controller
    if (auto message2 = owned(allocateMessage()))
    {
        message2->setMessageID("TimeData");
        sendMessage(message2);
    }
    m_nFrames = 0;
}
//--- Here you have to implement your processing

return kResultOk;

}

//then, at controller, we create a HWND which is used to transfer a message received from processor to UI thread. void RaccoonXController::onNotify(Vst::IMessage message) { //run on ui thread for (auto it = uiMessageControllers.begin(); it != uiMessageControllers.end(); it++) { (it)->notify(message); } }

tresult PLUGIN_API RaccoonXController::notify(Vst::IMessage message) { //post message to ui thread. SOUI::CRunnable pTask = new CVstRunnable(this, message); assert(m_pMsg2UI); m_pMsg2UI->postRunnable(pTask); pTask->release(); return kResultTrue; }

//finally, we try to invalid UI void UIMessageController::notify(Vst::IMessage* pMsg) { if (m_root) { m_root->invalid(); //m_root->setDirty(); } }

wait about 10 seconds, I believe you will observe a flicker. make sure using vstgui 4.11+. Vst3pluginTestHost was used here. Studio one looks better, but flicker can be observed still.

nickdowell commented 8 months ago

This sounds like the same issue as https://forums.steinberg.net/t/vstgui-4-11-windows-release-build-flickering/797049 for which there are a couple of workarounds;

scheffle commented 8 months ago

Commit e5294cafb11e735eaf5550c2b35fab593b834d46 should fix this issue.

nickdowell commented 8 months ago

Commit e5294ca should fix this issue.

Amazing! That fix seems to work for me with my NVIDIA GPU.