Closed Bug 1104064 Opened 9 years ago Closed 9 years ago

setInterval(,0) only fires once in worker

Categories

(Core :: DOM: Workers, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla37
Tracking Status
firefox34 --- wontfix
firefox35 + fixed
firefox36 + fixed
firefox37 --- fixed

People

(Reporter: bkelly, Assigned: baku)

References

Details

Attachments

(1 file)

Open the web console and run the following:

  var workerScript = 'data:text/javascript, setInterval(function() { console.log(Math.random()); }, 0)';
  var worker = new Worker(workerScript);

You will only see a single log statement.  This should repeatedly log.

In contrast, this works:

  var workerScript = 'data:text/javascript, function f() { console.log(Math.random()); setTimeout(f, 0); } f();';
  var worker = new Worker(workerScript);
I suspect this is limited to setInterval(,0).  10ms seems to work.
Interesting that it doesn't latch at a minimum value.  I thought that was how main thread setInterval() worked.
Summary: setInterval() only fires once in worker → setInterval(,0) only fires once in worker
Also 1ms works. It seems that the issue is just with 0.
Attached patch interval.patchSplinter Review
Attachment #8531639 - Flags: review?(khuey)
Comment on attachment 8531639 [details] [diff] [review]
interval.patch

Review of attachment 8531639 [details] [diff] [review]:
-----------------------------------------------------------------

Haha.

This needs a test.
Attachment #8531639 - Flags: review?(khuey) → review+
Assignee: nobody → amarchesini
https://hg.mozilla.org/mozilla-central/rev/731184e5ebbd
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
[Tracking Requested - why for this release]: This is a nasty bug that slipped in some time ago, and the fix is trivial. Let's backport please.
Andrea, could you request an uplift to aurora & beta?
Flags: needinfo?(amarchesini)
Comment on attachment 8531639 [details] [diff] [review]
interval.patch

Approval Request Comment
[Feature/regressing bug #]: bug 928312
[User impact if declined]: setInterval can be broken if used with timer 0
[Describe test coverage new/current, TBPL]: tbpl
[Risks and why]: none
[String/UUID change made/needed]: none
Flags: needinfo?(amarchesini)
Attachment #8531639 - Flags: approval-mozilla-beta?
Attachment #8531639 - Flags: approval-mozilla-aurora?
Attachment #8531639 - Flags: approval-mozilla-beta?
Attachment #8531639 - Flags: approval-mozilla-beta+
Attachment #8531639 - Flags: approval-mozilla-aurora?
Attachment #8531639 - Flags: approval-mozilla-aurora+
Depends on: 1111669
You need to log in before you can comment on or make changes to this bug.