<?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>29388</bug_id>
          
          <creation_ts>2016-01-21 23:10:10 +0000</creation_ts>
          <short_desc>Attribute to prevent calls to function passing TypedArray w/ backing SharedArrayBuffer</short_desc>
          <delta_ts>2019-02-28 13:34:37 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>WebIDL</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>binji</reporter>
          <assigned_to name="Cameron McCormack">cam</assigned_to>
          <cc>annevk</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>d</cc>
    
    <cc>jfb</cc>
    
    <cc>lhansen</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>public-script-coord</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>124661</commentid>
    <comment_count>0</comment_count>
    <who name="">binji</who>
    <bug_when>2016-01-21 23:10:10 +0000</bug_when>
    <thetext>SharedArrayBuffers are a new spec that is being proposed for JavaScript. See the spec here: http://lars-t-hansen.github.io/ecmascript_sharedmem/shmem.html

They use the same TypedArray hierarchy, but they will have a backing store that can be shared between Workers.

It&apos;s likely that most APIs will not want to allow TypedArrays with a backing SharedArrayBuffer to be passed, and instead to throw an exception.

I sent a message to blink-dev asking about this (see  https://groups.google.com/a/chromium.org/d/topic/blink-dev/EsX3S43nm-0/discussion) and they suggested communicating with the WebIDL authors.

My initial thought is that passing shared TypedArrays should be opt-in, so by default they will throw an exception. The APIs that want to accept a shared TypedArray will be annotated in some way (per function? per function argument?)

Does this seem reasonable?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124663</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2016-01-22 05:20:37 +0000</bug_when>
    <thetext>Lars, how does this sound?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124665</commentid>
    <comment_count>2</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2016-01-22 07:14:54 +0000</bug_when>
    <thetext>Opt-in makes a lot of sense to me. It seems most natural to opt in on a per-argument basis. 

- ArrayBuffer -&gt; (ArrayBuffer or SharedArrayBuffer)
- Int8Array -&gt; [AllowShared] Int8Array, etc.
- ArrayBufferView -&gt; [AllowShared] ArrayBufferView

There should then be some sort of requirement that specs which opt in to this have their processing models for the typed array/array buffer argument more well defined than they are currently. Specs are generally not very precise about when or if they do copies, transfers, moves, etc. IDL tries to enforce more precision with:

&gt; At the specification prose level, IDL buffer source types are simply references to objects. To inspect or manipulate the bytes inside the buffer, specification prose MUST first either get a reference to the bytes held by the buffer source or get a copy of the bytes held by the buffer source. With a reference to the buffer source’s bytes, specification prose can get or set individual byte values using that reference.

But for APIs that accept SAB I&apos;d expect extreme precision, possibly with branching paths depending on SAB or not (e.g. &quot;get a reference to the bytes held by the buffer source&quot; for SAB and &quot;get a copy of the bytes held by the buffer source&quot; for AB).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124666</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2016-01-22 08:08:06 +0000</bug_when>
    <thetext>See bug 28798 for the suggestion to use new IDL syntax to indicate whether to use by-reference or copy the input. I think we should fix that together with this bug to make things a bit simpler and more obvious.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124667</commentid>
    <comment_count>4</comment_count>
    <who name="Lars T Hansen">lhansen</who>
    <bug_when>2016-01-22 08:57:43 +0000</bug_when>
    <thetext>I&apos;m for it, a similar solution was suggested at Mozilla, see https://bugzilla.mozilla.org/show_bug.cgi?id=1231687.

Also a big +1 to Domenic&apos;s remark about increasing the precision level when shared memory might be involved, of course.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124669</commentid>
    <comment_count>5</comment_count>
    <who name="Lars T Hansen">lhansen</who>
    <bug_when>2016-01-22 10:04:52 +0000</bug_when>
    <thetext>Also related discussion here:
https://github.com/lars-t-hansen/ecmascript_sharedmem/issues/38</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128252</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2016-11-23 20:24:03 +0000</bug_when>
    <thetext>I would argue this should be handled via new types, not extended attributes.  See https://bugzilla.mozilla.org/show_bug.cgi?id=1231687#c11 and following comments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129580</commentid>
    <comment_count>7</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2019-02-28 13:34:37 +0000</bug_when>
    <thetext>This was fixed in https://github.com/heycam/webidl/pull/353.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>