The default bug view has changed. See this FAQ.

Some timers in worker never fired

RESOLVED FIXED in mozilla17

Status

()

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

People

(Reporter: Rex, Assigned: khuey)

Tracking

({testcase})

Trunk
mozilla17
x86
Linux
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 3 obsolete attachments)

(Reporter)

Description

5 years ago
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0
Build ID: 20120423122624

Steps to reproduce:

Ubuntu 12.04
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0
browser.startup.homepage_override.buildID=20120423122624

MainUI.html
==============================
<html>
<head>
<script type="text/javascript">
    function AreaController(areaId) {
        var area = null;
        this.append = function(line) {
            if (area == null) {
                area = document.getElementById(areaId);
            }
            area.value += (line + "\n");
        };
        this.clear = function() {
            area.value = "";
        };
    }

    leftArea = new AreaController("leftText");

    worker = new Worker("WebWorker.js");
    worker.onmessage = function(event) {
        leftArea.append(event.data);
    }
</script>
</head>
<body>
	<textarea id="leftText" rows="30" cols="50" readonly="readonly"></textarea>
	<br />
	<input type="button" value="Clear" onClick="leftArea.clear()">
</body>
</html>


WebWorker.js
==============================
function sendLater(msg) {
    postMessage("");
    postMessage("Scheduling:" + new Date().getTime());

    setTimeout(function() {
        postMessage("Firing    :" + new Date().getTime());
        postMessage(msg);
    }, 1);

    postMessage("Scheduled :" + new Date().getTime());
}

setInterval(function() {
    sendLater("Interval  :" + new Date().getTime());
}, 3000);



Actual results:

In the test case worker will fire a repeat timer every 3 seconds. It sends a message back to main UI by scheduling and using another quick timer (1ms). Some 1ms timer would never fire.

I see output on main UI below. A 4 line block is a good case. A 2 line block means the 1ms has never fired. These results will appear in the first couple of minutes.

==============================
Scheduling:1337840998402
Scheduled :1337840998402
Firing    :1337840998403
Interval  :1337840998402

Scheduling:1337841001401
Scheduled :1337841001401
Firing    :1337841001402
Interval  :1337841001401

Scheduling:1337841004398
Scheduled :1337841004398

Scheduling:1337841007401
Scheduled :1337841007401
Firing    :1337841007402
Interval  :1337841007401

Scheduling:1337841010401
Scheduled :1337841010401
Firing    :1337841010403
Interval  :1337841010401

Scheduling:1337841013397
Scheduled :1337841013397

Scheduling:1337841016400
Scheduled :1337841016400

Scheduling:1337841019402
Scheduled :1337841019402
Firing    :1337841019403
Interval  :1337841019402



Expected results:

If every timer scheduled fires correctly, we should see all 4 line blocks.
(Reporter)

Comment 1

5 years ago
Verified that it is still happening in version 13.0.1.

Version info: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0.1

Comment 2

5 years ago
Verified that it still happening in 14.0.1 on Ubuntu 12.04.
I had similar code that was using small timeout values, between 3-7 ms.
I tested it with several values and it seems the smaller the timeout value the more likely it will NOT be fired.

Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1

Comment 3

5 years ago
Created attachment 646601 [details]
test case: worker

Comment 4

5 years ago
Created attachment 646603 [details]
test case (use this)

Comment 5

5 years ago
Created attachment 646604 [details]
test case (use this)
Attachment #646603 - Attachment is obsolete: true

Updated

5 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase

Comment 6

5 years ago
I've prepared another test html+js to demonstrate this bug: https://gist.github.com/3192915

You can observe that in FF v12-14 setInterval() works fine (proving that worker hasn't died and is still running) but setTimeout() stops triggering after a few iterations.
We got this in a debugger and figured it out.
Assignee: nobody → khuey
Version: 12 Branch → Trunk
Created attachment 650204 [details] [diff] [review]
Patch
Attachment #646601 - Attachment is obsolete: true
Attachment #646604 - Attachment is obsolete: true
Attachment #650204 - Flags: review?(bent.mozilla)
Attachment #650204 - Flags: review?(bent.mozilla) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/7266ce1abf6b
https://hg.mozilla.org/mozilla-central/rev/7266ce1abf6b
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.