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

[Bug]: Exception in getNextAudioBlock or handleIncomingMidiMessage silently causes app to stop working #1417

Open
1 task done
dziemba opened this issue Aug 3, 2024 · 0 comments

Comments

@dziemba
Copy link

dziemba commented Aug 3, 2024

Detailed steps on how to reproduce the bug

Create a standalone app, which has a MidiInputCallback implemented:

void MainComponent::handleIncomingMidiMessage(juce::MidiInput *source, const juce::MidiMessage &message) {
  std::cout << "MIDI received" << std::endl;
  throw std::exception();
}

If the handler receives a MIDI message and throws, the program keeps running as if nothing happend. But after the handler has thrown once, it will not be called ever again with any later MIDI messages.

Similar behavior occurs when throwing in getNextAudioBlock:

void MainComponent::getNextAudioBlock(const juce::AudioSourceChannelInfo &bufferToFill) {
  [ ... regular audio code ... ]  
  static int i = 0;
  if (i++ == 1000) {
    throw std::exception();
  }
}

Once the 1000th buffer has been reached, audio will stop and not resume.

What is the expected behaviour?

Silently breaking the program is unexpected to me. I would expect the program to either abort fatally (which happens e.g. if you throw in the paint method), or catch the exceptions and do a jassertfalse. If catching exceptions is a performance issue, this could be only done if JUCE_DEBUG is enabled.

With the current behavior you will only notice that something went wrong if you have a debugger attached. Without a debugger, the program will continue as usual but the MIDI input will stop working.

For the audio handler the issue will be obvious immediately (since audio stops) but for the MIDI handler it's a bit more subtle to understand what happened (especially if the exceptions get thrown very rarely due to some corner case).

Operating systems

macOS

What versions of the operating systems?

macOS 14.5 (23F79)

Architectures

ARM

Stacktrace

No response

Plug-in formats (if applicable)

Standalone

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct

  • I agree to follow the Code of Conduct
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