Bug 147992

Summary: WorkQueue::dispatchAfter() on Windows fires early
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: Web Template FrameworkAssignee: Mark Lam <mark.lam>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, benjamin, bfulgham, cmarcelo, commit-queue, ggaren
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
the fix.
none
the fix. none

Description Mark Lam 2015-08-13 14:08:27 PDT
The Windows implementation of WorkQueue::dispatchAfter() uses CreateTimerQueueTimer().  Unfortunately, CreateTimerQueueTimer() is sloppy and can fire early.  We need to compensate for this slop to ensure that the specified duration does expire before the callback function is called (or the JSC watchdog which depends on this can fail randomly).
Comment 1 Brent Fulgham 2015-08-13 14:15:24 PDT
It looks like the standard Windows timer ticks at ~64 ticks/second -> 15ms interval.

http://download.microsoft.com/download/3/0/2/3027D574-C433-412A-A8B65E0A75D5B237/Timer-Resolution.docx
See also https://msdn.microsoft.com/enus/library/system.timers.timer.interval(v=vs.110).aspx
Another one: <https://msdn.microsoft.com/enus/library/windows/hardware/dn265247(v=vs.85).aspx>, check the "Controlling timer accuracy" section's first paragraph.
Comment 2 Mark Lam 2015-08-13 14:16:37 PDT
Created attachment 258932 [details]
the fix.
Comment 3 Mark Lam 2015-08-13 14:18:29 PDT
Created attachment 258933 [details]
the fix.
Comment 4 Brent Fulgham 2015-08-13 14:24:43 PDT
Comment on attachment 258933 [details]
the fix.

r=me.
Comment 5 WebKit Commit Bot 2015-08-13 16:39:20 PDT
Comment on attachment 258933 [details]
the fix.

Clearing flags on attachment: 258933

Committed r188415: <http://trac.webkit.org/changeset/188415>
Comment 6 WebKit Commit Bot 2015-08-13 16:39:26 PDT
All reviewed patches have been landed.  Closing bug.