setStateInformation Assertion failure regarding: sizeInBytes

void SimplifiedPluginAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
    // You should use this method to restore your parameters from this memory block,
    // whose contents will have been created by the getStateInformation() call.

    std::unique_ptr<juce::XmlElement> xml(getXmlFromBinary(data, sizeInBytes));
    if(xml.get() != nullptr)
    {
        if(xml->hasTagName(userParameters.state.getType()))
        {
            userParameters.replaceState(juce::ValueTree::fromXml(*xml));
        } 
    }

    //===Impulse Response===//
    jassert(sizeInBytes <= 4); //FAILS HERE
    auto tree = juce::ValueTree::readFromData(data, size_t(sizeInBytes));
    std::cout << "ERROR test" << std::endl;
    variableTree = tree.getChildWithName("Variables");
    if (tree.isValid()) 
    {
        treeState.state = tree;
        savedFile = juce::File(variableTree.getProperty("file1"));
        root = juce::File(variableTree.getProperty("root"));
    }
}

I am having an assertion failure on the line indicated in the code.
This is caused by these 2 functions/classes but I cannot figure the solution.

JUCE Assertion failure in juce_InputStream.cpp:119
JUCE Assertion failure in juce_ReferenceCountedObject.h:394

The input stream failure line:

if (numBytes > 4)
    {
        jassertfalse;  // trying to read corrupt data - this method must only be used
                       // to read data that was written by OutputStream::writeCompressedInt()
        return 0;
    }

And from the ReferenceCountedObject

    ReferencedType* operator->() const noexcept
    {
        jassert (referencedObject != nullptr); // null pointer method call!
        return referencedObject;
    }

I am confused on this error, for context here is my getStateInformation, I have 2 Trees, one for slider data and one for impulse response stuff.

void SimplifiedPluginAudioProcessor::getStateInformation (juce::MemoryBlock& destData)
{
    // You should use this method to store your parameters in the memory block.
    // You could do that either as raw data, or use the XML or ValueTree classes
    // as intermediaries to make it easy to save and load complex data.

    auto state = userParameters.copyState();
    std::unique_ptr<juce::XmlElement> xml(state.createXml());
    copyXmlToBinary(*xml, destData);

    //===Impulse Response===//
    treeState.state.appendChild(variableTree, nullptr);
    juce::MemoryOutputStream stream(destData, false);
    treeState.state.writeToStream(stream);
}

I know from my testing sizeInBytes is not zero

Any help would be very much appreciated. Many thanks

Here is my constructor so you can see my VariableTree, this is copied from an AudioProgrammer video setup. (obviously fitted to my own implementation)

SimplifiedPluginAudioProcessor::SimplifiedPluginAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
     : AudioProcessor (BusesProperties()
                     #if ! JucePlugin_IsMidiEffect
                      #if ! JucePlugin_IsSynth
                       .withInput  ("Input",  juce::AudioChannelSet::stereo(), true)
                      #endif
                       .withOutput ("Output", juce::AudioChannelSet::stereo(), true)
                     #endif
                       ), 
                       mainProcessor  (new juce::AudioProcessorGraph()),
    muteInput      ( new juce::AudioParameterBool (juce::ParameterID("muteInput", 1), "muteInput", true)),
    processorSlot1 ( new juce::AudioParameterChoice (juce::ParameterID("slot1", 1), "slot1", processorChoices, 0)),
    processorSlot2 ( new juce::AudioParameterChoice (juce::ParameterID("slot2", 1), "slot2", processorChoices, 0)),
    bypassSlot1    ( new juce::AudioParameterBool (juce::ParameterID("bypass1", 1), "bypass1", false)),
    bypassSlot2    ( new juce::AudioParameterBool (juce::ParameterID("bypass2", 1), "bypass2", false)),
                       treeState(*this, nullptr, "PARAMETERS", createParameterLayout()),
                       userParameters(*this, nullptr, juce::Identifier("userParams"),
                       {
                        std::make_unique<juce::AudioParameterFloat> (juce::ParameterID("airTemp", 1), "Air Temperature", -100.0, 500.0, 24),
                        std::make_unique<juce::AudioParameterFloat> (juce::ParameterID("airPressure", 1), "Air Pressure", 1, 10000, 1000),
                        std::make_unique<juce::AudioParameterFloat> (juce::ParameterID("airHumidity",  1), "Air Humidity", 0.0, 100.0, 50),
                        std::make_unique<juce::AudioParameterFloat> (juce::ParameterID("distance", 1), "distance", 0.0, 100.0, 3)     
                        //ProcessorGraph 
                        // std::make_unique<juce::ComboBox> (juce::ParameterID("processorBox1", 1), "Processor Box 1", processorChoices, 0),
                        // std::make_unique<juce::ComboBox> (juce::ParameterID("processorBox2", 1), "Processor Box 2", processorChoices, 0),
                        // std::make_unique<juce::AudioParameterBool> ( juce::ParameterID("bypass1", 1), "Bypass 1", false),
                        // std::make_unique<juce::AudioParameterBool> ( juce::ParameterID("bypass2", 1), "Bypass 2", false)
                       })
#endif
{
    airAbsorption = std::make_unique<AirAbsorption>();

    //=====SLIDER PARAMS=====//
    airTempParam = userParameters.getRawParameterValue("airTemp");
    humidtyParam = userParameters.getRawParameterValue("airHumidity");
    distanceParam = userParameters.getRawParameterValue("distance");
    airPressureParam = userParameters.getRawParameterValue("airPressure");
    userParameters.addParameterListener("airTemp", this);
    userParameters.addParameterListener("airHumidity", this);
    userParameters.addParameterListener("distance", this);
    userParameters.addParameterListener("airPressure", this);

    //===Tree naming for impulse response variables
    variableTree = {

        "Variables", {},
        {
            { "Group", {{"name", "IR Vars"}},
                {
                    { "Parameters", {{"id", "file1"}, {"value", "/"}}},
                    { "Parameters", {{"id", "root"}, {"value", "/"}}}
                }
            }
        }
    };
    //===ProcessorGraph===//
    addParameter(muteInput);
    addParameter(processorSlot1);
    addParameter(processorSlot2);
    addParameter(bypassSlot1);
    addParameter(bypassSlot2);
}