CachedValue and AudioProcessorValueTreeState stability

Its seems that whole concept around CachedValue and AudioProcessorValueTreeState is build around the fact, that manipulation of the source Value/ValueTree should happen ONLY from the message thread. This should be clearly documented in the comments.

The problem is that in plugins you cannot be fore sure that for example setStateInformation is called from the message-thread. Using a MM-Lock is not a good option for various reasons (possible deadlocks)

Solution: Remove any message-thread dependency, access to the Value/ValueTree should be only happen through a separate CriticalSections which is controlled by the plugin / AudioProcessorValueTreeState.

The JUCE-Tutorial (which maybe used by many people) is having the same problem
https://www.juce.com/doc/tutorial_audio_processor_value_tree_state

2 Likes