juce-framework / JUCE

JUCE is an open-source cross-platform C++ application framework for desktop and mobile applications, including VST, VST3, AU, AUv3, LV2 and AAX audio plug-ins.
https://juce.com
Other
6.31k stars 1.67k forks source link

[Bug]: juce_midi_ci property host does not expect Reply To Subscription in reply to Subscription messages #1329

Closed atsushieno closed 6 months ago

atsushieno commented 6 months ago

Detailed steps on how to reproduce the bug

Common Rules for Property Exchange v1.1 specification (along with MIDI-CI v1.2 Property Exchange specification), section 9.2 in particular, expects that the subscribers "shall" send the Reply to Subscription to the property host about its processing result:

A device that receives a Subscription message for any subscribed Resource Data shall reply with a Reply to Subscription message, so the original sender is aware of the success or failure of a command.

There is no conditional term whether the actual command is "full", "partial", or "notify".

Current JUCE property host implementation does not seem to expect this (it does not seem to have any input message handler for PropertySubscribeResponse), resulting in InvalidateMUID. Then our further Get Property Data requests are disregarded as our MUID is invalidated.

I noticed this while implementing my own MIDI-CI client (in Kotlin), same as issue #1323.

Repro steps (I name "CapabilityInquiryDemo" here, but the actual cause is somewhere in juce_midi_ci module):

CapabilityInquiryDemo returns InvalidateMUID after the steps above.

What is the expected behaviour?

It should expect Reply to Subscription in response to property updates via Subscription.

They can just be discarded, but should not result in "Invalidate MUID".

Operating systems

macOS

What versions of the operating systems?

13.5.2 (22G91)

Architectures

ARM

Stacktrace

No response

Plug-in formats (if applicable)

No response

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

atsushieno commented 6 months ago

I forgot to mention: Common Rules for PE specification, section 9.4 (Example Set of Transactions with Initiator Subscribing to Responder Resources) contains an exact case that Subscription message for "notify" ({"command":"notify","subscribeId":"sub138047"}) that results in Reply to Subscription ({"status":200}), at Page 42.

reuk commented 6 months ago

Thanks for the detailed report.

Unfortunately, I haven't been able to reproduce the issue exactly as you describe so far. Currently, I'm testing with two copies of the CapabilityInquiryDemo talking to each other.

I do see some potentially-related bugs in the area of property exchange.

I think that the subscribeId in the Property Subscribe Response above is unnecessary, but I don't see any InvalidateMUID messages being sent even if I remove this field from the Reply to Subscription header.

Are you able to provide the exact bytes of the sysex messages that you're sending to the Demo? That seems like the simplest way of repro-ing the bug. Otherwise, maybe you could stick a breakpoint in OutputHandler::processMessage in the Demo and see how the callstack looks at the point where InvalidateMUID is sent. I'd expect the callstack to provide some hints as to which message caused the InvalidateMUID reply.

atsushieno commented 6 months ago

Thanks for the details. Upon further investigation I figured that it was MY bug - my Reply to Subscription had indeed wrong MUID. After fixing the issue the property Subscription updates worked well. Sorry for the noise!

I'm closing the issue as the issue itself is invalid but if you prefer keeping it open (for the issues you discovered as above) please do so.

reuk commented 5 months ago

Thanks for reporting. We've pushed some fixes for the issues I discovered while debugging: