Linux-VST hosting needs to wait for Window creation


Hi Jules and the rest of ROLI team.

There's a race-condition in the Juce Linux VST host code.

When effEditOpen is called the plugin UI X11 Window might still not exist when the function returns.
(X11 is asynchronous)
The issue here is that the current Juce code only tries to get the plugin UI Window once, which might fail.
When this happens the plugin UI will not receive mouse and keyboard events, and in Tracktion it won't appear on the right place.

Example of race-condition happening:

I doesn't seem to happen on juce-demo-host (it's very rare) but does a lot in Tracktion.
My guess is that Tracktion complexity which uses X11 a lot more makes the events sync slower.

I have no fix for this yet, just wanted to let you know first.
Perhaps there's some X11 event we can listen to, and if not we could always trigger a timer until we get the window.

When this is fixed UIs should work 100% of time in Tracktion-Linux.




I don't really have a test for this, but how about a simple workaround that retries it like this?

(in the openPluginWindow() method, replacing the single call to getChildWindow)

        for (int i = 40; --i >= 0;)
            pluginWindow = getChildWindow ((Window) getWindowHandle());
            if (pluginWindow != 0)

            Thread::sleep (50);



Yes, I know that works because it's what I'm doing in my plugin when the host is "Tracktion" (and using Linux).
(I sleep for 1 full second in this case)

It's not a pretty solution as it locks the main thread.
There should be a better way to do this. If I find it I'll post it here.


Sorry it took so long, here's a patch-fix:



Thanks, seems sensible - will sort that out..


Thanks, but the change you made is not quite right.

componentMovedOrResized should only be called when pluginWindow != 0 (which might not happen on the first timer callback)



ok, cheers - should be OK now.


Yes, thank you.

Don't forget about this one next ;)