Bug 277321

Summary: stream not cancelled when seeking video(except for the first time)
Product: WebKit Reporter: youcheng321
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: cdumez, eric.carlson, jer.noble, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari 17   
Hardware: Mac (Intel)   
OS: macOS 14   
Attachments:
Description Flags
this video display the issue
none
demo none

youcheng321
Reported 2024-07-29 20:47:25 PDT
Created attachment 472012 [details] this video display the issue I am using a video element to play m3u8 and using a Service Worker to intercept mpeg-ts segment requests. To detect when a segment request is canceled upon video seeking, I return each segment as a ReadableStream. When seeking, the video needs to cancel the currently ongoing segment request and request new segments. At this point, the currently canceled segment triggers stream.cancel(). However, I found that only the first seek cancels the segment request and triggers the cancel event. When I seek again, the currently ongoing segment request is not canceled, nor does it trigger the cancel event. It's as if everything gets stuck, just like shown in the video. my Service Worker code: ``` self.addEventListener("fetch", (event) => { const requestUrl = event.request.url; if (requestUrl.indexOf('.ts') === -1) return; console.log('fragment request', event.request.url) event.respondWith((async () => { const stream = new ReadableStream({ start(controller) { console.log('start called', controller); }, cancel(reason) { console.log('cancel called', reason); } }); return new Response(stream); })()); }) ```
Attachments
this video display the issue (8.05 MB, video/mp4)
2024-07-29 20:47 PDT, youcheng321
no flags
demo (1.14 KB, application/zip)
2024-07-29 20:48 PDT, youcheng321
no flags
youcheng321
Comment 1 2024-07-29 20:48:51 PDT
Created attachment 472013 [details] demo here is the demo code
Radar WebKit Bug Importer
Comment 2 2024-08-05 20:48:19 PDT
Note You need to log in before you can comment on or make changes to this bug.