My plugin UI background is 2% bigger when I "reopen" the plugin... will visibilityChanged() help?

I have an unusual situation where my plugin UI background is about 2% bigger than it should be, only when I “reopen” the plugin. (The knobs and buttons remain the correct size).

Only when I close the plugin, and then double-click on the plugin in my FX list to reopen it, does this 2% size increase occur.
If I make a new instance of the plugin, then the UI background size is correct, or if I close the DAW completely (with my plugin showing) and relaunch the DAW, the plugin appears again at correct size. Its only the reopen that the size issue occurs.

I am learning about visibilityChanged() - could that be a place where I could reset the UI size? I’m guessing paint() and resized() are called too frequently for something as heavy as a UI reset.

In tried some visibilityChanged() code

void myplugineditor::visibilityChanged()
    DBG("It reaches here when the plugin is reopened, as expected");

    if (isVisible())

       //My code to make sure UI background is correct size


I thought I’d post an update for others who may suffer from the same issue in the future.
I tested my plugin in Ableton and it worked fine. This seems like a Reaper bug (the DAW I normally use).

I had to put a flag in visibilityChanged() to trigger a setSize in my timercallback(). And then it resized at the appropriate moment when it was reopened.

This post was helpful: