Is get state information thread safe? [Solved] use setStateInformation to load samples and dynamic xml values without UI thread

If I need to allocate memory. Someone pointed out that if you load a project in daw when your UI is not initialized you might not get the data from the UI thread such as samples or msegs .

It definitely doesnt work becuase everything is on UI thread initializing when you save and load a project and ui thread is not called.

prepareToPlay seems like way better option to intialize

‘getStateInformation’ is called by the host to write your plugin state into a memory block. Did you mean ‘setStateInformation’?

That being the case, you’re ok to allocate memory etc in setStateInformation because it doesn’t happen on the audio thread. However, you must bear in mind thread safety. That is, you don’t want to be setting up processor state as you go in setStateInformation, you want to load it and then hand it off to the audio thread or use some kind of lock free mechanism.

The data for your samples and msegs should be stored with the processor or associated classes, not with the UI. This is because the UI is constructed and destructed when it’s opened and closed. Your UI classes should just provide a view onto the data.

I think if I do it in my processor constructor I should be okay as long as the preset info is available and then the rest on UI thread . Unless they select a preset from their daw rather than my UI

Thank you setStateInformation was the place to do it ! on the plugin without the UI