Linux-VST hosting needs to wait for Window creation


#1

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: https://cloud.githubusercontent.com/assets/5719151/5877603/f34b9086-a320-11e4-801d-cfa6b82a0b10.png

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.

 


#2

Thanks

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)
                break;

            Thread::sleep (50);
        }

 


#3

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.


#4

Sorry it took so long, here's a patch-fix:
https://github.com/DISTRHO/juce/commit/665fb6033812b7dd544bcb0720584a20b3da7d28.patch

 


#5

Thanks, seems sensible - will sort that out..


#6

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)

 


#7

ok, cheers - should be OK now.


#8

Yes, thank you.

Don't forget about this one next ;)
http://www.juce.com/forum/topic/fix-some-issues-temporary-windows