I have the same problem before — turns out the compass setup finally worked after I did a full sensor recalibration in QGroundControl and made sure the GPS/compass was facing the right direction. Worth a try if you haven’t done that yet!
You can also try this tool for free. https://123compass.org/
R