-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Describe the bug
When clicking on a TimeSeries visualization, the seek event emits an inaccurate time value that doesn't match the actual data point clicked. The emitted value contains floating-point precision errors, resulting in a time value that doesn't exist in the original dataset.
For example:
- Clicking on data point
1770.677344emits seek event with value1770.6719467913167 - Clicking on data point
1733.719emits seek event with value1733.72516
This causes synchronization issues when TimeSeries is synced with audio/video players, as the seek events don't correspond to exact data points.
Video demonstration: https://www.loom.com/share/5f1f429a21f0438ca5f11e7146570bfe
To Reproduce
Steps to reproduce the behavior:
- Create a TimeSeries task with precise time values (e.g., using a CSV with timestamp column containing values like
1733.719,1770.677344) - Configure TimeSeries with
syncattribute to enable synchronization features - Open the labeling interface and load the task
- Click on a specific data point in the TimeSeries visualization
- Observe the seek event value in the browser console or synchronized media player
- Compare the emitted time value with the actual data point value displayed on hover
Expected behavior: The value shown on the plot should match exactly what is sent in the seek event
Actual behavior: The seek event emits a different time value with additional floating-point digits that don't exist in the original data
Expected behavior
The seek event should emit the exact time value of the nearest data point that was clicked. This ensures:
- Accurate synchronization with audio/video players
- Data integrity is maintained
- Annotations are created at precise data point locations
- No confusion between displayed values and actual seek positions
Screenshots
See video demonstration: https://www.loom.com/share/5f1f429a21f0438ca5f11e7146570bfe
The video shows:
- The TimeSeries visualization displaying a data point
- Clicking on the data point
- The seek event showing a different value than what was clicked
Environment (please complete the following information)
- OS: macOS (Darwin 25.0.0)
- Label Studio Version: develop branch (ahead of origin/develop by 492 commits)
- Browser: [Please specify]
- Component: TimeSeries tag with synchronization enabled
Additional context
Root Cause
The issue is caused by floating-point precision errors in pixel-to-time conversion calculations. The code performs continuous interpolation to convert click coordinates to time values:
const timeClicked = brushTimeStartNative + (clickX / plottingAreaWidth) * brushDurationNative;This calculation involves multiple floating-point operations (division, multiplication, addition) that accumulate rounding errors, resulting in time values that don't correspond to actual data points.
Impact
- High: Affects TimeSeries synchronization with video/audio players
- Medium: May cause annotation accuracy issues in time-based labeling tasks
- Medium: Could impact region creation precision when working with time series data
Affected Code Locations
The issue occurs in three places:
handleMainAreaClick()- Main area click handlerplotClickHandler()- Handler for MultiChannel visualization clicksemitSeekSync()- Automatic sync emission on brush range changes
Suggested Fix
Implement data point snapping logic using binary search to find the nearest actual data point instead of using continuous interpolation. This would ensure that all seek events emit exact data point values from the dataset.
Note: This is a precision/accuracy bug that affects the user experience when working with synchronized TimeSeries and media players. The fix should maintain backward compatibility while improving accuracy.