Skip to content

Migrate the WatchVideoPlaylist component to the composition API#8762

Open
absidue wants to merge 3 commits intoFreeTubeApp:developmentfrom
absidue:watch-video-playlist-composition
Open

Migrate the WatchVideoPlaylist component to the composition API#8762
absidue wants to merge 3 commits intoFreeTubeApp:developmentfrom
absidue:watch-video-playlist-composition

Conversation

@absidue
Copy link
Member

@absidue absidue commented Mar 6, 2026

Pull Request Type

  • Composition API migration
  • Performance improvement

Description

This pull request migrates the WatchVideoPlaylist component to the composition API. While testing the changes I noticed that shuffling was slow so I also improved the performance of it by switching to the modern version of the Fisher-Yates shuffle algorithm, as pushing to an array in a loop requires resizing arrays and splicing an array requires moving items around in the array each time an item is removed, the new in-place shuffling algorithm is a lot faster.

Screenshots

Measuremeants with my 16k item test playlist:

Before (notice how it is so slow that after clicking the shuffle button a few times in a row, V8 decides it needs to apply aggressive optimisations to the function, to avoid freezing the UI for 5.5 seconds):
before

After (the new approach is fast enough that V8 doesn't need to apply such aggressive optimisations):
after

While yes in the end the old approach ends up being faster because of the aggressive optimisations that V8 applies after clicking the shuffle button a few times, in real world situations users will probably only click the shuffle button once so a shuffle algorithm that is fast from the start is definitely the better choice.

Testing

Test both user playlists and YouTube playlists, as well as the various functions of the watch page playlist component.

Desktop

  • OS: Windows
  • OS Version: 11

@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Mar 6, 2026
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) March 6, 2026 23:21
@absidue absidue changed the title Watch video playlist composition Migrate the WatchVideoPlaylist component to the composition API Mar 7, 2026
Copy link
Member

Choose a reason for hiding this comment

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

On User or Creator playlists when you enable shuffle and skip to next video you receive an error. This error wont occur when shuffle is disbaled

VirtualBoxVM_mZvTGpq7CD.mp4

@efb4f5ff-1298-471a-8973-3d47447115dc

needs rebase into dev

@efb4f5ff-1298-471a-8973-3d47447115dc efb4f5ff-1298-471a-8973-3d47447115dc added PR: changes requested and removed PR: waiting for review For PRs that are complete, tested, and ready for review labels Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants