A few users have reported strange compass behaviour seemed to be triggered by iOS 11 updates. Compass started to behave really oddly for them, for example showing North regardless the iPhone/iPad heading and then jumping to South.
Troubleshooting showed that all of them had "Compass calibration" set as OFF in System location services. Switching it back to ON always fixed the issue.
Here is how to re-enable compass calibration:
1. Open iPhone/iPad settings and tap on Privacy:
2. Open Location services:
3. Scroll to the bottom, open System services:
This should bring compass back to senses.