Hi everyone,
I get this error when I start my vst3 from FL Studio:


it all starts from here:

When a parameter of the AudioProcessorValueTreeState changes I call the setBounds method of the bands component (bands is an array of components).

As soon as I call setBounds I get this error, can anyone help me?

This assertion is warning you that you shouldn’t modify components from any thread other than the main thread.

You could instead set a flag that the component needs to be updated, and use a Timer or AsyncUpdater to check this flag and set new bounds by reading the current parameter values if necessary.

1 Like

It is not only setBounds(), even the getWidth() you are using in the screenshot above will assert, because all component variables like bounds, children etc. are not thread safe.

You can also go the other way round to set an atomic int from resized() in the processor, that you can safely access from the parameterChanged()


If the offending thread is not the audio callback, I rely on MessageManager::callAsync in those cases.

1 Like

I usually rely on ParameterAttachment for updating the UI from parameter changes

1 Like

The problem with parameterChanged() is that you cannot possibly know.
That’s why I avoid that function at all cost.

1 Like

I do this at the listener callback, not the valuetree setting code. ie. if a valuetree callback is coming from more than one thread, and a listener for it is doing UI things, then I divert with the callAsync. When I am paying attenion, I will even wrap it in a 'MessageManager::isThisTheMessageThread()`. I have a todo item to attempt to automate this by integrating it into my ValueTreeWrapper code eventually.

1 Like

Thanks everyone for the answers.
I solved it with ParameterAttachment, as jellebakker suggested