Re: [whatwg] Workers and addEventListener
On Fri, 16 Oct 2009, Zoltan Herczeg wrote: I would not be opposed to changing the spec to include enabling a port's message queue when addEventListener(message) is invoked. I'm reluctant to make addEventListener() do magic. we have two choices: - extend addEventListener - fix the Shared Worker example on the whatwg site to call start() seems the latter one was preferred by the majority of the people. Ian, could you do this fix? Done! Sorry about that. -- Ian Hickson U+1047E)\._.,--,'``.fL http://ln.hixie.ch/ U+263A/, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Re: [whatwg] Workers and addEventListener
I would not be opposed to changing the spec to include enabling a port's message queue when addEventListener(message) is invoked. I'm reluctant to make addEventListener() do magic. we have two choices: - extend addEventListener - fix the Shared Worker example on the whatwg site to call start() seems the latter one was preferred by the majority of the people. Ian, could you do this fix? Thanks, Zoltan
Re: [whatwg] Workers and addEventListener
On Wed, Oct 14, 2009 at 3:33 AM, Ian Hickson i...@hixie.ch wrote: There's no start() to call, since there's no explicit pointer to the MessagePort in dedicated workers. The example in the worker spec refers to shared workers, which *do* have an explicit port, and do not automatically start the port. Search for addEventListener in this document: http://www.whatwg.org/specs/web-workers/current-work/#shared-workers And you'll see what I mean. -- Ian Hickson U+1047E)\._.,--,'``.fL http://ln.hixie.ch/ U+263A/, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Re: [whatwg] Workers and addEventListener
To be absolutely clear (since there's some confusion about whether we are talking about explicit MessagePorts, or about implicit ports for dedicated workers). Are you saying that this: var channel = new MessageChannel(); channel.port1.postMessage(hi mom); channel.port2.addEventListener(message, function(event) {alert(event.data); }, false); Should result in an alert dialog being fired? Because that does not match my reading of the spec at all - the spec explicitly states that a port's message queue is only enabled via start() or via setting the onmessage IDL attribute. I would not be opposed to changing the spec to include enabling a port's message queue when addEventListener(message) is invoked. -atw On Wed, Oct 14, 2009 at 3:32 AM, Ian Hickson i...@hixie.ch wrote: On Tue, 29 Sep 2009, Zoltan Herczeg wrote: In WebKit implementation of MessagePort the addEventListener(message, ...) does not enable the transmitting of messages. All messages are actually discarded until a dummy function is assigned to onmessage. That is a bug. The port message queue is explicitly enabled during the creation of the dedicated worker (step 12). And in the normative text, it is not mentioned that addEventListener should also enable message transmitting. The normative text just says to fire an event; the DOM Events spec makes it clear that events can be handled using addEventListener()-added handlers. Anyway, my qestion is: - should addEventListener enable message transmitting? Yes. - Should it do it in all cases, or only when message is passed as the first argument It should only receive 'message' events if you say 'message' as the first argument. -- Ian Hickson U+1047E)\._.,--,'``.fL http://ln.hixie.ch/ U+263A/, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Re: [whatwg] Workers and addEventListener
On Thu, 15 Oct 2009 19:54:23 +0200, Drew Wilson atwil...@google.com wrote: I would not be opposed to changing the spec to include enabling a port's message queue when addEventListener(message) is invoked. FWIW, I would be opposed to any change to addEventListener() that makes it do something more than just registering an event listener for the given event. -- Anne van Kesteren http://annevankesteren.nl/
Re: [whatwg] Workers and addEventListener
On Thu, 15 Oct 2009, Drew Wilson wrote: On Wed, Oct 14, 2009 at 3:33 AM, Ian Hickson i...@hixie.ch wrote: There's no start() to call, since there's no explicit pointer to the MessagePort in dedicated workers. The example in the worker spec refers to shared workers, which *do* have an explicit port, and do not automatically start the port. Search for addEventListener in this document: http://www.whatwg.org/specs/web-workers/current-work/#shared-workers And you'll see what I mean. Ah, yes, for shared workers you need to call start() (or use .onmessage). -- Ian Hickson U+1047E)\._.,--,'``.fL http://ln.hixie.ch/ U+263A/, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Re: [whatwg] Workers and addEventListener
On Thu, 15 Oct 2009, Drew Wilson wrote: To be absolutely clear (since there's some confusion about whether we are talking about explicit MessagePorts, or about implicit ports for dedicated workers). Are you saying that this: var channel = new MessageChannel(); channel.port1.postMessage(hi mom); channel.port2.addEventListener(message, function(event) {alert(event.data); }, false); Should result in an alert dialog being fired? Nope, this case should not get an event fired. I would not be opposed to changing the spec to include enabling a port's message queue when addEventListener(message) is invoked. I'm reluctant to make addEventListener() do magic. -- Ian Hickson U+1047E)\._.,--,'``.fL http://ln.hixie.ch/ U+263A/, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Re: [whatwg] Workers and addEventListener
On Tue, 29 Sep 2009, Zoltan Herczeg wrote: In WebKit implementation of MessagePort the addEventListener(message, ...) does not enable the transmitting of messages. All messages are actually discarded until a dummy function is assigned to onmessage. That is a bug. The port message queue is explicitly enabled during the creation of the dedicated worker (step 12). And in the normative text, it is not mentioned that addEventListener should also enable message transmitting. The normative text just says to fire an event; the DOM Events spec makes it clear that events can be handled using addEventListener()-added handlers. Anyway, my qestion is: - should addEventListener enable message transmitting? Yes. - Should it do it in all cases, or only when message is passed as the first argument It should only receive 'message' events if you say 'message' as the first argument. -- Ian Hickson U+1047E)\._.,--,'``.fL http://ln.hixie.ch/ U+263A/, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Re: [whatwg] Workers and addEventListener
On Tue, 29 Sep 2009, Drew Wilson wrote: The intent of the spec is fairly clear that addEventListener(message) should not start the message queue dispatch - only setting the onmessage attribute does that: The first time a MessagePort #messageport object's onmessage#handler-messageport-onmessage IDL attribute is set, the port's port message queue #port-message-queue must be enabled, as if the start() #dom-messageport-start method had been called. Yes, but the dedicated worker construction algorithm explicitly enables the message ports' message queues. In fact, the only reason for the existence of the MessagePort.start() method is to enable applications to start message queue dispatch when using addEventListener(). I don't have a strong opinion as to whether we should change the spec, though. I suspect not, given Anne's email. We should instead change the example in the workers spec to call start(). There's no start() to call, since there's no explicit pointer to the MessagePort in dedicated workers. -- Ian Hickson U+1047E)\._.,--,'``.fL http://ln.hixie.ch/ U+263A/, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
[whatwg] Workers and addEventListener
Hi all, I am Zoltan Herczeg from University of Szeged, Hungary. I am a member of a team who working on WebKit browser engine. In this bug report: https://bugs.webkit.org/show_bug.cgi?id=29801 , Alexey suggested me that I should contact you about my qestion. In WebKit implementation of MessagePort the addEventListener(message, ...) does not enable the transmitting of messages. All messages are actually discarded until a dummy function is assigned to onmessage. However, after the dummy is assigned, the callback functions passed to addEventListener start receiving messages. The shared workers example here http://www.w3.org/TR/workers/ in section 1.2.4 suggests that addEventListener should also enable message transmitting. However, as Alexey pointed out, the examples are non-normative. And in the normative text, it is not mentioned that addEventListener should also enable message transmitting. I feel the workaround to enable message transmitting for addEventListener is ... 'dumb' now. Anyway, my qestion is: - should addEventListener enable message transmitting? - Should it do it in all cases, or only when message is passed as the first argument Zoltan
Re: [whatwg] Workers and addEventListener
The intent of the spec is fairly clear that addEventListener(message) should not start the message queue dispatch - only setting the onmessage attribute does that: The first time a MessagePort #messageport object's onmessage#handler-messageport-onmessage IDL attribute is set, the port's port message queue #port-message-queue must be enabled, as if the start() #dom-messageport-start method had been called. In fact, the only reason for the existence of the MessagePort.start() method is to enable applications to start message queue dispatch when using addEventListener(). I don't have a strong opinion as to whether we should change the spec, though. I suspect not, given Anne's email. We should instead change the example in the workers spec to call start(). -atw On Tue, Sep 29, 2009 at 2:13 AM, Anne van Kesteren ann...@opera.com wrote: On Tue, 29 Sep 2009 09:13:17 +0200, Zoltan Herczeg zherc...@inf.u-szeged.hu wrote: Anyway, my qestion is: - should addEventListener enable message transmitting? - Should it do it in all cases, or only when message is passed as the first argument I don't think it should. Web Workers should not modify the semantics of addEventListener. -- Anne van Kesteren http://annevankesteren.nl/