First, open the
Map screen and calibrate the sensors with a figure 8 motion. Now
observe the display for a few seconds.
In case of too much jitter, keep the phone on a level surface.
If the jitter is such that the display rotates around the Nadir, then you need to reduce sensitivity of the magnetometer.
If the jitter seems random, then you need to reduce the sensitivity of the accelerometer.
On the other hand, if there is too much lag, determine the direction of the lag.
If there is a lag when moving along the horizon (azimuth change), you need to increase the sensitivity of the magnetometer.
If there is a lag when going from horizon to Nadir (altitude change), then you need to increase the sensitivity of the accelerometer.