Hello, first-time poster here. I have developed OSC support, using JUCE, for the FOSS synthesizer Surge XT (https://surge-synthesizer.github.io/). All has been working well, but I just discovered that if I send a string over OSC consisting only of slashes (e.g. "/', or “//”, or “///”, etc.), no further callbacks of OSCMessageReceived() are generated until JUCE OSC input is stopped and restarted.
I wonder if anybody can confirm this behavior. I’m on a Silicon Mac, JUCE 7.0.5, btw.
EDIT: I have added a call to registerFormatErrorHandler(), and no such error seems to be generated. (Second EDIT): I cannot seem to trigger a Format Error at all, even when passing strings such as “x” or “&&&&” (although these strings do not “kill” subsequent OSC input processing).
I would say it potentially might have something to do with this infinite loop in src/surge-xt/osc/OpenSoundControl.cpp:
void OpenSoundControl::oscBundleReceived(const juce::OSCBundle &bundle)
{
std::string msg;
for (int i = 0; i < bundle.size(); ++i)
{
auto elem = bundle[i];
if (elem.isMessage())
oscMessageReceived(elem.getMessage());
else if (elem.isBundle())
oscBundleReceived(elem.getBundle());
}
}
… basically, I think you shouldn’t be making the differentiation on whether to be despatching on bundles or messages in the bundle handler - juce_OSC already does this.
Instead, just use the juce_OSC- provided callbacks for oscMessageRecievedandoscBundleReceived individually (i.e. have two handlers) - don’t do this yourself, its redundant and buggy.
The despatching is handled upstream in juce_OSC - you should just be receiving the message/bundle you expect, and processing it.
Verify this yourself by setting a breakpoint on oscBundleReceived, and see how many times it gets called in your test case.
i have the same loop in all my code and never had any problems with it - indeed, if the sender can send bundles then you should have this in your code as the juce code won’t recurse, intentionally (obvs I’m not commenting on the original issue, but just the processing of incoming messages)
I’m not getting any calls to OpenSoundControl::oscBundleReceived when I send a string of “/”. And I could be wrong (I’ll check into this), but I believe the example code for JUCE OSC does this same recursive call. I’ll look further into this, though, and thank you for your suggestion.
EDIT: As I understand it, the recursion is supposed to handle bundles of bundles; at any rate, it doesn’t look like the problem lies there, as it’s not even getting called for an input message of “/”.
I’d like to extend this request to anyone who has a functioning, testable JUCE OSC implementation. Try sending it a “/” and see if it knocks out further OSC processing. I have yet to have confirmation that it’s happening to anybody else. Many thanks!
‘addr’ is an empty string for OSC messages containing just “/” chars. Making the line
if (addr.empty() || addr.at(0) != '/')
fixes the issue for me. Sorry for the noise, but I hope this might help somebody else who runs into the same issue. I didn’t realize that getAddressPattern() would return a null string in this case, but in retrospect, should have guarded against it. It was an insidious error, too, as it looked like the failure was upstream…further parsing just silently failed.