Bug 235353

Summary: [meta] Perform media networking operation off the main thread
Product: WebKit Reporter: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Component: MediaAssignee: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, calvaris, cdumez, cgarcia, cmarcelo, eric.carlson, ews-watchlist, glenn, gustavo, japhet, jer.noble, menard, philipj, pnormand, sergio, vjaquez, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=241159
Bug Depends on:    
Bug Blocks: 205208, 241061, 243838    
Attachments:
Description Flags
WIP1
none
WIP2
ews-feeder: commit-queue-
WIP3
ews-feeder: commit-queue-
WIP3
ews-feeder: commit-queue-
WIP4
ews-feeder: commit-queue-
WIP4
ews-feeder: commit-queue-
WIP6
ews-feeder: commit-queue-
WIP6 ews-feeder: commit-queue-

Description Jean-Yves Avenard [:jya] 2022-01-19 04:09:49 PST
When playing multiple CRABS videos we can end up with a deadlock between the main thread and the CoreMedia player.

Currently data coming via PlatformMediaResourceLoader/PlatformMediaResourceClient comes on the main thread. 

When we have a sync call from the content process to the GPU Process to query status of the CoreMedia player this last one could be waiting for data to arrive on the main process. As the data will never come with the main thread blocked ; we end up in a deadlock.

This can be checked with this page:
https://webkit.apple.com/demos/bin/video/many-video-elements.html

Steps to reproduce:
1. Load <https://webkit.apple.com/demos/bin/video/many-video-elements.html> in Safari
2. Tap the “50” button to create 50 media elements
3. Playback will stall with < 50 elements successfully created

By moving the networking operations off the main thread, we could avoid a deadlock.
Comment 1 Jean-Yves Avenard [:jya] 2022-01-19 04:10:13 PST
rdar://84517825
Comment 2 Jean-Yves Avenard [:jya] 2022-01-19 04:21:28 PST
Created attachment 449473 [details]
WIP1
Comment 3 Jean-Yves Avenard [:jya] 2022-01-20 06:01:04 PST
Created attachment 449568 [details]
WIP2
Comment 4 Jean-Yves Avenard [:jya] 2022-01-24 06:46:12 PST
Created attachment 449809 [details]
WIP3
Comment 5 Jean-Yves Avenard [:jya] 2022-01-24 07:22:35 PST
Created attachment 449811 [details]
WIP3
Comment 6 Jean-Yves Avenard [:jya] 2022-01-25 00:30:40 PST
Created attachment 449903 [details]
WIP4
Comment 7 Jean-Yves Avenard [:jya] 2022-01-25 06:17:33 PST
Created attachment 449924 [details]
WIP4
Comment 8 Jean-Yves Avenard [:jya] 2022-01-30 20:13:53 PST
Created attachment 450374 [details]
WIP6

Fix crashes related to use of AtomString in ResourceResponse
Comment 9 Jean-Yves Avenard [:jya] 2022-01-31 00:07:20 PST
Created attachment 450386 [details]
WIP6

Fix crashes when GPU->WebContent connection is closed
Comment 10 Jean-Yves Avenard [:jya] 2022-05-18 05:22:56 PDT
Pull request: https://github.com/WebKit/WebKit/pull/719
Comment 11 EWS 2022-05-28 06:27:31 PDT
Committed r294999 (251097@main): <https://commits.webkit.org/251097@main>

Reviewed commits have been landed. Closing PR #719 and removing active labels.
Comment 12 Ryan Haddad 2022-05-31 16:36:30 PDT
This change was reverted in https://commits.webkit.org/251166@main because it introduced https://bugs.webkit.org/show_bug.cgi?id=241159
Comment 13 Jean-Yves Avenard [:jya] 2024-01-24 02:29:07 PST
Pull request: https://github.com/WebKit/WebKit/pull/23156
Comment 14 EWS 2024-01-30 19:33:04 PST
Committed 273804@main (75bfd79c190e): <https://commits.webkit.org/273804@main>

Reviewed commits have been landed. Closing PR #23156 and removing active labels.