Closed
Bug 1050104
Opened 10 years ago
Closed 10 years ago
It is not possible to override console.log (or set any expandos on console) in a worker because self.console returns a new object each time
Categories
(Core :: DOM: Workers, defect)
Tracking
()
RESOLVED
FIXED
mozilla34
People
(Reporter: jujjyl, Assigned: ehsan.akhgari)
Details
Attachments
(2 files, 1 obsolete file)
1.13 KB,
application/x-gzip
|
Details | |
3.04 KB,
patch
|
baku
:
review+
|
Details | Diff | Splinter Review |
If one replaces the console.log function in a worker to e.g. post the messages back to main thread instead of printing to console, this assignment is ignored and the worker will keep calling to the original browser-implemented console.log function instead of calling the user-defined function. See the attached code for a test case. See also https://bugzilla.mozilla.org/show_bug.cgi?id=1049091 where this was first reported.
Comment 1•10 years ago
|
||
It's possible to replace the entire object: console = { log: function(msg) { .. } }
Reporter | ||
Comment 2•10 years ago
|
||
Thanks, that works. Is there a reason why overriding just a single function is not supported, or was that just accidental?
Comment 3•10 years ago
|
||
I suspect it's a bug because on main-thread it works.
Flags: needinfo?(bzbarsky)
Comment 4•10 years ago
|
||
Andrea, did you read bug 1049091 comment 11? This is totally a bug, and a memory hog if something uses console in workers.
Flags: needinfo?(bzbarsky) → needinfo?(amarchesini)
Updated•10 years ago
|
Summary: It is not possible to override console.log in a worker. → It is not possible to override console.log (or set any expandos on console) in a worker because self.console returns a new object each time
Assignee | ||
Comment 5•10 years ago
|
||
Assignee | ||
Updated•10 years ago
|
Attachment #8469585 -
Flags: review?(amarchesini)
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → ehsan
Comment 6•10 years ago
|
||
Comment on attachment 8469585 [details] [diff] [review] Do not return a new console object every time self.console is called on workers; r=baku Why can't you just make the return type Console* and return mConsole?
Assignee | ||
Comment 7•10 years ago
|
||
I can!
Assignee | ||
Updated•10 years ago
|
Attachment #8469585 -
Attachment is obsolete: true
Attachment #8469585 -
Flags: review?(amarchesini)
Assignee | ||
Comment 8•10 years ago
|
||
Assignee | ||
Updated•10 years ago
|
Attachment #8469628 -
Flags: review?(amarchesini)
Comment 9•10 years ago
|
||
Comment on attachment 8469628 [details] [diff] [review] Do not return a new console object every time self.console is called on workers; r=baku Review of attachment 8469628 [details] [diff] [review]: ----------------------------------------------------------------- good!
Attachment #8469628 -
Flags: review?(amarchesini) → review+
Updated•10 years ago
|
Flags: needinfo?(amarchesini)
Assignee | ||
Comment 10•10 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/9cc8465f45a5
Assignee | ||
Comment 11•10 years ago
|
||
Backed out because this patch seems to leak the Console object :( https://hg.mozilla.org/integration/mozilla-inbound/rev/587758056245 https://tbpl.mozilla.org/php/getParsedLog.php?id=45531709&tree=Mozilla-Inbound
Comment 12•10 years ago
|
||
Perhaps because WorkerGlobalScope doesn't CC the mConsole member?
Assignee | ||
Comment 13•10 years ago
|
||
Ah, of course, the cycle collector needs to know about mConsole! https://hg.mozilla.org/integration/mozilla-inbound/rev/cf471a3f661b
https://hg.mozilla.org/mozilla-central/rev/cf471a3f661b
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
You need to log in
before you can comment on or make changes to this bug.
Description
•