WebPlatformForEmbedded / WPEWebKit

WPE WebKit port (downstream)
211 stars 135 forks source link

Full asset is downloaded in progressive playback with "chunked" transfer encoding #1257

Closed filipe-norte-red closed 8 months ago

filipe-norte-red commented 8 months ago

When a server transfers a video resource using "chunked" transfer encoding, wpe will download the full file, irrespective of size (e.g. 150MB). However, if "chunked" transfer encoding is not used, wpe will download small parts, progressively requesting further parts of the file as needed. The attached test.zip contains:

Repo steps:

If you'd like to disable chunked transfer mode for test, edit myserver.js and comment line 20: res.setHeader('Transfer-Encoding', 'chunked');

test_chunked1

magomez commented 8 months ago

This happens on wpe-2.38 so we're using libsoup3 and HTTP2 requests. According to google, Transfer-Encoding:chunked is deprecated when using HTTP2 as all of the requests are chunked by design. The server shouldn't be replying with a Transfer-Content header when using an HTTP2 connection. Then, we may have a bug on our side handling that incorrect header that's causing that the full file is being downloaded. I'll ask internally about it.

magomez commented 8 months ago

Mi previous comment is not valid because the request is HTTP 1.1 and not 2.0. The problem seems to be that when Transfer-Encoding chunked is used, the Content-Lenght of the header is not available. Due to that, WebKitWebSourceGStreamer assumes that the content is not seekable and downloads the whole file. A way to handle chunked data should be added.

eocanha commented 8 months ago

I coded a patch to honor Content-Length when the Transfer-Encoding is chunked (so the WebKitWebSrc element has an idea of the actual length, considers that the content isn't "live" and can therefore unblock the seek and partial download features) and submitted it upstream for review as https://bugs.webkit.org/show_bug.cgi?id=266691 / https://github.com/WebKit/WebKit/pull/22093.

filipe-norte-red commented 8 months ago

Thanks for the feedback, @magomez . Will that be done via an upstream issue to be created? Or is it something you are working on?

modeveci commented 8 months ago

@filipe-norte-red , The PR is in review, in the meantime you can also give a try: https://github.com/WebKit/WebKit/pull/22093/commits/68c0a93e3bd650f84fe2a0a399b32d020d101ff2 Regards Ozgur

eocanha commented 8 months ago

The fix landed upstream as https://github.com/WebKit/WebKit/commit/dc4698316b36833706bc93aff6ad7a18cb3e4c33 and was backported to wpe-2.38 as https://github.com/WebPlatformForEmbedded/WPEWebKit/commit/b56a9c7fd3d95058fdacf5c004b6f21c0b33526c and to wpe-2.42 as https://github.com/WebPlatformForEmbedded/WPEWebKit/commit/4e6f7033a2cc06c36705d21b708cd4670630edb1. Closing issue.