RESOLVED FIXED 194220
[MSE][GStreamer] Batch player duration updates
https://bugs.webkit.org/show_bug.cgi?id=194220
Summary [MSE][GStreamer] Batch player duration updates
Alicia Boya García
Reported 2019-02-04 08:13:21 PST
This saves up a ton of CPU cycles doing layout unnecessarily when all the appended frames extend the duration of the movie, like in YTTV 2018 59.DASHLatencyVP9.
Attachments
Patch (6.45 KB, patch)
2019-02-06 12:19 PST, Alicia Boya García
no flags
Patch (6.44 KB, patch)
2019-02-06 12:40 PST, Alicia Boya García
no flags
Patch (6.50 KB, patch)
2019-02-19 04:34 PST, Alicia Boya García
no flags
Patch (6.36 KB, patch)
2019-02-19 05:14 PST, Alicia Boya García
no flags
Patch (5.60 KB, patch)
2019-02-21 08:09 PST, Alicia Boya García
calvaris: review+
calvaris: commit-queue-
Archive of layout-test-results from ews126 for ios-simulator-wk2 (2.47 MB, application/zip)
2019-02-21 10:08 PST, EWS Watchlist
no flags
Patch (5.54 KB, patch)
2019-02-21 15:12 PST, Alicia Boya García
no flags
Patch (5.59 KB, patch)
2019-02-22 12:18 PST, Alicia Boya García
no flags
Archive of layout-test-results from ews121 for ios-simulator-wk2 (2.74 MB, application/zip)
2019-02-23 00:53 PST, EWS Watchlist
no flags
Patch (5.59 KB, patch)
2019-02-23 04:32 PST, Alicia Boya García
no flags
Alicia Boya García
Comment 1 2019-02-06 12:19:14 PST
Alicia Boya García
Comment 2 2019-02-06 12:40:46 PST
Xabier Rodríguez Calvar
Comment 3 2019-02-07 03:25:34 PST
Comment on attachment 361317 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=361317&action=review Apart from the specific comments, as Charlie, I think this a very convoluted and weird way to accomplish the goal. > Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:65 > +void > +CodedFrameProcessingBatchContext::durationUpdate(RefPtr<PlaybackPipeline> playbackPipeline, MediaPlayer* mediaPlayer) style and ASSERT for main thread. > Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:79 > + ASSERT(!s_instance); I know we're doing this in the caller as well but I think we should also ASSERT(isMainThread()) here to ensure we don't create two instances at the same time. > Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:93 > +void > +CodedFrameProcessingBatchContext::enqueueDurationUpdate(RefPtr<PlaybackPipeline> playbackPipeline, MediaPlayer* mediaPlayer) style > Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h:49 > +class CodedFrameProcessingBatchContext { WTF_FORBID_HEAP_ALLOCATION; > Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h:51 > + static void durationUpdate(RefPtr<PlaybackPipeline>, MediaPlayer*); updateDuration > Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h:65 > + MediaPlayer* m_mediaPlayer { nullptr }; You can probably make this a MediaPlayer& and take that as parameter in the enqueue and updateDuration as well.
Alicia Boya García
Comment 4 2019-02-18 04:55:31 PST
Comment on attachment 361317 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=361317&action=review >> Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h:65 >> + MediaPlayer* m_mediaPlayer { nullptr }; > > You can probably make this a MediaPlayer& and take that as parameter in the enqueue and updateDuration as well. MediaPlayer* is provided by the player when calling durationUpdate(), not in the constructor. The only way to change that would be to initialize these variables with the creation of the context inside AppendPipeline. That would be doable, but I think it's clearer this way since you can see in the durationUpdate() call what objects will be acted upon.
Alicia Boya García
Comment 5 2019-02-18 05:01:01 PST
Regarding concerns of this being convoluted: the problem arises from the fact that duration updates are requested as part of sourceBufferPrivateDidReceiveSample(), which by design is called once per sample and will call durationChanged() if such sample grows the duration. Therefore, when processing a batch of samples, we need a way to turn off the expensive notifications until the batch is finished. A stack context class like this does exactly that, in a RAII fashion.
Xabier Rodríguez Calvar
Comment 6 2019-02-18 22:57:35 PST
(In reply to Alicia Boya García from comment #4) > Comment on attachment 361317 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=361317&action=review > > >> Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h:65 > >> + MediaPlayer* m_mediaPlayer { nullptr }; > > > > You can probably make this a MediaPlayer& and take that as parameter in the enqueue and updateDuration as well. > > MediaPlayer* is provided by the player when calling durationUpdate(), not in > the constructor. The only way to change that would be to initialize these > variables with the creation of the context inside AppendPipeline. That would > be doable, but I think it's clearer this way since you can see in the > durationUpdate() call what objects will be acted upon. Yes, you'right!
Alicia Boya García
Comment 7 2019-02-19 04:09:50 PST
Comment on attachment 361317 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=361317&action=review >> Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h:49 >> +class CodedFrameProcessingBatchContext { > > WTF_FORBID_HEAP_ALLOCATION; I would like to, but unfortunately it has the side effect of disallowing destructors.
Alicia Boya García
Comment 8 2019-02-19 04:34:29 PST
Alicia Boya García
Comment 9 2019-02-19 05:14:50 PST
Alicia Boya García
Comment 10 2019-02-21 08:09:33 PST
EWS Watchlist
Comment 11 2019-02-21 10:08:15 PST
Comment on attachment 362607 [details] Patch Attachment 362607 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: https://webkit-queues.webkit.org/results/11232741 New failing tests: fast/viewport/ios/device-width-viewport-after-changing-view-scale.html
EWS Watchlist
Comment 12 2019-02-21 10:08:16 PST
Created attachment 362616 [details] Archive of layout-test-results from ews126 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews126 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.6
Alicia Boya García
Comment 13 2019-02-21 15:12:18 PST
Xabier Rodríguez Calvar
Comment 14 2019-02-22 03:41:39 PST
Comment on attachment 362607 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=362607&action=review > Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:680 > + m_durationChangedWhileBlocked = false; You can do this inside the if. > Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:118 > + bool m_blockingDurationChanges = false; > + bool m_durationChangedWhileBlocked = false; m_areDurationChangesBlocked and m_shouldReportDurationWhenUnblocking
Alicia Boya García
Comment 15 2019-02-22 12:18:39 PST
EWS Watchlist
Comment 16 2019-02-23 00:53:14 PST
Comment on attachment 362742 [details] Patch Attachment 362742 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: https://webkit-queues.webkit.org/results/11257923 New failing tests: fast/viewport/ios/device-width-viewport-after-changing-view-scale.html
EWS Watchlist
Comment 17 2019-02-23 00:53:16 PST
Created attachment 362818 [details] Archive of layout-test-results from ews121 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews121 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.6
Alicia Boya García
Comment 18 2019-02-23 04:32:14 PST
Charlie Turner
Comment 19 2019-02-24 10:01:16 PST
Informal r+ from me :)
WebKit Commit Bot
Comment 20 2019-02-25 02:12:03 PST
Comment on attachment 362824 [details] Patch Clearing flags on attachment: 362824 Committed r242034: <https://trac.webkit.org/changeset/242034>
WebKit Commit Bot
Comment 21 2019-02-25 02:12:05 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.