News for hackers. Stuff that matters.
Re:Firefox 29 by angersock on Tuesday April 29, 2014 @01:07PM (#7668360)
"Added the console API to Web Workers (bug 620935). Now you can log messages to the Web Console from Web Workers."

About bloody time. Does anyone know why that wasn't the case from the get-go?

Re:Firefox 29 by asutherland on Tuesday April 29, 2014 @03:50PM (#7669544)
Originally, exposure of APIs to JS was done using the XPConnect JS/XPCOM bridge in Firefox. Simplifying a little, XPConnect is not thread-safe, so exposing APIs to workers required manually writing code using the SpiderMonkey JS API. This was done in an ad-hoc fashion for a while. Additionally, XPConnect allowed JS code to be written to expose functionality to content on the main thread, but was basically a non-starter on the worker thread because of the lack of XPConnect. (Simplifying slightly again, XPConnect also provided required security protections.)

Between having to write thread-safe code and custom JS exposure, the overhead could be significant. This has now been greatly improved through the use of automatically generated WebIDL bindings, although C++ is still used and threading issues do have to be dealt with (usually by remoting a runnable to the main thread), so worker versions of an API still aren't free.

New Web APIs implemented by the platform team should usually be designed from the ground-up for worker exposure and have worker support land soon-after or at the same time as the main-thread support. Experimental APIs related to Firefox OS and developed by Firefox OS Gaia teams are more likely to be prototypes implemented in JS for rapid prototyping and will need another rev before they can be exposed to workers. This last bit frequently happens as part of an effort to standardize the API informed by the prototype.

Links for context: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/... https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bind...

Re:Firefox 29 by angersock on Tuesday April 29, 2014 @04:25PM (#7669743)
Thank you very much for your explanation!

We ended up writing a goofy little console.log() replacement that sent messages back to the main UI thread for processing and logging, but that kind of thunking is a might-bit janky.

Re:Firefox 29 by bzbarsky on Wednesday April 30, 2014 @01:08AM (#7671721)
The console.log exposed to workers just sends the messages to the UI thread for logging...
Re:Firefox 29 by angersock on Wednesday April 30, 2014 @02:09AM (#7671861)
I forget whether the workaround was done for Firefox or Chrome...I remember hitting it in one or the other, and putting in the workaround for both.

On a related note, transferable objects are handled a bit differently between IE, FF, and Chrome. Some are a bit stricter than others.

Re:Firefox 29 by bzbarsky on Friday May 02, 2014 @02:26AM (#7684346)
That's not surprising, but annoying. Please do file bugs as needed; the spec is generally pretty clear about how things should work here, so if browsers don't agree one of them is just buggy.
Re:Firefox 29 by ecnahc515 on Tuesday April 29, 2014 @01:32PM (#7668589)
Cause printing functions usually aren't thread safe I'd assume it has to be a similar reason.
Re:Firefox 29 by Excavator on Tuesday April 29, 2014 @04:36PM (#7669800)
According to comments in that bug it looks like it were held up due to discussion around standardization of the Console API and a rewrite of the same.

https://bugzilla.mozilla.org/show_bug.cgi?id=620935#c30

Re:Firefox 29 by dubcanada on Tuesday April 29, 2014 @04:48PM (#7669874)
The Console API is getting rewritten to handle proper console.logging with colours, grouping etc.