Magnetic vs Orientation sensor for OsmAnd

OsmAnd has a setting of “Use magnetic sensor instead of orientation sensor”.
What is the difference between 2 sensors? Which is the best option for hiking?