Sudden GPS lost during flight


We have intgps_lost_custom_mode.BIN (2.1 MB)
egrated a customized mode based on Copter 3.5 to perform tracking desired local NED path. The new mode can fulfill the task most of the time. But accidental crashes happen quite a lot recently and when we checked the flight logs, it was indicating GPS satellites dropping from 16 to 4,3 even 0, and the HDOP from 0.63 to 1,2 and 99.9. However, when we switch back to the original official firmware, the GPS never drops. As it happens quite randomly and quite a few times, we realized it might be our firmware bug somehow triggering this problem.
Attached the onboard flight logs and really appreciate your suggestions.