The PixHawk / APM style of GPS/mag has an I2C mag. I2C is a communication format like NMEA, DSM, SBus, etc. I2C mags are susceptible to cable problems. The cable must be short and twisted. Even then, the cheap clones sometimes have issues and the fix is to install a pair of pullup (to 3.3v?) resistors (say 3k to 5k) on both SCL and SDA lines in the I2C cable. Best place is to just add the resistors inside the GPS shell.