New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 747737 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jul 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Fuchsia
Pri: 1
Type: Bug

Blocking:
issue 738275



Sign in to add a comment

MessageLoopTestTypeIO.PostDelayedTask_Basic has started flaking again

Project Member Reported by w...@chromium.org, Jul 23 2017

Issue description

Even with the changes landed to use TimeTicks (monotonic) instead of Time (wall-clock) to determine when PostDelayedTask is processed, the test is observing the delayed task being executed early.

It's possible when running in a VM for the guest OS to be starved of cycles (e.g. if the VM is using guest CPU cores to emulate devices), which can result in clock interrupts being missed; however, I'd expect that to impact both the reported time, and the timing of the delayed task.  It seems more likely that there is some issue with Fuchsia clock/wake granularity, or with rounding errors between Chromium time and Fuchsia time.
 

Comment 1 by w...@chromium.org, Jul 23 2017

Blocking: 738275
Owner: scottmg@chromium.org
Status: Started (was: Untriaged)
I think this is a test bug, or a misunderstanding at least, perhaps during a test runner refactor.

The test code currently posts the task, then gets the start time.

But during post, the message loop calculates the absolute time for wakeup by doing TimeTicks::Now() + delay.

Then, the .Run() is called in the test code, then the end time is gathered.

Moving the start time get to before the PostDelayedTask() would be correct in the test, or otherwise, the calculation of when to wake up in the post needs to be deferred to after the loop starts.
More concretely, I believe this ought to pass if the test code was correct, but it always fails.

sgraham@river:/work/cr/src$ git diff
diff --git a/base/message_loop/message_loop_test.cc b/base/message_loop/message_loop_test.cc
index 9ed2434..f66de94 100644
--- a/base/message_loop/message_loop_test.cc
+++ b/base/message_loop/message_loop_test.cc
@@ -136,6 +136,8 @@ void RunTest_PostDelayedTask_Basic(MessagePumpFactory factory) {
   loop.task_runner()->PostDelayedTask(
       FROM_HERE, BindOnce(&RecordRunTimeFunc, &run_time, &num_tasks), kDelay);
 
+  sleep(1);
+
   TimeTicks time_before_run = TimeTicks::Now();
   RunLoop().Run();
   TimeTicks time_after_run = TimeTicks::Now();

Comment 4 by w...@chromium.org, Jul 24 2017

Re #3: Yes, I think you are exactly right. Well spotted. :)
Project Member

Comment 5 by bugdroid1@chromium.org, Jul 25 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/241c1dc966603c7a2db0cc4644e0488f6d606517

commit 241c1dc966603c7a2db0cc4644e0488f6d606517
Author: Scott Graham <scottmg@chromium.org>
Date: Tue Jul 25 03:42:32 2017

Fix PostDelayedTask test timing check

The test code is assuming that the delay is relative to the beginning of
the message loop Run(), but it's actually relative to when the task is
posted per the call to CalculateDelayedRuntime() in
AddToIncomingQueue().

This was exposed on Fuchsia when running on a slow QEMU, but in theory
is all-platforms.

Ref:
https://cs.chromium.org/chromium/src/base/message_loop/incoming_task_queue.cc?rcl=d5968b33fed15b4364fdb44acfa491bbc65ad035&l=75

Bug:  747737 ,  738001 , 738275
Change-Id: If98e0ef3e81777f678f543474194e1fa2f667e2c
Reviewed-on: https://chromium-review.googlesource.com/584029
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Wez <wez@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#489216}
[modify] https://crrev.com/241c1dc966603c7a2db0cc4644e0488f6d606517/base/message_loop/message_loop_test.cc

Comment 6 by w...@chromium.org, Jul 25 2017

Status: Fixed (was: Started)

Sign in to add a comment