Skip to content

Optimize createSetCurrentTime to avoid setting currentTime while seeking #22

@AlexanderArvidsson

Description

@AlexanderArvidsson

Hi,

We optimized our non-sync player by avoiding to seek while the player is currently seeking, as outlined in this article:
https://kitchen.vibbio.com/blog/optimizing-html5-video-scrubbing/

We found an extreme improvement in scrubbing performance when avoiding setting currentTime if the player is currently seeking, by listening to the "seeking" and "seeked" events. If currentTime is set while player is currently seeking, we instead store the "pending" seek time and set it after "seeked" as occured, effectively throttling based on the browser seeking time.

It might seem insignificant, but it does make a huge difference. My assumption (as well as the article) is that excessively setting currentTime causes the player to cancel fetching the frame from memory before it has fully loaded, instead moving on to fetch a different frame. This causes the player to "get stuck" while seeking, until you stop seeking. By waiting for "seeked" event, you can see frames pop up when you scrub, and you respect the loading times of your browser.

Since you support creating a custom timingsrc function, I can try implementing this in user space and it could later be provided as an alternative function in the library. This should not affect playback, since currentTime is avoided as much as possible to avoid stuttering, so it's up to you if you want to include this logic in the default timingsrc function, or an alternative.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions