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

Issue 2491613004: Make base::Timer sequence-friendly. (Closed)

Created:
4 years, 1 month ago by gab
Modified:
3 years, 6 months ago
CC:
chirantan+watch_chromium.org, chromium-reviews, fdoray, jsbell, robliao
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Make base::Timer sequence-friendly. This CL was also going to fix a race condition in the existing implementation when SetTaskRunner() was used but the test-only failures caused by tests having long-lived with the status quo are proving hard than expected to fix. The race is no worse than before by making this code sequence-friendly (and generally healthier). Will fix race in a follow-up CL. Of note in this CL: - Patch set 1 is https://codereview.chromium.org/1433373003 so looking at diff from 1 might be less work (especially for tests). - (not true anymore, postponed to race fix CL:) The Timer's delayed task now always lives on the sequence it was started from (and even SetTaskRunner() was used, a task is posted to it when the delay expires instead of having the Timer's delayed task live on it -- this solves the aforementioned race condition). - This required adapting tests for MediaCodecLoop and UploadProgressTracker. BUG=587199, 552633, 678592, 684640, 675631 Review-Url: https://codereview.chromium.org/2491613004 Cr-Commit-Position: refs/heads/master@{#476317} Committed: https://chromium.googlesource.com/chromium/src/+/4e844bb5f686dbd3a062c6aaf83c8a1df171a08a

Patch Set 1 : https://codereview.chromium.org/1433373003 rebased on trunk #

Patch Set 2 : Modernize, make sequence-safe, keep old benefits, yay! #

Patch Set 3 : Fix TickClock support. #

Patch Set 4 : Rebase dependencies #

Patch Set 5 : fix TimerSequenceTest flakes #

Patch Set 6 : Extract test refactor to https://codereview.chromium.org/2514293004/ #

Patch Set 7 : rebase onto r434166 #

Patch Set 8 : rebase #

Total comments: 30

Patch Set 9 : rebase on r440436 #

Patch Set 10 : self-review + vpmstr review + adjustments for new GetTimeToCallback method #

Patch Set 11 : merge up to r442293 #

Total comments: 8

Patch Set 12 : nits:vmpstr#46 #

Patch Set 13 : Fix IWYU errors #

Patch Set 14 : New approach: everything on origin sequence, re-post to destination sequence if necessary after del… #

Patch Set 15 : rebase on r445386 #

Patch Set 16 : re-fix ~Timer to work on origin sequence if stopped #

Patch Set 17 : Remove need for SequenceCheckerImpl in ~Timer() with cleaner Stop() #

Patch Set 18 : fix ~Timer() further #

Patch Set 19 : fix typo #

Patch Set 20 : Don't bind sequence in SetTaskRunner() #

Patch Set 21 : Update Timer usage for MediaCodecLoop and UpdateProgressTracker's tests (+fix IWYU) #

Patch Set 22 : rebase on dependency #

Total comments: 9

Patch Set 23 : merge up to r450035 and non-virtual Timer::SetTaskRunner() #

Patch Set 24 : review dalecurtis#90/vmpstr#91 #

Patch Set 25 : rebase on r453103 and issue 2657013002 #

Patch Set 26 : rebase on r456293 #

Patch Set 27 : rebase on r458055 #

Patch Set 28 : fix dependency #

Patch Set 29 : fix ServiceWorkerVersionBrowserTests (and rebase on r462998) #

Patch Set 30 : rebase on r464476 #

Total comments: 18

Patch Set 31 : rebase on r474679 #

Patch Set 32 : review:horo/fdoray #

Patch Set 33 : reintroduce pre-existing race to land core of this CL which doesn't worsen the situation #

Patch Set 34 : disable many new sequence checks per the pre-existing race triggering them... #

Patch Set 35 : fix TSAN suppressions #

Patch Set 36 : fix ServiceWorkerJobTest.ActivateCancelsOnShutdown #

Patch Set 37 : revert changes to Stop/Abandon behaviour for now #

Patch Set 38 : add back commented out DCHECK in Stop() #

Unified diffs Side-by-side diffs Delta from patch set Stats (+434 lines, -167 lines) Patch
M base/timer/timer.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 7 chunks +54 lines, -49 lines 0 comments Download
M base/timer/timer.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 9 chunks +78 lines, -52 lines 0 comments Download
M base/timer/timer_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 25 26 27 28 4 chunks +208 lines, -6 lines 0 comments Download
M build/sanitizers/tsan_suppressions.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/loader/upload_progress_tracker.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2 chunks +6 lines, -8 lines 0 comments Download
M content/browser/loader/upload_progress_tracker.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +6 lines, -1 line 0 comments Download
M content/browser/loader/upload_progress_tracker_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 20 chunks +45 lines, -22 lines 0 comments Download
M content/browser/service_worker/service_worker_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 3 chunks +1 line, -2 lines 0 comments Download
M content/browser/service_worker/service_worker_job_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 1 chunk +1 line, -1 line 0 comments Download
M media/base/android/media_codec_loop.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 3 chunks +8 lines, -10 lines 0 comments Download
M media/base/android/media_codec_loop.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 chunk +3 lines, -3 lines 0 comments Download
M media/base/android/media_codec_loop_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 6 chunks +21 lines, -12 lines 0 comments Download
M media/filters/android/media_codec_audio_decoder.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 chunk +2 lines, -1 line 0 comments Download

Dependent Patchsets:

Messages

Total messages: 192 (152 generated)
gab
Dana PTAL (bots are red because I need to rebase on https://codereview.chromium.org/2484023002 -- and sadly ...
4 years, 1 month ago (2016-11-15 17:53:34 UTC) #11
danakj
To be sure.. if u revert all changes to the unit tests, they all pass? ...
4 years, 1 month ago (2016-11-21 23:49:52 UTC) #22
danakj
Why isn't the stuff in sequenced_worker_pool.cc a separate CL? It seems pretty nice on its ...
4 years, 1 month ago (2016-11-22 00:09:12 UTC) #23
gab
> To be sure.. if u revert all changes to the unit tests, they all ...
4 years, 1 month ago (2016-11-22 21:05:24 UTC) #26
vmpstr
https://codereview.chromium.org/2491613004/diff/160001/base/threading/sequenced_worker_pool.cc File base/threading/sequenced_worker_pool.cc (right): https://codereview.chromium.org/2491613004/diff/160001/base/threading/sequenced_worker_pool.cc#newcode387 base/threading/sequenced_worker_pool.cc:387: void DeleteTheseOutsideLockHelper( WDYT about just "DeleteWithoutLock" with "tasks_to_delete" as ...
4 years ago (2016-12-03 01:14:04 UTC) #33
gab
Finally got around to this :) -- still need to cleanup unused Timer members and ...
3 years, 12 months ago (2016-12-23 20:22:12 UTC) #39
gab
@vmpstr PTAnL, thanks!
3 years, 11 months ago (2017-01-06 16:28:39 UTC) #43
vmpstr
looks good, just small nits https://codereview.chromium.org/2491613004/diff/240001/base/timer/timer.cc File base/timer/timer.cc (right): https://codereview.chromium.org/2491613004/diff/240001/base/timer/timer.cc#newcode300 base/timer/timer.cc:300: if (is_running_) { I ...
3 years, 11 months ago (2017-01-12 20:04:22 UTC) #46
gab
@vmpstr: assumptions baked in around the codebase made it hard to fix some tests with ...
3 years, 11 months ago (2017-01-25 20:14:56 UTC) #88
Charlie Harrison
c/b/l lgtm
3 years, 11 months ago (2017-01-25 20:28:25 UTC) #89
DaleCurtis
media/ lgtm https://codereview.chromium.org/2491613004/diff/470001/media/base/android/media_codec_loop.h File media/base/android/media_codec_loop.h (right): https://codereview.chromium.org/2491613004/diff/470001/media/base/android/media_codec_loop.h#newcode205 media/base/android/media_codec_loop.h:205: scoped_refptr<base::SingleThreadTaskRunner> = nullptr); Is the = nullptr ...
3 years, 11 months ago (2017-01-25 22:33:25 UTC) #90
vmpstr
lgtm https://codereview.chromium.org/2491613004/diff/470001/base/timer/timer.cc File base/timer/timer.cc (right): https://codereview.chromium.org/2491613004/diff/470001/base/timer/timer.cc#newcode43 base/timer/timer.cc:43: // *this will be deleted by the task ...
3 years, 10 months ago (2017-02-01 21:13:11 UTC) #91
gab
Applied comments (sorry for delay, still fighting with tests not happy with the switch to ...
3 years, 10 months ago (2017-02-13 19:57:00 UTC) #105
DaleCurtis
https://codereview.chromium.org/2491613004/diff/470001/media/base/android/media_codec_loop_unittest.cc File media/base/android/media_codec_loop_unittest.cc (right): https://codereview.chromium.org/2491613004/diff/470001/media/base/android/media_codec_loop_unittest.cc#newcode189 media/base/android/media_codec_loop_unittest.cc:189: new base::TestMockTimeTaskRunner; On 2017/02/13 at 19:57:00, gab wrote: > ...
3 years, 10 months ago (2017-02-13 21:03:23 UTC) #108
danakj
On Mon, Feb 13, 2017 at 4:03 PM, <dalecurtis@chromium.org> wrote: > > https://codereview.chromium.org/2491613004/diff/470001/ > media/base/android/media_codec_loop_unittest.cc ...
3 years, 10 months ago (2017-02-13 21:46:46 UTC) #109
gab
Finally managed to land https://codereview.chromium.org/2657013002/ which is supposed unblock the last failures here *crossing-fingers*! Taking ...
3 years, 9 months ago (2017-03-02 01:22:44 UTC) #114
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2491613004/550001
3 years, 9 months ago (2017-03-02 01:23:35 UTC) #117
commit-bot: I haz the power
Try jobs failed on following builders: cast_shell_linux on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linux/builds/319449)
3 years, 9 months ago (2017-03-02 02:26:18 UTC) #119
gab
Still working on a few more tests but in the meantime +horo for content/browser/service_worker/service_worker_browsertest.cc Thanks, ...
3 years, 8 months ago (2017-04-26 16:48:00 UTC) #142
horo
https://codereview.chromium.org/2491613004/diff/650001/content/browser/service_worker/service_worker_browsertest.cc File content/browser/service_worker/service_worker_browsertest.cc (right): https://codereview.chromium.org/2491613004/diff/650001/content/browser/service_worker/service_worker_browsertest.cc#newcode1174 content/browser/service_worker/service_worker_browsertest.cc:1174: RunOnIOThreadWithDelay( Keep this as is, and call "version_->timeout_timer_.IsRunning()" in ...
3 years, 8 months ago (2017-04-27 02:33:12 UTC) #143
gab
https://codereview.chromium.org/2491613004/diff/650001/content/browser/service_worker/service_worker_browsertest.cc File content/browser/service_worker/service_worker_browsertest.cc (right): https://codereview.chromium.org/2491613004/diff/650001/content/browser/service_worker/service_worker_browsertest.cc#newcode1174 content/browser/service_worker/service_worker_browsertest.cc:1174: RunOnIOThreadWithDelay( On 2017/04/27 02:33:12, horo wrote: > Keep this ...
3 years, 7 months ago (2017-04-27 14:56:04 UTC) #144
horo
https://codereview.chromium.org/2491613004/diff/650001/content/browser/service_worker/service_worker_browsertest.cc File content/browser/service_worker/service_worker_browsertest.cc (right): https://codereview.chromium.org/2491613004/diff/650001/content/browser/service_worker/service_worker_browsertest.cc#newcode666 content/browser/service_worker/service_worker_browsertest.cc:666: version_->SimulatePingTimeoutForTesting(); Add EXPECT_TRUE(version_->timeout_timer_.IsRunning()); https://codereview.chromium.org/2491613004/diff/650001/content/browser/service_worker/service_worker_browsertest.cc#newcode1174 content/browser/service_worker/service_worker_browsertest.cc:1174: RunOnIOThreadWithDelay( On 2017/04/27 14:56:04, ...
3 years, 7 months ago (2017-04-27 15:49:53 UTC) #145
fdoray
https://codereview.chromium.org/2491613004/diff/650001/base/timer/timer.cc File base/timer/timer.cc (right): https://codereview.chromium.org/2491613004/diff/650001/base/timer/timer.cc#newcode126 base/timer/timer.cc:126: // Do not allow changing the task runner once ...
3 years, 7 months ago (2017-05-10 14:22:58 UTC) #147
gab
Finally looping back to this! Can't land it as-is yet though as I still lack ...
3 years, 7 months ago (2017-05-26 04:26:58 UTC) #148
gab
Decided to re-use this CL as most of it is still good. Merely need to ...
3 years, 7 months ago (2017-05-26 05:10:00 UTC) #152
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2491613004/730001
3 years, 7 months ago (2017-05-26 05:11:10 UTC) #156
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2491613004/730002
3 years, 7 months ago (2017-05-26 05:20:05 UTC) #160
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_ozone_rel_ng/builds/393811)
3 years, 7 months ago (2017-05-26 06:07:56 UTC) #162
horo
lgtm
3 years, 6 months ago (2017-05-29 10:38:33 UTC) #167
gab
I'm also opting to revert changes to Stop/Abandon for now. After re-reading this change yet ...
3 years, 6 months ago (2017-05-31 20:23:37 UTC) #172
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2491613004/820001
3 years, 6 months ago (2017-05-31 20:25:15 UTC) #176
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2491613004/840001
3 years, 6 months ago (2017-05-31 20:30:47 UTC) #180
commit-bot: I haz the power
Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_android_rel_ng/builds/307463)
3 years, 6 months ago (2017-05-31 22:24:29 UTC) #182
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2491613004/840001
3 years, 6 months ago (2017-06-01 14:00:12 UTC) #184
commit-bot: I haz the power
Committed patchset #38 (id:840001) as https://chromium.googlesource.com/chromium/src/+/4e844bb5f686dbd3a062c6aaf83c8a1df171a08a
3 years, 6 months ago (2017-06-01 16:23:55 UTC) #187
findit-for-me
Findit (https://goo.gl/kROfz5) identified this CL at revision 476317 as the culprit for failures in the ...
3 years, 6 months ago (2017-06-01 17:33:39 UTC) #188
gab
On 2017/06/01 17:33:39, findit-for-me wrote: > Findit (https://goo.gl/kROfz5) identified this CL at revision 476317 as ...
3 years, 6 months ago (2017-06-01 17:58:12 UTC) #189
gab
On 2017/06/01 17:58:12, gab wrote: > On 2017/06/01 17:33:39, findit-for-me wrote: > > Findit (https://goo.gl/kROfz5) ...
3 years, 6 months ago (2017-06-01 18:09:06 UTC) #190
gab
On 2017/06/01 18:09:06, gab wrote: > On 2017/06/01 17:58:12, gab wrote: > > On 2017/06/01 ...
3 years, 6 months ago (2017-06-01 18:11:29 UTC) #191
gab
3 years, 6 months ago (2017-06-01 18:11:33 UTC) #192
Message was sent while issue was closed.
On 2017/06/01 18:09:06, gab wrote:
> On 2017/06/01 17:58:12, gab wrote:
> > On 2017/06/01 17:33:39, findit-for-me wrote:
> > > Findit (https://goo.gl/kROfz5) identified this CL at revision 476317 as
the
> > > culprit for
> > > failures in the build cycles as shown on:
> > >
> >
>
https://findit-for-me.appspot.com/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3Itb...
> > 
> > This seems very unlikely to me... looking...
> 
> Ah, this CL indeed made TSAN tests fail
> (TimerSequenceTest.OneShotTimerUsedAndTaskedOnDifferentPools), but the linked
> failed build also had an unrelated content_browsertest failure which I thought
> was initially what was being blamed.
> 
> This is just a missing TSAN suppression in this CL (same reason I added the
> other ones -- the pre-existing race wasn't fixed, the new tests highlight
> it...).

I'm landing the fix right now, no need to revert this.

Powered by Google App Engine
This is Rietveld 408576698