<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>15063</bug_id>
          
          <creation_ts>2011-12-05 16:42:09 +0000</creation_ts>
          <short_desc>each MessageChannel acts as its own task source.  This means that messages sent using this function are not guaranteed to execute in order, since the order task sources are processed isn&apos;t specified.</short_desc>
          <delta_ts>2013-01-29 20:59:21 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#message-ports</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ian</cc>
    
    <cc>james</cc>
    
    <cc>mike</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>60947</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-12-05 16:42:09 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html
Multipage: http://www.whatwg.org/C#message-ports
Complete: http://www.whatwg.org/c#message-ports

Comment:
each MessageChannel acts as its own task source.  This means that messages
sent using this function are not guaranteed to execute in order, since the
order task sources are processed isn&apos;t specified.

Posted from: 85.227.157.105 by simonp@opera.com
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/535.8 (KHTML, like Gecko) Chrome/17.0.942.0 Safari/535.8</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60948</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2011-12-05 16:43:40 +0000</bug_when>
    <thetext>The above is quoted from https://www.w3.org/Bugs/Public/show_bug.cgi?id=15007#c18

I think it&apos;s a problem. We shouldn&apos;t let the order be unspecified for ports within a single window (or worker).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61176</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-12-07 23:38:56 +0000</bug_when>
    <thetext>Why is this a problem? Seems pretty reasonable to me. Implementations should be allowed to implement all message channels by routing messages through a central dispatch process, and if we do that there&apos;s no way to really make channels that happen to have both ports in one process magically be ordered relative to each other.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61225</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2011-12-08 09:34:39 +0000</bug_when>
    <thetext>Because people have used multiple MessageChannels as a way to implement &quot;queue a task&quot; polyfill (which they want to execute in order), and they do execute in order in Opera and Chrome today. If we change it to not execute in order, sites using such polyfills would break sometimes in hard-to-debug ways.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61275</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-12-09 00:29:12 +0000</bug_when>
    <thetext>I am highly skeptical that the order is actually guaranteed in Chrome today, especially around the time if and while one were to send the port across processes and back.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61299</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2011-12-09 12:19:54 +0000</bug_when>
    <thetext>The polyfills don&apos;t send the ports to other processes, though. When a port is sent to somewhere else (and possibly back again), I&apos;m fine with order being arbitrary.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61350</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-12-09 23:06:38 +0000</bug_when>
    <thetext>Hmmm... So you&apos;re saying the order should be defined only amongst ports that have been created by a MessageChannel and not yet ever been sent over another channel...

I guess we can do that, though it&apos;ll be really convoluted to spec...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70535</commentid>
    <comment_count>7</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-07-18 16:01:39 +0000</bug_when>
    <thetext>This bug was cloned to create bug 18033 as part of operation convergence.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71586</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-07-27 06:00:36 +0000</bug_when>
    <thetext>If there&apos;s any way to get out of speccing this, I&apos;d love to take it...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72119</commentid>
    <comment_count>9</comment_count>
    <who name="James Graham">james</who>
    <bug_when>2012-08-13 12:22:03 +0000</bug_when>
    <thetext>I think I agree with Simon here; there will be compat constraints on message ordering.

I wonder if it is OK to make a design that assumes order can be preserved for each unit of related browsing context. Then each unit of related browsing context could have two associated task queues; one for same-unit messages and one for different-unit messages. Messages from the two queues might interleave, and messages from the other-unit queue might not have a well-defined order, but messages from the same-unit queue would.

Basically this is equivalent to the &quot;central dispatch server&quot; design, but with a spec-mandated optimisation that as long as you are not going outside your own related browsing context neighborhood you don&apos;t go through the seperate server but instead straight into a local queue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75906</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-10-10 23:52:37 +0000</bug_when>
    <thetext>That&apos;s more or less what I had in mind earlier when I said it&apos;d be convoluted to spec (and probably implement). But I think there&apos;s a simpler solution:

How about we just make each port have a flag that tracks if it or its paired port have ever gone through another port. While that flag isn&apos;t set (i.e. both ports are still in the same unit of related browsing contexts (henceforth &quot;unit&quot;) as the original message channel), then you use a unit-global task source shared with all the other MessagePort objects with the flag set in the same unit. But if you ever send a port through another port, then both the sent port and its paired port, as well as the new port on the other end when the port comes out, have the flag set, and then they start using their own task source just for themselves.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75941</commentid>
    <comment_count>11</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2012-10-11 06:53:53 +0000</bug_when>
    <thetext>That sounds OK.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76769</commentid>
    <comment_count>12</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-10-19 22:27:20 +0000</bug_when>
    <thetext>*** Bug 18033 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82309</commentid>
    <comment_count>13</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-01-29 20:59:21 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7669.
Check-in comment: Make MessagePort objects synchronised until they are posted through another port.
http://html5.org/tools/web-apps-tracker?from=7668&amp;to=7669</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>