AAX plugin, automation gets all messy after a while

I have a JUCE AAX plugin and users are reporting issues with automation in Pro Tools. It works for a while, an then the automation gets all 'messy' looking and out of order.

I've created a automation track that looks like this:

I added logging statements to AudioProcessor::setParameter, then I dumped those logged values to Excel and created a graph and it looks like this:

I had playback looped, the first few times you can see the graph looks fine. But then it goes completely haywire looking, any idea what's going on? Is my plugin doing something wrong? It appears ProTools is sending the wrong automation data, but automation in ProTools must work, or everybody would be freaking out. So what could my plugin be doing wrong?

I just tried this with the examples/PlugInSamples/GainPlugIn and was not able to reproduce this behaviour. This is how I modified the source code:

#include <iostream>
#include <vector>
#include <fstream>
#include <iterator>

#include "../JuceLibraryCode/JuceHeader.h"
#include "../../GenericEditor.h"

class GainProcessor  : public AudioProcessor
    std::vector<float> values;
        addParameter (gain = new AudioParameterFloat ("gain", "Gain", 0.0f, 1.0f, 0.5f));

    ~GainProcessor() {
        std::ofstream file ("/Users/JUCE/Desktop/hello.dat", std::ios::trunc);
        std::copy (values.begin(), values.end(), std::ostream_iterator<float>(file, "\n"));

    void setParameter (int idx, float value) override
        if (idx == 0)
            values.push_back (value);

        AudioProcessor::setParameter (idx, value);

This is the plot I'm getting (which resembles my automation curve almost exactly):

Can you try this with the gain plugin and see if you can reproduce your bug?

This might be related.
In Final Cut Pro X automation gets changed when it is played back (which makes it unusable). Only happens if the plugin editor is open. Probably providing unexpected feedback to the host.

Final Cut Pro X is kinda quirky when it comes to automation. If playback is stopped and an automated parameter gets changed in the plugin editor, the entire automation gets changed relatively (in the vertical axis), such that the automation curve matches the changed parameter at the playhead position.


Another AU issue that might be related: Set Logic Pro X to write automation data. Change a parameter in the plugin editor during playback. Automation does not get recorded at all. If I remember correctly this worked before the introduction of AudioProcessorParameter.


Final Cut Pro X Trial 10.2.3 (available at https://www.apple.com/final-cut-pro/trial/)
Logic Pro X 10.2.1

I found the issue, my implementation of a metaparameter was buggy and feeding back and updating the original parameter with a delay.