ListenerList crashes on AudioProcessor destruction

ValueTree doesn’t rely on message-thread. It has synchronous callback behaviour (on the same thread where the changes happen), while others like ChangeBroadcaster are asynchronous, and callback on the message-thread.

This is simply a matter of definition and should be taken into account when programming.

I agree, there should be better tools (like wrappers for thread-safe access to / and callbacks from value-trees) and warnings do deal with it.

1 Like

Sure, it doesn’t have to be the message thread, but it has to be single threaded (read the second part of my comment…).

The reason is - logically, once the callback is called you’re gonna be reading the value, and doing read-access into a ValueTree is not thread safe.

What you want to prevent is not callbacks run at a certain thread, but read/write access happen at the same time.

This would surely happen if you start writing/dispatching callbacks in another thread and expecting any read to be valid after that.

I’ve pushed some changes to ListenerList, I don’t expect this to fix anything and everything but it would be good to see how much of an issue it still is for others.

Unfortunately I had hoped to add some additional debug assertions to help catch common issues but it seems due to the way some hosts work it results in a too many false positives so I’ve had to leave it out for now.

2 Likes