Closed Bug 913065 Opened 11 years ago Closed 11 years ago

setImmediate polyfill does not support web workers

Categories

(Firefox OS Graveyard :: Gaia, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bkelly, Assigned: bkelly)

Details

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

Attachments

(1 file)

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: nobody → bkelly
Status: NEW → ASSIGNED
Whiteboard: [c= p=2 u= s=]
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
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)
Whiteboard: [c= p=2 u= s=] → [c= p=2 u= s=2013.09.06]
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+
(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
Closed: 11 years ago
Resolution: --- → FIXED
Keywords: perf
Whiteboard: [c= p=2 u= s=2013.09.06] → [ c= p=2 u= s=2013.09.06 ]
Attachment #800234 - Flags: feedback?(21)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: