Skip to content

Commit 05d0bbc

Browse files
Staacksclaude
andcommitted
The periodicity displacement loop advances by an int, so it terminates.
doppler stalled the remote API on the lab's Galaxy A3 after a stop. It is not lock starvation and not the paused analysis re-running: it is a single analysis pass that never ends. Measured on the device with a debug build, a watchdog dumping the stack of any module that runs longer than four seconds: STUCK in periodicityAM for 22810 ms at Analysis$periodicityAM.update(Analysis.java:1979) at PhyphoxExperiment.processAnalysis(PhyphoxExperiment.java:417) Line 1979 is the innermost loop, and the counter said 346 million iterations and climbing. Logging the live locals from inside it explains why: live i=2355 j=12000 x2-i=12045 step=0.0 stepBits=0 iPlusStep=2355 step is the update of the displacement loop, "for (int i = minPeriod; i < maxPeriod; i += step)". It is declared double and assigned 1 or 2 and nothing else - yet on that device it reads back as +0.0, bit pattern and all, and (int)(i + step) is i. So i never advances, the loop cannot end, and since processAnalysis holds the data lock for the whole module loop, the experiment and every endpoint that touches buffer data stop with it. The same code with the same parameters finishes in 1 ms on a desktop JVM, so what produced the zero is below the source - but the shape is the bug either way: an int counter whose stride is a double is not guaranteed to advance, and this one only ever wanted 1 or 2. Making step an int fixes it on the device. The results do not change: with a user-selected range the stride was already 1, and 2 as an int is what the double 2 truncated to. corpus/analysis/vectors/periodicity/sine-user-range still passes. This was never only an API stall. doppler filled 4 buffers on the A3 before - all of them settings constants - and 15 after, because the pass that computes everything downstream of the periodicity never returned. The experiment was producing nothing at all on that phone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 25b6035 commit 05d0bbc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

app/src/main/java/de/rwth_aachen/phyphox/Analysis.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,12 @@ protected void update() {
19651965
double maxValueRight = Double.NEGATIVE_INFINITY;
19661966
double lastSum = Double.NEGATIVE_INFINITY;
19671967

1968-
double step = 1;
1968+
//An int, not a double: this is the update of an int loop counter, and a double
1969+
//that is anything below 1 makes "i += step" a no-op, so the loop cannot end. The
1970+
//lab's Galaxy A3 hit exactly that - the local was read back as +0.0 there, with
1971+
//i frozen and the innermost loop spinning - and since the analysis holds the data
1972+
//lock for a whole pass, the experiment and the whole remote API stopped with it.
1973+
int step = 1;
19691974
if (!userSelectedRange)
19701975
step = 2; //Until we find the first negative value, we can go faster...
19711976

0 commit comments

Comments
 (0)