Commit ea79572
committed
[MSE][GStreamer] Deadlock while flushing on paused when there's a non in-place transform element
https://bugs.webkit.org/show_bug.cgi?id=260067
Reviewed by Alicia Boya Garcia.
There is a deadlock possible inside WebKit media src (MSE) between streaming thread handling
CAPS event and pipeline flush in the main thread. This happens in case where there is a
transform element in the pipeline that does transition NOT in place. Basetransform elem
expects that it will allocate buffers so on CAPS change it triggers allocation negotiations
(ALLOCATION query). In such case CAPS event becomes fully synchronous as basetransform does
ALLOCATION query that is synchronous (serialized with data) and may block the streaming
thread. If the pipeline is paused and the sink thread doesn't accept any data, this will
block CAPS event until pipeline is unpaused or flushed. But flush requires a lock that
streaming thread is holding (DataMutexLocker streamingMembers {
stream->streamingMembersDataMutex };)
See: #1135
A way to fix this is to make webKitMediaSrcLoop() release the lock before pushing the caps
event (which may take a long time to get processed) to let the main thread start the flush.
Such a flush would cause the sink element to release the streaming thread and the caps event
processing to finish. After the caps event has been pushed, the lock would be retaken. But
streamingMembers might have changed under our feet (and it certainly will, because of the
flush). We should reevaluate if the flush condition is present, and in that case abort the
execution of webKitMediaSrcLoop() after having paused the streaming task of the
corresponding pad.
* Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:
(webKitMediaSrcLoop): Run the caps pushing code with the lock released and reevaluate the flush condition after the lock is reacquired.
Canonical link: https://commits.webkit.org/267276@main1 parent 8a606e4 commit ea79572
1 file changed
Lines changed: 15 additions & 4 deletions
Lines changed: 15 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
434 | 438 | | |
435 | 439 | | |
436 | 440 | | |
| |||
517 | 521 | | |
518 | 522 | | |
519 | 523 | | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
525 | 536 | | |
526 | 537 | | |
527 | 538 | | |
| |||
0 commit comments