setInterval(,0) only fires once in worker

RESOLVED FIXED in Firefox 35

Status

()

Core
DOM: Workers
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: bkelly, Assigned: baku)

Tracking

unspecified
mozilla37
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox34 wontfix, firefox35+ fixed, firefox36+ fixed, firefox37 fixed)

Details

Attachments

(1 attachment)

(Reporter)

Description

3 years ago
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.
(Reporter)

Comment 2

3 years ago
Interesting that it doesn't latch at a minimum value.  I thought that was how main thread setInterval() worked.
(Reporter)

Updated

3 years ago
Summary: setInterval() only fires once in worker → setInterval(,0) only fires once in worker
(Assignee)

Comment 3

3 years ago
Also 1ms works. It seems that the issue is just with 0.
(Assignee)

Comment 4

3 years ago
Created attachment 8531639 [details] [diff] [review]
interval.patch
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)

Comment 6

3 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/731184e5ebbd
(Assignee)

Updated

3 years ago
Assignee: nobody → amarchesini
https://hg.mozilla.org/mozilla-central/rev/731184e5ebbd
Status: NEW → RESOLVED
Last Resolved: 3 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.
status-firefox34: --- → affected
status-firefox35: --- → affected
status-firefox36: --- → affected
tracking-firefox36: --- → ?
tracking-firefox35: --- → ?
Andrea, could you request an uplift to aurora & beta?
status-firefox34: affected → wontfix
status-firefox37: --- → affected
tracking-firefox35: ? → +
tracking-firefox36: ? → +
Flags: needinfo?(amarchesini)
(Assignee)

Comment 10

3 years ago
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?
status-firefox37: affected → fixed
Attachment #8531639 - Flags: approval-mozilla-beta?
Attachment #8531639 - Flags: approval-mozilla-beta+
Attachment #8531639 - Flags: approval-mozilla-aurora?
Attachment #8531639 - Flags: approval-mozilla-aurora+
https://hg.mozilla.org/releases/mozilla-aurora/rev/84e8d92b74c7
https://hg.mozilla.org/releases/mozilla-beta/rev/084a4d8ad42b
status-firefox35: affected → fixed
status-firefox36: affected → fixed
Flags: in-testsuite+
Depends on: 1111669
You need to log in before you can comment on or make changes to this bug.