SharedArrayBuffer: cloning vs transferring?

Axel Rauschmayer rauschma at icloud.com
Mon Jan 30 02:09:12 UTC 2017


Will do!

> On 29 Jan 2017, at 15:15, Lars Hansen <lhansen at mozilla.com> wrote:
> 
> If you encounter a most-current-release browser that requires the transfer form of postmessage, could you follow up here so that I can bug the appropriate person about it?  Thanks.
> 
> --lars
> 
> 
> On Sat, Jan 28, 2017 at 2:26 PM, Axel Rauschmayer <rauschma at icloud.com <mailto:rauschma at icloud.com>> wrote:
> Thanks! This worked for me for a toy example (for multiple calls, I’d record whether an exception was thrown during the first try):
> 
> ```
> try {
>     // Try new API (clone)
>     worker.postMessage({sharedBuffer});
> } catch (e) {
>     // Fall back to old API (transfer)
>     worker.postMessage({sharedBuffer}, [sharedBuffer]);
> }
> ```
> 
> Complete source code: https://github.com/rauschma/shared-array-buffer-demo/blob/master/main.js <https://github.com/rauschma/shared-array-buffer-demo/blob/master/main.js>
> 
> Axel
> 
>> On 25 Jan 2017, at 15:03, Lars Hansen <lhansen at mozilla.com <mailto:lhansen at mozilla.com>> wrote:
>> 
>> You're asking about how postMessage() handles a SharedArrayBuffer, since the spec changed last summer from requiring the buffer to be in the transfer list to forbidding it.  For the time being, Firefox allows the SAB to be in the transfer list but prints a warning in the console; by and by we will throw an error for that (and until then we'll fail any test cases that test for an exception).  This is implemented in Firefox 51, if my testing right now is correct.
>> 
>> Since no browser has officially shipped this functionality I think some browser sniffing may be reasonable for early adopters who want to operate in a multi-browser setting.  I would expect that when this functionality is enabled by default in a browser the browser would adhere to the spec.
>> 
>> --lars
>> 
>> 
>> On Wed, Jan 25, 2017 at 10:49 AM, Axel Rauschmayer <rauschma at icloud.com <mailto:rauschma at icloud.com>> wrote:
>> AFAICT, all current implementations want you to transfer SABs. What’s the best way to prepare for the future? `try` transferring and clone in the `catch` clause?
>> 
>> Thanks!
>> 
>> Axel
>> 
>> --
>> Dr. Axel Rauschmayer
>> rauschma.de <http://rauschma.de/>
>> [Sent from a mobile device, please forgive brevity and typos]
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
>> https://mail.mozilla.org/listinfo/es-discuss <https://mail.mozilla.org/listinfo/es-discuss>
>> 
> 
> -- 
> Dr. Axel Rauschmayer
> axel at rauschma.de <mailto:axel at rauschma.de>
> dr-axel.de <http://dr-axel.de/>
> 

-- 
Dr. Axel Rauschmayer
axel at rauschma.de
dr-axel.de

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170130/ca6e93b1/attachment.html>


More information about the es-discuss mailing list