As I can see from px4 source implementation, gyro bias is re-calculated in every measurement step, in function controlMagFusion() just as you pointed out. This function will then in turn call fuse() in the end, taking Kalman gain and innovation as input params. The Kalman gain and innovation are all calculated based on the covariance of in-run measured mag data. Only one thing that different from your previous description, I think the “bias learning” in controlMagFusion() is not only on the ground, but continuously on the flight in-run,.
If you are using a VIO system instead of mag, then the input to fuse() function changed to vision _heading_innov, which then gyro_bias will be recalculated upon. I think if the VIO system passing a bad measurement, then should be the same effect as passing in a bad mag measurement.