free-audio / interop-tracker

A place to track bugs between host and plugins
5 stars 0 forks source link

Eventqueue out of order events #38

Closed tas-from-planet-u-he closed 1 year ago

tas-from-planet-u-he commented 1 year ago

Found with Bitwig 4.3 on M1 Mac Monterey.

Example project file, using CLAP ACE and the Bitwig arpeggiator: outoforder-events.zip

If you deactivate the arpeggiator module and play back the project, ACE logs a long stream of out of order events like these:

AM_CLAP_Plugin::AM_CLAP_EventQueue: out of order event 47 - 37
AM_CLAP_Plugin::AM_CLAP_EventQueue: out of order event 48 - 37
AM_CLAP_Plugin::AM_CLAP_EventQueue: out of order event 49 - 106

It seems to be caused by the pressure note expression events in the MIDI clip. Deleting the pressure events stops that logging.

More info from David: Our code just goes through the input queue (we get from the host) until its current buffer end is reached. When we get to the next buffer, we continue going through the queue. What happens is that the following events in the queue have an older timestamp, meaning they should have been processed earlier but since they haven't been placed in the queue in the correct order by Bitwig, we cannot know (unless we'd always go through the entire queue and have less efficient processing).

I added a check that detects out-of-order events directly in the process loop. That check is only active in debug builds. That check will log something like:

clap_process_status AM_CLAP_Plugin::process: out of order event. Event pointer 60 has timer 16, but previous event's timer was 124

If that check logs, the problem is a host problem because the host is supposed to sort the input queue by time and having that log means we found an event with a lower timer value than the previous value. The example project triggers that log when disabling the arpeggiator effect, so it's clearly a bug within Bitwig.

You might need ACE rev. 13276 or higher to see the new debug logging.

abique commented 1 year ago

I've looked into it and it seems that ACE is producing out of order output events. Bitwig asserts that the event list we produce is in order. I used bitwig >4.3.3 and ace rev 13283.

abique commented 1 year ago

I think it is looking good now.