console.log is asynchronous

RESOLVED DUPLICATE of bug 754861

Status

()

Firefox
Developer Tools: Console
RESOLVED DUPLICATE of bug 754861
3 years ago
3 years ago

People

(Reporter: \, Unassigned)

Tracking

30 Branch
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

So if I have a block of code like:

```javascript
var worker = new Worker('whatever.js');
var xhr = new XMLHttpRequest;
xhr.open('GET', 'whatever.txt');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
  console.log(xhr.response);
  worker.postMessage(xhr.response, [xhr.response]);
  console.log(xhr.response);
};
xhr.send();
```

I would expect the first logged ArrayBuffer to have a byteLength of whatever.txt, and the second logged Array buffer to have a byteLength property of 0.  Instead both are 0.  How is it zero before I invoke postMessage?
console.log works asynchronously.  You can see this trivially with a testcase like this:

  var obj = { a: 5 };
  console.log(obj);
  obj.a = 6;
Component: JavaScript Engine → Developer Tools: Console
Product: Core → Firefox
Also, note that the behavior was added pretty purposefully.
Summary: Transferrable Objects cleared too soon? → console.log is asynchronous
(In reply to Boris Zbarsky [:bz] from comment #2)
> Also, note that the behavior was added pretty purposefully.

So is this bug a non issue?
I would say it's a known issue (bug 754861). Fixing this would likely make games and other apps that use console.log in a tight loop appear very slow in Firefox. I don't have enough data to have an informed opinion on which is more important. I'll see if our product folks do.
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 754861
Couldn't we take the performance hit only when the developer tools are being used?
You need to log in before you can comment on or make changes to this bug.