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

Issue 2998923002: Use SingleThreadedTaskQueue in DirectTransport (Closed)

Created:
3 years, 4 months ago by eladalon
Modified:
3 years, 4 months ago
CC:
webrtc-reviews_webrtc.org, video-team_agora.io, yujie_mao (webrtc), zhengzhonghou_agora.io, tlegrand-webrtc, tterriberry_mozilla.com, the sun, mflodman
Target Ref:
refs/heads/master
Project:
webrtc
Visibility:
Public.

Description

Use SingleThreadedTaskQueue in DirectTransport DirectTransport has so far used its own thread, which led to a different threading-model for in the unit-tests than is used in actual WebRTC. Because of that, some critical-sections that weren't truly necessary in WebRTC could not be replaced with thread-checks, because those checks failed in unit-tests. This CL introduces SingleThreadedTaskQueue - a TaskQueue which guarantees to run all of its tasks on the same thread (rtc::TaskQueue doesn't guarantee that on Mac) - and uses that for DirectTransport. CLs based on top of this will uncomment thread-checks which had to be commented out before, and remove unnecessary critical-sections. Future work would probably replace the thread-checkers by more sophisticated serialized-access checks, allowing us to move from the SingleThreadedTaskQueue to a normal TaskQueue. Related implementation notes: * This CL has made DirectTransport::StopSending() superfluous, and so it was deleted. BUG=webrtc:8113, webrtc:7405, webrtc:8056, webrtc:8116 Review-Url: https://codereview.webrtc.org/2998923002 Cr-Commit-Position: refs/heads/master@{#19445} Committed: https://chromium.googlesource.com/external/webrtc/+/413ee9a010eca70712a6935c68b815201bee1270

Patch Set 1 #

Total comments: 7

Patch Set 2 : Unit-tests added. #

Patch Set 3 : . #

Patch Set 4 : Added PostDelayedTask #

Patch Set 5 : Rebase + fix some tests on Linux. #

Patch Set 6 : . #

Patch Set 7 : . #

Total comments: 20

Patch Set 8 : Response to nisse's CR. #

Total comments: 10

Patch Set 9 : Response to nisse's CR. #

Patch Set 10 : Handle deprecated functions for internal projects. #

Patch Set 11 : Sequenced-checker dependency. #

Patch Set 12 : Fix perf-tests. #

Patch Set 13 : Release capturer on correct thread. #

Patch Set 14 : Fix video_loopback teardown on Linux. #

Patch Set 15 : Some fixes. #

Patch Set 16 : Appease win_msvc_rel. #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+2280 lines, -1201 lines) Patch
M webrtc/audio/BUILD.gn View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M webrtc/audio/test/audio_bwe_integration_test.h View 1 2 2 chunks +6 lines, -2 lines 0 comments Download
M webrtc/audio/test/audio_bwe_integration_test.cc View 1 2 1 chunk +7 lines, -4 lines 0 comments Download
M webrtc/audio/test/low_bandwidth_audio_test.h View 1 2 1 chunk +5 lines, -2 lines 0 comments Download
M webrtc/audio/test/low_bandwidth_audio_test.cc View 1 2 1 chunk +5 lines, -3 lines 0 comments Download
M webrtc/call/bitrate_estimator_tests.cc View 2 chunks +98 lines, -80 lines 0 comments Download
M webrtc/call/call_perf_tests.cc View 1 2 4 chunks +149 lines, -124 lines 0 comments Download
M webrtc/call/rampup_tests.h View 1 2 1 chunk +3 lines, -1 line 0 comments Download
M webrtc/call/rampup_tests.cc View 1 2 1 chunk +4 lines, -2 lines 0 comments Download
M webrtc/test/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 2 chunks +16 lines, -0 lines 0 comments Download
M webrtc/test/call_test.h View 1 2 3 4 5 6 7 8 3 chunks +8 lines, -2 lines 0 comments Download
M webrtc/test/call_test.cc View 1 2 3 4 5 6 7 8 3 chunks +115 lines, -97 lines 0 comments Download
M webrtc/test/direct_transport.h View 1 2 3 4 5 6 7 8 9 4 chunks +43 lines, -19 lines 2 comments Download
M webrtc/test/direct_transport.cc View 1 2 3 4 5 6 7 8 9 4 chunks +56 lines, -24 lines 0 comments Download
M webrtc/test/layer_filtering_transport.h View 1 2 2 chunks +3 lines, -1 line 0 comments Download
M webrtc/test/layer_filtering_transport.cc View 1 2 2 chunks +2 lines, -1 line 0 comments Download
M webrtc/test/rtp_rtcp_observer.h View 1 2 2 chunks +7 lines, -2 lines 0 comments Download
A webrtc/test/single_threaded_task_queue.h View 1 2 3 4 5 6 7 8 1 chunk +97 lines, -0 lines 0 comments Download
A webrtc/test/single_threaded_task_queue.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +144 lines, -0 lines 0 comments Download
A webrtc/test/single_threaded_task_queue_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +364 lines, -0 lines 0 comments Download
M webrtc/video/end_to_end_tests.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 42 chunks +635 lines, -472 lines 0 comments Download
M webrtc/video/picture_id_tests.cc View 4 chunks +67 lines, -36 lines 0 comments Download
M webrtc/video/video_quality_test.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 7 chunks +239 lines, -202 lines 0 comments Download
M webrtc/video/video_send_stream_tests.cc View 1 2 3 4 24 chunks +206 lines, -127 lines 0 comments Download

Messages

Total messages: 59 (29 generated)
eladalon
This isn't 100% finished yet, but perhaps you could already take a look?
3 years, 4 months ago (2017-08-14 11:16:03 UTC) #2
stefan-webrtc
https://codereview.webrtc.org/2998923002/diff/1/webrtc/test/direct_transport.cc File webrtc/test/direct_transport.cc (right): https://codereview.webrtc.org/2998923002/diff/1/webrtc/test/direct_transport.cc#newcode116 webrtc/test/direct_transport.cc:116: SendPackets(); This will busy loop, won't it?
3 years, 4 months ago (2017-08-14 11:34:54 UTC) #5
nisse-webrtc
One alternative could be to extend MessageQueue (base class of rtc::Thread) with a method MessageQueue::PostTask(std::unique_ptr<QueuedTask> ...
3 years, 4 months ago (2017-08-14 12:04:52 UTC) #6
eladalon
Unit-tests added. They might be a bit more extensive than a unit intended for testing ...
3 years, 4 months ago (2017-08-14 15:38:00 UTC) #7
stefan-webrtc
https://codereview.webrtc.org/2998923002/diff/1/webrtc/test/direct_transport.cc File webrtc/test/direct_transport.cc (right): https://codereview.webrtc.org/2998923002/diff/1/webrtc/test/direct_transport.cc#newcode116 webrtc/test/direct_transport.cc:116: SendPackets(); On 2017/08/14 15:38:00, eladalon wrote: > On 2017/08/14 ...
3 years, 4 months ago (2017-08-14 16:30:22 UTC) #8
eladalon
https://codereview.webrtc.org/2998923002/diff/1/webrtc/test/direct_transport.cc File webrtc/test/direct_transport.cc (right): https://codereview.webrtc.org/2998923002/diff/1/webrtc/test/direct_transport.cc#newcode116 webrtc/test/direct_transport.cc:116: SendPackets(); On 2017/08/14 16:30:21, stefan-webrtc wrote: > On 2017/08/14 ...
3 years, 4 months ago (2017-08-14 17:08:26 UTC) #9
eladalon
https://codereview.webrtc.org/2998923002/diff/1/webrtc/test/direct_transport.cc File webrtc/test/direct_transport.cc (right): https://codereview.webrtc.org/2998923002/diff/1/webrtc/test/direct_transport.cc#newcode116 webrtc/test/direct_transport.cc:116: SendPackets(); On 2017/08/14 17:08:26, eladalon wrote: > On 2017/08/14 ...
3 years, 4 months ago (2017-08-14 17:17:54 UTC) #10
nisse-webrtc
On 2017/08/14 17:17:54, eladalon wrote: > 2. Introduce PostDelayedTask(). This is possible, but would increase ...
3 years, 4 months ago (2017-08-15 07:16:27 UTC) #11
eladalon
After we've run into a circular-dependency problem on sequence-checker when trying to use TaskQueue, we're ...
3 years, 4 months ago (2017-08-16 12:54:26 UTC) #12
stefan-webrtc
lgtm from me assuming comments during pair review yesterday are addressed.
3 years, 4 months ago (2017-08-18 10:57:32 UTC) #13
stefan-webrtc
Would probably be good with a bug to reference though.
3 years, 4 months ago (2017-08-18 10:57:51 UTC) #14
nisse-webrtc
I've looked through this, but it's not so easy to review, since there's so much ...
3 years, 4 months ago (2017-08-18 11:08:30 UTC) #15
eladalon
https://codereview.webrtc.org/2998923002/diff/120001/webrtc/call/call_perf_tests.cc File webrtc/call/call_perf_tests.cc (right): https://codereview.webrtc.org/2998923002/diff/120001/webrtc/call/call_perf_tests.cc#newcode171 webrtc/call/call_perf_tests.cc:171: task_queue_.SendTask([&]() { On 2017/08/18 11:08:29, nisse-webrtc wrote: > Check ...
3 years, 4 months ago (2017-08-18 12:12:38 UTC) #17
nisse-webrtc
lgtm, with some nits for comment and cl description. For review, I applied the patch ...
3 years, 4 months ago (2017-08-21 09:07:07 UTC) #20
eladalon
https://codereview.webrtc.org/2998923002/diff/140001/webrtc/call/bitrate_estimator_tests.cc File webrtc/call/bitrate_estimator_tests.cc (left): https://codereview.webrtc.org/2998923002/diff/140001/webrtc/call/bitrate_estimator_tests.cc#oldcode140 webrtc/call/bitrate_estimator_tests.cc:140: send_transport_->StopSending(); On 2017/08/21 09:07:07, nisse-webrtc wrote: > Why is ...
3 years, 4 months ago (2017-08-21 10:56:54 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2998923002/180001
3 years, 4 months ago (2017-08-21 15:00:28 UTC) #25
commit-bot: I haz the power
Try jobs failed on following builders: mac_baremetal on master.tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/mac_baremetal/builds/24110)
3 years, 4 months ago (2017-08-21 15:04:38 UTC) #27
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2998923002/200001
3 years, 4 months ago (2017-08-21 15:07:07 UTC) #30
commit-bot: I haz the power
Try jobs failed on following builders: linux_baremetal on master.tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/linux_baremetal/builds/23685)
3 years, 4 months ago (2017-08-21 15:31:58 UTC) #32
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2998923002/220001
3 years, 4 months ago (2017-08-21 16:06:47 UTC) #35
commit-bot: I haz the power
Try jobs failed on following builders: linux_baremetal on master.tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/linux_baremetal/builds/23687)
3 years, 4 months ago (2017-08-21 16:27:57 UTC) #37
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2998923002/240001
3 years, 4 months ago (2017-08-21 17:29:38 UTC) #40
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2998923002/260001
3 years, 4 months ago (2017-08-21 17:32:28 UTC) #43
commit-bot: I haz the power
Try jobs failed on following builders: linux_memcheck on master.tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/linux_memcheck/builds/10673)
3 years, 4 months ago (2017-08-21 17:46:38 UTC) #45
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2998923002/280001
3 years, 4 months ago (2017-08-22 09:56:09 UTC) #48
commit-bot: I haz the power
Try jobs failed on following builders: win_msvc_rel on master.tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/win_msvc_rel/builds/42)
3 years, 4 months ago (2017-08-22 10:20:39 UTC) #50
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2998923002/300001
3 years, 4 months ago (2017-08-22 10:32:58 UTC) #53
commit-bot: I haz the power
Committed patchset #16 (id:300001) as https://chromium.googlesource.com/external/webrtc/+/413ee9a010eca70712a6935c68b815201bee1270
3 years, 4 months ago (2017-08-22 11:03:00 UTC) #56
danilchap
https://codereview.webrtc.org/2998923002/diff/300001/webrtc/test/direct_transport.h File webrtc/test/direct_transport.h (right): https://codereview.webrtc.org/2998923002/diff/300001/webrtc/test/direct_transport.h#newcode105 webrtc/test/direct_transport.h:105: SingleThreadedTaskQueueForTesting::TaskId next_scheduled_task_; why this member is unguarded? access to ...
3 years, 4 months ago (2017-08-23 15:49:23 UTC) #58
eladalon
3 years, 4 months ago (2017-08-24 07:56:52 UTC) #59
Message was sent while issue was closed.
https://codereview.webrtc.org/2998923002/diff/300001/webrtc/test/direct_trans...
File webrtc/test/direct_transport.h (right):

https://codereview.webrtc.org/2998923002/diff/300001/webrtc/test/direct_trans...
webrtc/test/direct_transport.h:105: SingleThreadedTaskQueueForTesting::TaskId
next_scheduled_task_;
On 2017/08/23 15:49:23, danilchap wrote:
> why this member is unguarded? access to it seems racy:
> 1) it is accessed in constructor, but before it is assigned, there is a call
> PostTask on a different thread that also tries to assign same variable.
> 
> 2) it is used to cancel task (read) which seems expected to be done outside of
> the task queue thread, but task queue can write into it same time on different
> thread.

The *deprecated* version is racy, because it runs the ctor outside of the
task-queue.
The "approved" version isn't.
The solution is to migrate all projects away from the deprecated version, then
remove it.

Powered by Google App Engine
This is Rietveld 408576698