Logic Pro X AU bypass noise issue

My plugins produce unpleasant noises in Logic Pro X when bypass is enabled/disabled. Looking at the waveform it looks like some fading is going on, but it’s not correct and the fadeout gets cropped.

To figure out the issue I built the GainPlugin example, but it shows the same behavior in Logic. To reproduce, just feed a sine through the GainPlugin with gain 1.0 and then enable/disable bypass - nothing should happen, but a mixture of fades and cut off signals happens.

I tried playing with getTailTime(…) and getBypassParameter() but neither of those help.

However there are AUs that bypass in Logic without noise. For example all the built-in Apple AUs like AUFilter and friends.

Has anyone found out how to make JUCE plugins Logic bypass friendly? Is this maybe a “bug” in the Juce AU wrapper?

Checking this with Apple AU Sample code I see it doesn’t happen there even when the plugin does absolutely nothing to support bypass. So I think the problem comes from some call during the PrepareToPlay() sequence that causes Logic to reset too much state. I already tried disabling all the PropertyChanged() msgs in the AU wrapper, but no luck so far.

The waveform on bypass enable looks like this: