Flipping horizon is usually bad orientation of external magnetometer (AuxMag) in your screenshot you have Aux Mag Orientation (Pitch = 0, Roll =0, Yaw = 0), this is only true for OP GPSv9.
Other GPS may have different orientation and you need to adjust these values by +-45,90,180 degrees, depending on your GPS. Values in the bars should be very close to zero. You should see on scope that both AuxMag and Internal Mag respond the same when copter is rotated and values for orientations set correctly.
If your Mag orientation does not match what accelerometers measures, EKF will go crazy and you will see horizon going crazy or even flipping up-side-down.