Plugin not saving its state when i reopen project

trying to fix a bug in my gain staging plugin where it will reset its state when reopening projects in any DAW.

void OnlyGainsAudioProcessor::getStateInformation (juce::MemoryBlock& destData)
{
    auto state = apvts.copyState();
    std::unique_ptr<juce::XmlElement> xml(state.createXml());
    copyXmlToBinary(*xml, destData);
}

void OnlyGainsAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{
    std::unique_ptr<juce::XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes));
    if (xmlState.get() != nullptr)
        if (xmlState->hasTagName(apvts.state.getType())) apvts.replaceState(juce::ValueTree::fromXml(*xmlState));
}

can someone help me out?

That looks fine. I think your issue lays somewhere else.

How are you managing the plugin parameters?

Have you tried debugging to check weather the parameters have the expected value? Could it be that you’re not updating your dsp objects although the parameters have the right value?