A correct Qibla calculation cannot compensate for a disturbed compass. Separate the numerical bearing from the phone sensor that tries to show which way you face.
Remove common sources of interference
Take off magnetic cases and mounts. Step away from cars, speakers, steel desks, lifts and reinforced walls. Hold the phone flat in an open area and let the reading settle. Do not test it beside another device with magnets.
Check repeatability before accuracy
Slowly turn in a full circle and return to the same physical direction. A reading that jumps or does not return close to its starting value is not dependable. Repeatability alone does not prove it is aligned to true north, but instability is a warning.
Calibrate only as your device recommends
If your device suggests a figure-eight motion, follow its instructions in a clear space. Calibration can reduce sensor errors; it cannot remove a nearby magnetic field. A permission error or missing sensor is different from a calibration problem.
Compare against true north
Use a north-aligned map and a distant, identifiable landmark to check orientation. Magnetic north differs from true north by local magnetic declination. Devices and browsers do not all report the same north reference; do not add a correction to a reading already corrected to true north. If readings disagree, use the map method and seek local guidance for religious edge cases.
Common questions
Why do two phones show different directions?
They may have different calibration, magnetic interference or north-reference handling. Check both away from metal against an independent reference.
Does recalibrating change the calculated Qibla bearing?
No. Calibration affects the heading sensor, not the bearing calculated from coordinates.
What if the phone has no compass?
Use the displayed true-north bearing with a north-aligned map or another reliable compass.