Compass failure mode after successful compass calibration

I have had several instances when the compass calibration is successful, but when flying, the drone goes into failsafe due to “CRITICAL NAVIGATION FAILURE” and "EMERGENCY YAW RESET - MAG USE STOPPED, followed by “STOPPING COMPASS USE”. It seems that even though the compass calibration was successful, it lost the calibration as it started to fly.

What are the possible causes of this?