Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Issue 1351473006: WebmMuxer-MediaRecorderHandler: thread hopping and data ownership (Closed)

Created:
5 years, 3 months ago by mcasas
Modified:
5 years, 3 months ago
Reviewers:
emircan, miu, ajose, DaleCurtis
CC:
chromium-reviews, mlamouri+watch-content_chromium.org, posciak+watch_chromium.org, jam, mcasas+watch_chromium.org, feature-media-reviews_chromium.org, darin-cc_chromium.org, mkwst+moarreviews-renderer_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

WebmMuxer-MediaRecorderHandler: thread hopping and data ownership This CL addresses the global thread model between VideoTrackRecorder - MediaRecorderHandler - WebmMuxer. The constraints: all of them are created on Main Renderer thread, whereas VTR frames come via Renderer IO thread. The final result goes to Blink on Main Renderer Thread. VideoTrackRecorder (IO) sends frames to WebmMuxer, that is destroyed on Main Render thread. This causes a race between WebmMuxer dtor and (the last) frame in flight. This race was found during integration tests. To address this issue, this CL moves WebmMuxer to Main render thread completely, and the frames coming from VTR on IO thread are trampolined on MediaRecorderHandler thanks to BindToCurrentLoop. To clarify data ownership across all these thread hops, the encoded/contained data is managed as a scoped_ptr<std::string>. This is OK since that data is not shared, but passed from stage to stage (and StringPiece only works in a single thread environment since the data is not copied but managed as unowned pointer). Unittests, docs and headers adapted. BUG=262211 TESTS=All appropriate UTs passing and also the whole shebang test in https://crrev.com/1354863002/ Committed: https://crrev.com/a46a0503424df3f5f14c9b6422cdf97a26b9d45b Cr-Commit-Position: refs/heads/master@{#350234}

Patch Set 1 : #

Total comments: 1

Patch Set 2 : Fix data ownership before thread jump. ajose@ comment #

Total comments: 3

Patch Set 3 : miu@ proposal #

Total comments: 12

Patch Set 4 : miu@s comments #

Total comments: 2

Patch Set 5 : StringPiece passed by value #

Unified diffs Side-by-side diffs Delta from patch set Stats (+78 lines, -62 lines) Patch
M content/renderer/media/media_recorder_handler.h View 1 2 3 4 2 chunks +11 lines, -6 lines 0 comments Download
M content/renderer/media/media_recorder_handler.cc View 1 2 3 4 5 chunks +21 lines, -8 lines 0 comments Download
M content/renderer/media/media_recorder_handler_unittest.cc View 1 chunk +3 lines, -3 lines 0 comments Download
M content/renderer/media/video_track_recorder.h View 1 2 2 chunks +1 line, -3 lines 0 comments Download
M content/renderer/media/video_track_recorder.cc View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
M content/renderer/media/video_track_recorder_unittest.cc View 1 2 5 chunks +14 lines, -7 lines 0 comments Download
M media/capture/webm_muxer.h View 1 2 3 4 3 chunks +12 lines, -14 lines 0 comments Download
M media/capture/webm_muxer.cc View 1 2 3 4 chunks +9 lines, -7 lines 0 comments Download
M media/capture/webm_muxer_unittest.cc View 1 2 3 4 4 chunks +5 lines, -12 lines 0 comments Download

Messages

Total messages: 27 (12 generated)
mcasas
ajose@, ermican@ PTAL
5 years, 3 months ago (2015-09-17 00:53:59 UTC) #3
ajose
lgtm https://codereview.chromium.org/1351473006/diff/40001/media/capture/webm_muxer.h File media/capture/webm_muxer.h (right): https://codereview.chromium.org/1351473006/diff/40001/media/capture/webm_muxer.h#newcode48 media/capture/webm_muxer.h:48: static void FinalizeSegment(scoped_ptr<mkvmuxer::Segment> segment); Can this be below ...
5 years, 3 months ago (2015-09-17 21:35:27 UTC) #5
mcasas
miu@ PTAL emircan@ ping
5 years, 3 months ago (2015-09-18 02:08:28 UTC) #8
miu
not lgtm: https://codereview.chromium.org/1351473006/diff/80001/content/renderer/media/media_recorder_handler.cc File content/renderer/media/media_recorder_handler.cc (right): https://codereview.chromium.org/1351473006/diff/80001/content/renderer/media/media_recorder_handler.cc#newcode90 content/renderer/media/media_recorder_handler.cc:90: base::Bind(&media::WebmMuxer::OnEncodedVideo, webm_muxer_); This does not call for ...
5 years, 3 months ago (2015-09-21 19:39:43 UTC) #9
mcasas
https://codereview.chromium.org/1351473006/diff/80001/content/renderer/media/media_recorder_handler.cc File content/renderer/media/media_recorder_handler.cc (right): https://codereview.chromium.org/1351473006/diff/80001/content/renderer/media/media_recorder_handler.cc#newcode90 content/renderer/media/media_recorder_handler.cc:90: base::Bind(&media::WebmMuxer::OnEncodedVideo, webm_muxer_); On 2015/09/21 19:39:43, miu wrote: > This ...
5 years, 3 months ago (2015-09-21 20:22:18 UTC) #10
miu
https://codereview.chromium.org/1351473006/diff/80001/content/renderer/media/media_recorder_handler.cc File content/renderer/media/media_recorder_handler.cc (right): https://codereview.chromium.org/1351473006/diff/80001/content/renderer/media/media_recorder_handler.cc#newcode90 content/renderer/media/media_recorder_handler.cc:90: base::Bind(&media::WebmMuxer::OnEncodedVideo, webm_muxer_); On 2015/09/21 20:22:18, mcasas wrote: > Yes, ...
5 years, 3 months ago (2015-09-21 20:57:12 UTC) #11
mcasas
miu@ PTAL big changes - I suggest checking the whole diff, not the latest delta. ...
5 years, 3 months ago (2015-09-21 22:25:47 UTC) #16
miu
Much better. I should say that I'm not against ref-counting for no good reason. ;-) ...
5 years, 3 months ago (2015-09-22 04:11:08 UTC) #17
mcasas
miu@ PTAL https://codereview.chromium.org/1351473006/diff/170001/content/renderer/media/media_recorder_handler.cc File content/renderer/media/media_recorder_handler.cc (right): https://codereview.chromium.org/1351473006/diff/170001/content/renderer/media/media_recorder_handler.cc#newcode10 content/renderer/media/media_recorder_handler.cc:10: #include "base/strings/stringprintf.h" On 2015/09/22 04:11:08, miu wrote: ...
5 years, 3 months ago (2015-09-22 16:58:41 UTC) #18
miu
lgtm https://codereview.chromium.org/1351473006/diff/170001/media/capture/webm_muxer.cc File media/capture/webm_muxer.cc (right): https://codereview.chromium.org/1351473006/diff/170001/media/capture/webm_muxer.cc#newcode102 media/capture/webm_muxer.cc:102: write_data_callback_.Run(scoped_ptr<std::string>( On 2015/09/22 16:58:41, mcasas wrote: > On ...
5 years, 3 months ago (2015-09-22 19:10:07 UTC) #19
mcasas
DaleCurtis: media/capture/webm_muxer* Owners RS/ PTAL https://codereview.chromium.org/1351473006/diff/170001/media/capture/webm_muxer.cc File media/capture/webm_muxer.cc (right): https://codereview.chromium.org/1351473006/diff/170001/media/capture/webm_muxer.cc#newcode102 media/capture/webm_muxer.cc:102: write_data_callback_.Run(scoped_ptr<std::string>( On 2015/09/22 19:10:06, ...
5 years, 3 months ago (2015-09-22 20:20:04 UTC) #21
DaleCurtis
miu@, mcasas@ you two should have a top-level per-file OWNERS for these. rs lgtm based ...
5 years, 3 months ago (2015-09-22 20:28:39 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1351473006/210001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1351473006/210001
5 years, 3 months ago (2015-09-22 20:33:48 UTC) #25
commit-bot: I haz the power
Committed patchset #5 (id:210001)
5 years, 3 months ago (2015-09-22 21:21:41 UTC) #26
commit-bot: I haz the power
5 years, 3 months ago (2015-09-22 21:53:01 UTC) #27
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/a46a0503424df3f5f14c9b6422cdf97a26b9d45b
Cr-Commit-Position: refs/heads/master@{#350234}

Powered by Google App Engine
This is Rietveld 408576698