π Bug Description
The tracking-loss early return in src/services/exerciseEngine.ts does not update trackingLostFrames, visibilityBuffer, or lastValidAngles in the returned state object. On subsequent frames, the counter reads the stale value from currentState and never accurately increments, making the tracking-loss diagnostic counter unreliable during occlusion.
Bug location β src/services/exerciseEngine.ts:351-358 (approximate):
if (avgVisibility < 0.4 && nextTrackingLostFrames >= 5) {
return {
...currentState, // trackingLostFrames stays at previous value (e.g., 4)
feedback: 'SENSORS BLURRED β POSITION BODY',
status: 'yellow',
isInExercisePosture: false,
liveDepthFeedback: '',
// MISSING: trackingLostFrames, visibilityBuffer, lastValidAngles
};
}
The non-early-return path (lines ~738-740) correctly includes these:
return {
...currentState,
// ...
trackingLostFrames: nextTrackingLostFrames,
visibilityBuffer: newVisibilityBuffer,
lastValidAngles: nextLastValidAngles,
};
Steps To Reproduce
- Start a workout
- Occlude the camera so tracking is lost
- trackingLostFrames increments to 4 (just below threshold of 5)
- On the 5th frame,
nextTrackingLostFrames >= 5 is true
- Early return fires with only
...currentState (trackingLostFrames remains 4)
- Counter stuck at 4 forever β every subsequent frame calculates
nextTrackingLostFrames = 4 + 1 = 5, condition passes, early returns with trackingLostFrames: 4
- Counter never reflects the actual duration of tracking loss
Expected Behavior
- Early return should override
trackingLostFrames with the current nextTrackingLostFrames value
visibilityBuffer and lastValidAngles should also be updated to avoid stale data
Actual Behavior
- trackingLostFrames counter stuck at 4 during sustained tracking loss
- visibilityBuffer also never updated β reappends to the same 4-element stale buffer
- No diagnostic impact on functionality (recovery still works), but diagnostic data is inaccurate
Browser
Chrome
Operating System
All
Node.js Version
v20.x
Additional Context
Impact: LOW-MEDIUM. The tracking-loss counter provides inaccurate data during sustained occlusion. Recovery is unaffected because the counter checks the condition correctly, but the returned state is stale.
Level: 1 (Beginner Friendly) β add missing state fields to early return
π Bug Description
The tracking-loss early return in
src/services/exerciseEngine.tsdoes not updatetrackingLostFrames,visibilityBuffer, orlastValidAnglesin the returned state object. On subsequent frames, the counter reads the stale value fromcurrentStateand never accurately increments, making the tracking-loss diagnostic counter unreliable during occlusion.Bug location β src/services/exerciseEngine.ts:351-358 (approximate):
The non-early-return path (lines ~738-740) correctly includes these:
Steps To Reproduce
nextTrackingLostFrames >= 5is true...currentState(trackingLostFrames remains 4)nextTrackingLostFrames = 4 + 1 = 5, condition passes, early returns withtrackingLostFrames: 4Expected Behavior
trackingLostFrameswith the currentnextTrackingLostFramesvaluevisibilityBufferandlastValidAnglesshould also be updated to avoid stale dataActual Behavior
Browser
Chrome
Operating System
All
Node.js Version
v20.x
Additional Context
Impact: LOW-MEDIUM. The tracking-loss counter provides inaccurate data during sustained occlusion. Recovery is unaffected because the counter checks the condition correctly, but the returned state is stale.
Level: 1 (Beginner Friendly) β add missing state fields to early return