New issue
Advanced search Search tips

Issue 854180 link

Starred by 4 users

Issue metadata

Status: WontFix
Owner:
Closed: Aug 2
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

setTimeout sometimes fires sooner than specified

Project Member Reported by jakearchibald@chromium.org, Jun 19 2018

Issue description

https://static-misc.glitch.me/set-timeout-delay

This is a setTimeout 'loop' with a delay of 10ms. However, you pretty get a callback happening less than 10ms from when it was scheduled. Is this expected behaviour?

This also happens in Edge & Firefox, but not Safari.
 

Comment 1 by t...@tws.name, Jun 19 2018

When I first posted[1] this question on Twitter, it was suggested that the issue might be due to timer fuzzing[2] done to guard against Spectre. That does sound plausible.

[1] https://twitter.com/wa7son/status/1009048999972818944
[2] https://www.mozilla.org/en-US/security/advisories/mfsa2018-01/
Owner: skyos...@chromium.org
Status: Assigned (was: Untriaged)
We suspect that it is indeed due to timer fuzzing. We'll check to make sure.
Cc: wanderview@chromium.org
Status: WontFix (was: Assigned)
Did a quick test, and indeed disabling the time clamper[1][2] makes the problem go away. What's happening is the individual callbacks run at randomly jittered times, which may make the measured delay between two consecutive runs less than 10ms. I think we want to maintain this behavior for now for the reason mentioned.

[1] https://cs.chromium.org/chromium/src/gin/v8_platform.cc?l=115&gs=kythe%253A%252F%252Fchromium%253Flang%253Dc%25252B%25252B%253Fpath%253Dsrc%252Fgin%252Fv8_platform.cc%253Froot%253Dchromium-android%2523M6CsQ058%25252Faxd0FtprCTRWsoiRmVbBRRivqcxwPq7uI4%25253D&gsn=TimeClamper&ct=xref_usages

[2] https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/time_clamper.cc?q=timeclamper&sq=package:chromium&dr=CSs&l=15

Sign in to add a comment