Skip to content

Video: Fix race condition during rapid video frame navigation - #333

Merged
jblake42 merged 13 commits into
devfrom
video/bug-fix/uda-race-condition
Aug 3, 2026
Merged

Video: Fix race condition during rapid video frame navigation#333
jblake42 merged 13 commits into
devfrom
video/bug-fix/uda-race-condition

Conversation

@abdullah-ukaea

@abdullah-ukaea abdullah-ukaea commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Rapid frame navigation could cause stale responses to overwrite newer frames, leaving the video view flickering and unusable.

This change tracks the latest requested frame, cancels older requests, and only allows the newest response to update the UI. Rapid Next and Previous clicks now resolve to the expected frame.

This will close issue #332

Current dev branch behaviour

dev_branch.mp4

This branch behaviour

latest_branch_fix.mp4

@abdullah-ukaea abdullah-ukaea self-assigned this Jul 23, 2026
@abdullah-ukaea abdullah-ukaea added the bug Something isn't working label Jul 23, 2026
@abdullah-ukaea
abdullah-ukaea requested a review from jblake42 July 23, 2026 12:53
@abdullah-ukaea abdullah-ukaea changed the title Fix race condition during rapid video frame navigation Video: Fix race condition during rapid video frame navigation Jul 23, 2026
@abdullah-ukaea

Copy link
Copy Markdown
Collaborator Author

ready for code review @jblake42

@jblake42 jblake42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and I'm happy for it to merge. Could I ask you to look how easy it would be for the frame display to show the requested frame when a user is quickly clicking through the frames as at the moment it remains on the current frame until the user stops clicking and the frame loads.

This isn't blocking and if it is more than a few lines of code I'm happy for it to be pulled into a new PR.

Comment thread toktagger/ui/src/app/contexts/SampleContext.tsx
Comment thread toktagger/ui/src/app/video/components/video-view.tsx Outdated
@abdullah-ukaea

abdullah-ukaea commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

This looks good and I'm happy for it to merge. Could I ask you to look how easy it would be for the frame display to show the requested frame when a user is quickly clicking through the frames as at the moment it remains on the current frame until the user stops clicking and the frame loads.

This isn't blocking and if it is more than a few lines of code I'm happy for it to be pulled into a new PR.

yep this is possible by just displaying "desired frame" turned out to be a 1 line code change 70e371e

The problem now, is that when the user clicks next e.g. from frame 0 to frame 1 there is a delay so that while the user sees the frame display is at frame 1 they are still at frame 0 for a few seconds until it updates. So I added a very small spinner above the frame display to give the user some indication they are not at the frame they think they are. Let me know what you think about this change in commit e149d98 @jblake42

@jblake42

Copy link
Copy Markdown
Collaborator

This looks good and I'm happy for it to merge. Could I ask you to look how easy it would be for the frame display to show the requested frame when a user is quickly clicking through the frames as at the moment it remains on the current frame until the user stops clicking and the frame loads.
This isn't blocking and if it is more than a few lines of code I'm happy for it to be pulled into a new PR.

yep this is possible by just displaying "desired frame" turned out to be a 1 line code change 70e371e

The problem now, is that when the user clicks next e.g. from frame 0 to frame 1 there is a delay so that while the user sees the frame display is at frame 1 they are still at frame 0 for a few seconds until it updates. So I added a very small spinner above the frame display to give the user some indication they are not at the frame they think they are. Let me know what you think about this change in commit e149d98 @jblake42

I think the spinner is a good idea but I am not a fan of the implementation as it is not very obvious the spinner is there. My recommendation would be a larger spinner over the actual image as that is incredibly clear that something is loading. Not sure on the feasibility so open to other implementations

2026-07-30.07-06-10.mp4

@jblake42 jblake42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes relating to the spinner as per above comment

@abdullah-ukaea

abdullah-ukaea commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

Request changes relating to the spinner as per above comment

@jblake42 I have updated this branch with a new commit 10bcd6b that does what I think you wanted me to change with the spinner. Let me know if you are okay with this implementation

new.spinner.mp4

@abdullah-ukaea

abdullah-ukaea commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

Regarding the second feature you requested to disable annotations during frame loading @jblake42

I confirmed that users can still draw annotations while a new frame is loading, but I have not fixed this in this PR on purpose. The video view has been significantly refactored in PR #334, so I would prefer to disable annotation editing during frame loading there to avoid conflicting changes. If you are happy with the new spinner, I think this PR is ready to merge.

I have documented this in that PR already here #334 (comment)

@jblake42 jblake42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make use of react spectrum for the spinner e.g.:
<ProgressCircle aria-label="Loading…" size="L" isIndeterminate /> instead of a custom component

After that I am happy for you to merge

@abdullah-ukaea

Copy link
Copy Markdown
Collaborator Author

Please make use of react spectrum for the spinner e.g.: <ProgressCircle aria-label="Loading…" size="L" isIndeterminate /> instead of a custom component

After that I am happy for you to merge

fixed in commit ac54c72

Is this branch ready to be merged now? @jblake42

@jblake42
jblake42 self-requested a review August 3, 2026 15:16

@jblake42 jblake42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jblake42
jblake42 merged commit 4248ac6 into dev Aug 3, 2026
@abdullah-ukaea
abdullah-ukaea deleted the video/bug-fix/uda-race-condition branch August 12, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants