Standalone plugin calls prepareToPlay in different order on Mac vs PC

I’m developing a JUCE (v7.0.5) plugin which targets VST/AAX/Standalone.

In the Windows Standalone build, the AudioProcessor::prepareToPlay method is called before any Component::paint calls. However, on MacOS 11.7, my Component::paint method is being called before AudioProcessor::prepareToPlay.

One of my Components’ paint methods uses an object which needs to be first initialized by AudioProcessor::prepareToPlay, but since this didn’t happen yet, a runtime exception occurs in the MacOS Standalone build.

My question is, is this intended behavior of the standalone app on MacOS? If so, it would seem that I can’t make the assumption that AudioProcessor::prepareToPlay has been called before any Component::paint calls are made, and may have to refactor the code to handle this situation.

Initialize your processor in its constructor with default values… don’t rely on prepareToPlay() to initialize your processor.

Rail

3 Likes