This isn't a problem with the phone; I have a Huawei Mate60P, and it experiences the same issue sometimes. First, phones are not professional electronic compasses. Second, the most likely cause is that the magnetic field is very weak and easily affected by interference. If you try using a compass near your phone, you'll see this firsthand. Common sources of interference include magnetic phone cases, large metal objects within 3 meters, electronic devices within 20 cm of the phone, and power lines within 30 meters. Before attempting to track a satellite, it's helpful to determine its approximate launch and landing direction, which can be useful if the compass fails. You can also recalibrate your phone's built-in compass before tracking, especially in familiar locations where you can use your experience to determine the direction.