HumanSignal / HumanSignal/label-studio

TimeSeries: Seek events emit inaccurate time values when clicking on data points

Open
#8,601 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
28.3k
Forks
3.7k
Avg merge
14h
Merged PRs (30d)
15

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.677344` emits seek event with value `1770.6719467913167`
- Clicking on data point `1733.719` emits seek event with value `1733.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](https://www.loom.com/share/5f1f429a21f0438ca5f11e7146570bfe)

## To Reproduce

Steps to reproduce the behavior:

1. Create a TimeSeries task with precise time values (e.g., using a CSV with timestamp column containing values like `1733.719`, `1770.677344`)
2. Configure TimeSeries with `sync` attribute to enable synchronization features
3. Open the labeling interface and load the task
4. Click on a specific data point in the TimeSeries visualization
5. Observe the seek event value in the browser console or synchronized media player
6. 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](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:

```javascript
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:
1. `handleMainAreaClick()` - Main area click handler
2. `plotClickHandler()` - Handler for MultiChannel visualization clicks
3. `emitSeekSync()` - 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.