I can't tell you exactly what the problem is, but I've had similar experiences.
For me it is like this. If I go into a building or drive through a tunnel, I usually lose the "position fix", i.e. the GPS receiver cannot determine the location due to poor satellite reception. Completely normal. In principle, this is not a problem as long as it does not take too long.
I have an app that recognises which of my clients I am with when I enter a building and saves this information for my reporting. When I'm done at the customer's (possibly after 3-4 hours), leave the building again and drive to the next customer, it sometimes takes what feels like an eternity until a "Position Fix" is displayed again and my GPS receiver is "online" again. The problem gets even worse when I am already on the move with the car. That sometimes takes 15 minutes.
I don't know exactly what this has to do with. GPS satellites are not geostationary, i.e. they move around in the sky as seen from Earth. Some satellites that were visible during the last position fix may no longer be. If I remember correctly, there is also a so-called GPS almanac (orbital data of the satellites). This is also sent by the satellites and stored in the GPS receiver. Based on this almanac, the approximate positions of the satellites can then be estimated by the device when the device is switched on again, in order to get a "position fix" more quickly again, or in other words, the GPS receiver can already make a preselection as to which satellites it should search for because they should be "visible". Maybe it has to do with that, I don't know exactly how long this almanac is valid on the respective device. Assuming it is out of date, the GPS unit will listen until it receives signals from some satellite. Usually there are at least 3 or 4 within a short period of time and then you can determine the location. To be honest, I don't think that almanac data becomes obsolete so quickly. They should be valid for at least a few days.
It should not be the programme itself, or rather the corresponding subroutine or the corresponding service, because I assume that it works as long as the period from the last valid "position fix" to the next valid fix is not too long.
As I said, it gets even worse if you also move a little faster (by car). Then you also constantly change your current position and it can take a long time...
I don't think it has anything to do with the service. It just doesn't fire because there is nothing to fire, there is no position fix. Watch the GPS icon on the smartphone. On many devices it flashes when there is no position fix.
Just my personal experience, of course it also depends on the GPS receiver itself. I experience the behaviour described above from time to time on my old HTC M7, not the latest model as I said. More modern smartphones are perhaps a bit more intelligent. But that is also just a guess.
Hope this helps a little bit.