Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on certain hosts due to initial preset value being set to -1 #18

Closed
yamadapc opened this issue Aug 12, 2023 · 2 comments
Closed

Comments

@yamadapc
Copy link

This is fine on most iOS hosts, but for AUM (https://apps.apple.com/us/app/aum-audio-mixer/id1055636344) which is a highly used host for iOS, the fact the initial program is set to -1 causes the plugin to crash.

The reason is that -1 is not a valid program index and JUCE AudioUnit code is not handling -1 as an input. See:

  • juce::JuceAudioUnitv3::FactoryPresets::getAtIndex

What AUM seems to do it:

  • Create the plugin filter; here the RNBO::JuceAudioProcessor constructor sets the current program to -1
  • Get the current preset by calling juce::JuceAudioUnitv3::getCurrentPreset
AUAudioUnitPreset* getCurrentPreset() const
{
    return factoryPresets.getAtIndex (getAudioProcessor().getCurrentProgram());
}
  • At this point, we're calling factoryPresets.getAtIndex (-1); see the implementation of this method does no lower bounds checking
AUAudioUnitPreset* getAtIndex (int index) const
{
     std::lock_guard<std::mutex> lock (mutex);

     if (index < (int) [presets.get() count])
          return [presets.get() objectAtIndex: (unsigned int) index];

     return nullptr;
}
  • The plugin crashes due to objectAtIndex trying to access index - 1 of that array

The fix could be to for RNBO::JuceAudioProcessor's _currentPresetIdx field to be initialised to 0 or a different value. I can verify setting the program to 0 (as well as patching JUCE bounds checking code above to consider lower bounds) fixes crashes in AUM for my iOS plugin.

All the best

@yamadapc
Copy link
Author

The problem is on RNBO_JuceAudioProcessors.cpp line 246:

	, _currentPresetIdx(-1)

@yamadapc
Copy link
Author

Closing this in favour of Cycling74/rnbo.adapter.juce#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant