Al-Masjid al-Haram · Makkah
Hold the phone flat, away from metal and laptops, and move it in a figure-of-eight once to calibrate.
Phone compasses read magnetic north, which can sit several degrees away from true north depending where you are, and metal, speakers, laptops and magnetic cases all pull the needle. Move away from electronics and swing the phone in a figure-of-eight to recalibrate. Some devices don't report heading to the browser at all — the degree figure above is still exact.
For anyone praying away from the Sacred Mosque, facing the general direction is what is required — "what is between the east and the west is qibla."