Youtube scrolling bug

Youtube bug in the new virtual DOM. Tested in Firefox and Chrome stable.

Repro:

  • Play a Youtube video embedded in a post, and scroll up or down but the post itself is still visible.
  • The URL bar will refresh as another post (before or after) becomes visible.
  • The video should continue playing. Instead, it reloads, beginning playback again from the beginning.
  • Every time the URL updates and the containing post is partly visible (even if the video itself is offscreen) it will reload.
  • If you scroll up or down until the containing post is offscreen, the video stops and doesn’t reload until you click it again.

See example here:

Another one here:

https://meta.discourse.org/t/the-end-of-clown-vomit-or-simplified-category-styles/24249/144

2 Likes

This may be related to YouTube links that start the video from a specific spot.

For instance, the example you linked involved the video starting @ 2:26.

This is the precise URL I used for that post: https://youtu.be/ZKpFFD7aX3c?t=2m26s

Otherwise, confirmed from my side based on your repro steps.

Well, lets try it with a different one.

https://meta.discourse.org/t/the-end-of-clown-vomit-or-simplified-category-styles/24249/144?u=ky_metro

The repro steps in your OP did not conjure the same bug as seen from my post. RE: simplified category styles post.

I start that video, scroll down, the video stops. I scroll back up, press play anew, let it run a bit then scroll up; it stops. Intended behavior. I am on latest Chrome/Windows 10.

So, this narrows down to videos that start from a spot specified in the URL.

That’s interesting. For me it did the same thing as repro steps, restarted playing. I’m on latest Chrome / Win10 too.

Try disabling all your plugins/extensions? Then test anew.

After some experimenting, I’ve updated the repro steps. Its more tied to the post which contains the video, not the video itself.

Keep a tiny bit of that video’s post onscreen as you scroll around, and the video will reload every time the URL updates. Once the post goes offscreen, the video stops.

2 Likes

Yep I can repro this @eviltrout

I’ve got a fix here for the video restarting when scrolling to different posts:

https://github.com/discourse/discourse/commit/65d7103bdc20d597decaeefa6ae9c782d6d51aaa

As for it stopping when offscreen: that’s the result of our cloaking, which tries to save memory by unloading things as they scroll off. We might be able to increase the threshold before this happens, or perhaps add a check to see if there’s a video playing, but I think it’s less serious of a bug.

4 Likes

I’m all for turning a bug into a new feature. Facebook does this too, right?

Unless you’re listening to music, I can’t see needing to keep the video running offscreen.