Skip to content

Comments

fix: Calibration Points Not Rendering for Low Point Counts (< 4)#111

Open
thechillbasu wants to merge 1 commit intoruxailab:mainfrom
thechillbasu:fix/calibration-points-logic
Open

fix: Calibration Points Not Rendering for Low Point Counts (< 4)#111
thechillbasu wants to merge 1 commit intoruxailab:mainfrom
thechillbasu:fix/calibration-points-logic

Conversation

@thechillbasu
Copy link

@thechillbasu thechillbasu commented Feb 8, 2026

Description

The eye-tracking calibration system was failing to render calibration points when configured with fewer than 4 points (e.g., 2 or 3 points).

Technical Analysis:
The bug was traced to the generateRuntimePattern method used to calculate dynamic point coordinates. The logic attempts to distribute points evenly by calculating step sizes based on grid dimensions:

const stepY = usableHeight / (rows - 1);

For configurations with fewer than 4 points, the grid logic results in a single row (rows = 1). This causes the denominator (rows - 1) to become 0, leading to a Division by Zero error.

The resulting coordinates become NaN (Not a Number). Since the rendering engine cannot draw elements at invalid coordinates, the calibration screen remains blank, even though the application state indicates calibration is active.

Solution and Reasoning

I replaced the usage of the flawed generateRuntimePattern with the existing, robust generateCalibrationPattern method.

Why this is the correct fix:
Instead of patching the faulty logic in generateRuntimePattern, switching to generateCalibrationPattern leverages a proven implementation that explicitly handles edge cases for 1-row or 1-column layouts. It correctly calculates coordinates for any number of points without division errors, ensuring stability and preventing similar regressions.

Before and After

Before (Bug)

The calibration screen remains blank with 2 points configured.

before-fix-points.mov

After (Fix)

The calibration points appear correctly and function as expected.

after-fix.points.mov

Closes #110

    Replaces buggy generateRuntimePattern with generateCalibrationPattern to
    fix an issue where setting point count to 2 or 3 resulted in infinite/NaN
    coordinates due to (rows-1) division by zero.

    Generated patterns now correctly handle all point counts (2-9) with
    specific geometric layouts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛[Bug] : Calibration Points Fail to Render with Low Point Configurations (Points < 4)

1 participant