<?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>27955</bug_id>
          
          <creation_ts>2015-02-04 07:10:42 +0000</creation_ts>
          <short_desc>share an immutable object between threads</short_desc>
          <delta_ts>2016-10-25 09:27:49 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>whatwg-resolved</status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Charlie">charlie651</reporter>
          <assigned_to name="This bug has no owner yet - up for the taking">dave.null</assigned_to>
          <cc>annevk</cc>
    
    <cc>arronei</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>117688</commentid>
    <comment_count>0</comment_count>
    <who name="Charlie">charlie651</who>
    <bug_when>2015-02-04 07:10:42 +0000</bug_when>
    <thetext>&quot;The steps will return a new object of the same type, and will permanently neuter the original object. &quot;

It would be nice to have a way to make an arraybuffer available for reading both to a worker thread and to the main thread for reading without duplicating it in memory.

Sending it as a message will duplicate it, and transferring it will neuter it making it unavailable to the main thread.

If we can make the ArrayBuffer read only, we should be able to share it between the worker and code in the main thread while preserving thread safety.

Maybe a syntax like worker.postMessage(message, [transfers], [shares])?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117695</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2015-02-04 18:38:22 +0000</bug_when>
    <thetext>This requires JS engines to support threadsafe GC or some other threadsafe form of memory management for the arraybuffer, right?

It also requires the readonly bit, which is not so simple post-facto...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117703</commentid>
    <comment_count>2</comment_count>
    <who name="Charlie">charlie651</who>
    <bug_when>2015-02-05 05:16:55 +0000</bug_when>
    <thetext>Good point that thread safe GC would be required - I don&apos;t have a good enough understanding of browser implementations to understand how difficult that would be.  Maybe a thread could be required to pass shared objects back to the original thread for them to be released?

There is already Object.freeze which works on ArrayBuffer, so i think implementing immutability may not be so much of a challenge.

I came across this interesting proposal https://gist.github.com/dherman/5401735 which may be an alternate solution.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117706</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2015-02-05 14:21:00 +0000</bug_when>
    <thetext>&gt; There is already Object.freeze which works on ArrayBuffer

Object.freeze on an ArrayBuffer doesn&apos;t prevent mutation of its data:

  var buf = new ArrayBuffer(1);
  var view = new Uint8Array(buf);
  view[0] = 5;
  alert(view[0]);
  Object.freeze(buf);
  view[0] = 7;
  var view2 = new Uint8Array(buf);
  alert(view2[0]);

dherman&apos;s proposal is a strict superset of yours, looks like; I think it ran into implementation difficulties...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126206</commentid>
    <comment_count>4</comment_count>
    <who name="Arron Eicholz">arronei</who>
    <bug_when>2016-04-27 16:53:38 +0000</bug_when>
    <thetext>HTML5.1 Bugzilla Bug Triage: Incubation needed

This bug constitutes a request for a new feature of HTML. The current guidelines [1], rather than track such requests as bugs or issues, please create a proposal outlining the desired behavior, or at least a sketch of what is wanted (much of which is probably contained in this bug), and start the discussion/proposal in the WICG [2]. As your idea gains interest and momentum, it may be brought back into HTML through the Intent to Migrate process [3].
[1] https://github.com/w3c/html#contributing-to-this-repository
[2] https://www.w3.org/community/wicg/
[3] https://wicg.github.io/admin/intent-to-migrate.html</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>