GUI layer threading

SDK for VST 3 audio plug-in and host development.
Post Reply
User avatar
pongasoft
Posts: 98
Joined: Sun Mar 11, 2018 5:57 pm
Location: Las Vegas, USA
Contact:

GUI layer threading

Post by pongasoft » Sat Apr 18, 2020 5:27 pm

So far I have been assuming that the GUI layer is mono threaded/runs on an event loop like most other GUI layers (ex: Android, etc...) and I wanted to confirm that my understanding is correct.

I do understand that the GUI and the RT may (and will most likely) run on separate threads but because they don't share any data it should never be an issue (except when the RT is asked to save its state which AFAIK happens from the GUI thread but I have already discussed this in another thread).

But within the GUI itself, can I assume that all implementations (=DAWs) are required to use some event loop and only a single thread to call all methods in the UI. One thing that comes to mind is that I have a Timer (Steinberg::Timer) and I want to make sure that the onTimer callback gets called serially with other GUI events and I do not have to handle synchronization in any way (for example, a onMouseDownEvent and onTimer event will always be serial, and never called from 2 different threads).

Thanks
Yan

Arne Scheffler
Posts: 343
Joined: Mon Jun 20, 2016 7:53 am

Re: GUI layer threading

Post by Arne Scheffler » Tue Apr 21, 2020 2:17 pm

Hi,
as stated in the documenation (https://steinbergmedia.github.io/vst3_d ... llsequence), all edit controller calls must be done on the main thread.

Cheers,
Arne

User avatar
pongasoft
Posts: 98
Joined: Sun Mar 11, 2018 5:57 pm
Location: Las Vegas, USA
Contact:

Re: GUI layer threading

Post by pongasoft » Wed Apr 22, 2020 12:43 pm

Arne Scheffler wrote:
Tue Apr 21, 2020 2:17 pm
Hi,
as stated in the documenation (https://steinbergmedia.github.io/vst3_d ... llsequence), all edit controller calls must be done on the main thread.

Cheers,
Arne
This diagram/section does not talk about timers explicitly. Or am I missing something? Are timers callback also required to be called from the main thread?

Thanks
Yan

Arne Scheffler
Posts: 343
Joined: Mon Jun 20, 2016 7:53 am

Re: GUI layer threading

Post by Arne Scheffler » Fri Apr 24, 2020 6:28 am

Hi,
Timers are not part of the SDK for macOS or Windows. So if you create a timer on these platforms you have to make sure that they are working as you expect. The VSTGUI timer class will post on that thread where you create it, so you have to make sure that this is happening on the main thread.

Cheers,
Arne

Post Reply