Crash when loading VST2 if VST3 is present

We are running into this same issue with our plugins built on JUCE 8.0.6. The issue is present in Cubase 13 and 14 running under Rosetta on Apple Silicon, and on Intel Macs. It is not present when running natively on Apple Silicon. I will check Windows ASAP (hopefully tomorrow).

There seem to be two separate things going wrong:

  • With JUCE_VST3_CAN_REPLACE_VST2 enabled and both VST2 and VST3 installed, the VST2 is showing up in Cubase (on JUCE 7 and earlier, only the VST3 would show - VST2 would be hidden)
  • The VST2 crashes in JuceVST3EditController::setComponentState()

The issue seems to have been introduced via the trio of commits mentioned/posted on this forum post. These are the 3 commits in question:

If I revert those 3 commits, then everything seemingly works as expected: only the VST3 shows in Cubase when both VST2 and VST3 are installed, and thus there’s no crashing VST2.

I can partially reproduce the issue using the GainPlugin demo: Both VST2 and VST3 appear (seemingly incorrect), but interestingly the VST2 loads fine (no crash). This happens on both v8.0.6 and on the latest tip of develop.
EDIT: I can reproduce the issue using the GainPlugin demo with JUCE_VST3_CAN_REPLACE_VST2=1 (and JUCE_FORCE_USE_LEGACY_PARAM_IDS=1 to get past this error), using v8.0.6 and the latest tip of develop.

Our end users may want to install both VST2 and VST3 for various reasons, so only installing one or the other is not an option. Given the bug seems to have started after the above changes, can the JUCE team please investigate and provide a fix? Thanks!