setImmediate polyfill does not support web workers

RESOLVED FIXED

Status

Firefox OS
Gaia
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: bkelly, Assigned: bkelly)

Tracking

({perf})

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [ c= p=2 u= s=2013.09.06 ])

Attachments

(1 attachment)

(Assignee)

Description

5 years ago
I just realized that the setImmediate polyfill I landed in bug 910876 will not function properly in workers.  When I customized the NobleJS code I removed the MessageChannel implementation which was designed to handle this case.  I apologize for being a bit overly aggressive in stripping things out here.

If we feel we need this in web workers I can add the MessageChannel implementation back in.

I know David mentioned he might have a use for setImmediate in workers, so CC'ing him here.
(Assignee)

Updated

5 years ago
Assignee: nobody → bkelly
Status: NEW → ASSIGNED
Whiteboard: [c= p=2 u= s=]
(Assignee)

Comment 1

5 years ago
Unfortunately MessageChannel is not available for web workers in Gecko yet.  See bug 911972.

We should definitely patch something here, though, so the broken postMessage() is not used in the worker.  I'll work a patch to provide setTimeout(0) fallback implementation.
Depends on: 911972
(Assignee)

Comment 2

5 years ago
Created attachment 800234 [details]
Pull request at https://github.com/mozilla-b2g/gaia/pull/11960

This patch provides a fallback implementation of setImmediate() using setTimeout(0).  I will write a separate bug to provide the MessageChannel implementation dependent on bug 911972 landing.

This patch also adds a worker unit test.

Sorry again for missing this case in the original commit.
Attachment #800234 - Flags: review?(timdream)
Attachment #800234 - Flags: feedback?(21)
(Assignee)

Updated

5 years ago
Whiteboard: [c= p=2 u= s=] → [c= p=2 u= s=2013.09.06]
(Assignee)

Comment 3

5 years ago
I wrote bug 913148 to track implementing the MessageChannel polyfill once it is available on gecko.
No longer depends on: 911972
Comment on attachment 800234 [details]
Pull request at https://github.com/mozilla-b2g/gaia/pull/11960

Don't over-doing it! It's just a shim :)
Attachment #800234 - Flags: review?(timdream) → review+
(Assignee)

Comment 5

5 years ago
(In reply to Tim Guan-tin Chien [:timdream] (MoCo-TPE) from comment #4)
> Don't over-doing it! It's just a shim :)

I'll try not to.  :-)  I just wanted to make sure it at least didn't break in workers since djf mentioned on irc it would be useful there.

Merged:

 https://github.com/mozilla-b2g/gaia/commit/f0514bb29c7da935a3e5af84cc526d18e93c0b45
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
(Assignee)

Updated

5 years ago
Keywords: perf
Whiteboard: [c= p=2 u= s=2013.09.06] → [ c= p=2 u= s=2013.09.06 ]
(Assignee)

Updated

5 years ago
Attachment #800234 - Flags: feedback?(21)
You need to log in before you can comment on or make changes to this bug.