Loop while processing

Something odd happened with my location data collected yesterday. A single sample (13 seconds) would continuously bounce between two segments. It clearly was stuck in a loop where it couldn’t decide which segment to attach the sample too.

I watched it bounce back and forth for a couple minutes before digging in marking it as bogus thus stopping the processing loop.


I have no idea what caused it, but I thought I’d mention it because this sort of thing might cause a battery drain as the app might never settle on the correct grouping for a given event.

Otherwise nifty app.
V3.10.0 iPhone SE (2022).

1 Like

Ah, you’ve stumbled onto one of my longest running pet hates. This is a bug that I’ve “fixed” at least twice, but still finds a way to hang in there.

The good news is it’s not a serious battery drain issue, because the infinite loop stops as soon as the app goes into the background. But it’s still peak annoying.

Basically what’s happening is, as you surmised, one sample is getting shuffled back and forth between two timeline items on each processing loop. This is a result of the “edge stealing” part of the processing loop, where adjacent Visit and Path timeline items potentially hand off samples between each other, based on the Visit’s gravitational pull. If the edge sample falls outside of the gravitational pull it will “fly away” and get given to the Path item instead. Conversely, if the edge sample from the Path falls within the Visit’s gravitational pull, it will get sucked into the Visit.

The bug is that a sample could get pulled into the Visit, which then changes the centre and “gravity” of the Visit such that the sample no longer falls within the gravitational pull, so it gets pushed out again. Repeat ad infinitum.

The fix was to have the processing loop remember which samples it pushed out / pulled in last time round, and if it sees that it’s shunting around the same sample(s) again, to break the loop and stop. Simple.

Except somehow it still occasionally happens :expressionless: My guess is it’s looping with a “nothing changed” step between, so it’s not noticing that it’s moving the same sample(s) it moved two loops ago. Which should be impossible, because after it notices the repeating pattern the first time it will stop - no more processing. But… there it is, you’ve seen it, I’ve seen it, it’s still happening :man_shrugging:t2:

So yeah, in the top five most annoying long running bugs :joy: I’ll catch it someday.

Oh, and yeah, your solution is pretty much the same as mine - change the activity type of the sample. The two activity types that have different gravitational weights from the rest are “stationary” and “bogus”. A stationary sample has more “weight” (or I guess mass, if we’re being picky), making stationary samples and segments more likely to stay within the gravitational pull of their Visit. A bogus sample has no weight/mass at all.

I tend to break the loop by changing the sample to either stationary or walking (or cycling, or whatever makes the most sense). One or the other will typically break the loop. But bogus will definitely get there too!

Thanks for the detailed reply. Glad to know it don’t run an infinite while the app is in the background.

1 Like