I have cache headers from the request on
I have cache headers from the request on a mp4 file:
Cache-Control: max-age=2678400 Cf-Cache-Status: HIThttps://assets.flayks.com/4thsex-screencast.mp4
50 Replies
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
that's what I get from the Network tab
so I guess ~600ms?
You say there are multiple videos triggered in a short time. Could it be a limit of your browser? For example Chrome allows 6 concurrent HTTP requests for the same domain.
ah, really? that could explain things. Yes typically the IntersectionObserver is triggering the loading of videos if you scroll fast
Blocking: The Web Performance Villain
You may not realize it, but your pages may be slowing down due to something that usually flies under the radar. Learn what you can do today about blocking.
Hm I tried with another CDN provider and its definitely not coming from that so R2 is fine 🤔
@kev-ac do you see any issues here? I made a little REPL of my usage: https://svelte.dev/repl/e2e81ef4e2aa4380a7043ba439545913?version=4.2.2
Play-pause video playing from viewport visibility • REPL • Svelte
Cybernetically enhanced web apps
I get an 500 error when opening your link
dammit 🤦 Svelte REPL is down haha
actually linked to Cloudflare outage 🤭
They really don't have a good streak right now. 😁 Perfect timing that I just contacted their ENT sales today for a contract.
Seems to work again now. Now you just have to tell me what I need to do there. Never worked with svelte before.
I see a (recording?) of the website on the right side. But I can't see any playing videos, its just static images.
Hm weird. It's all videos yes, they should play based on the scroll
Here's a screen recording from what I can see
I can see the mp4s being partially fetched from assets.flayks.com, but they don't play. Maybe an autoplay issue?
I'm on macOS 14 / Safari 17.0
I don't see any issue from that first video, it's more when you scroll fast over the other ones
But yes essentially that's the whole problem, the videos are not played properly for some reason
That's what's happening on my end on the website (not REPL but same code essentially)
Could there be an issue in your code that calls pause? Or can you see from the network tab that the playback must be stalling because of a slow download?
Not sure at this point 😬 all I see is that, nothing happens for like 20sc
Interesting. Looking at the request size. What bytes range is this requesting? 0-1?
then now:
No idea, the videos are 15-35mb though, not 300b
You can see it when you click in on the request. Under request headers is the Range header
But that being said its rather hard for me to debug it from my side. From what I can see here all videos are fetched as quick as expected.
So obscure!
Have you tried another browser? Something like Firefox?
I didn't but just checked and it's all good, so definitely Chrome/ium related 😮
Range: bytes=4974078-
Do you call pause() on the videos once they go out of the viewport? Maybe try commenting it out. Could be a race condition, depending on how you call it
I tried many things and ended up playing with the promise of play as it is one, it's messy haha
I use
inView
which is pretty much an IntersectionObserver wrapperThe function returns once it goes out of viewport?
yes that's it
What's the state of playPromise when you return the video? Can you add a console.log() to the first line in the return function?
Something like
console.log(playPromise)
.It goes
Promise {<fulfilled>: undefined}
all the time even though the video freezes/stops
sometimes goes Promise {<pending>}
In this iteration: 1/7 video is stuck (and I scroll back over twice)
Good to see the pending promises. Shows that the play promise has not resolved fast enough when you scroll fast enough. But that shouldn't matter because you wait for the promise to resolve before pausing it.
Yea that's what I thought too, not an expert about it but it kinda makes sense, it's so tricky 😵💫
Shouldn't make a difference but have you tried making it an async function and awaiting the play() promise instead?
I think
inView
doesn't like that, I think I tried 😅
or do you mean just the return?Very dirty idea: Add a setTimeout() for like half a second, just to see if its a race condition.
went there too 😂 even with a clearTimeout in the return and a time difference to not trigger the play if scrolling too fast
It really feels like Chrome is throttling the incoming data for these videos
Very strange bug. What I still don't understand:
- It works in Firefox, it doesn't work in Chrome => Indicated browser / implementation bug
- It doesn't work in Chrome with R2, It does work in Chrome with another CDN => Indiciates R2 problem
I tried BunnyCDN as an alternative and it was the same so R2 is not the culprit here
Oh it was the same, then I have misunderstood you there
will try Safari just for the sake of it 😂
Chrome does do range requests for video files to only fetch as much as needed ahead. But its not really throttling. (But Firefox should do it as well)
yea all fine on Safari/Firefox. SO strange!
my career of bug finder is gonna keep going then haha
Main job description of every developer.
But I think sadly I'm of no real help to you here without having more context of the code base, which would go too deep here.
Oh well don't sweat it hey, chrome users are gonna have to scroll slowly hahaha
thank you so much for investigating! 🙏
Simple as that
yes 😂
or worst case scenario I don't do autoplay and click to play to also reduce incoming data, might not be the stupidest idea hey 🤷
If you feel lucky you could use something like Browserstack to test against an old version of chrome if its a new bug.
might try! thanks