Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ImageBitmap transferable #444

Closed
wants to merge 1 commit into from
Closed

Make ImageBitmap transferable #444

wants to merge 1 commit into from

Conversation

junov
Copy link
Member

@junov junov commented Dec 23, 2015

ImageBitmap objects can already be sent using postMessage(), but this
requires a duplication of the bitmap data in memory, which is
inefficient and often unnecessary. This change is a pre-requisite
for the OffscreenCanvas proposal, which relies on ImageBitmaps as
an efficient means of transferring bitmap data to and from Workers.
See: https://wiki.whatwg.org/wiki/OffscreenCanvas

@junov
Copy link
Member Author

junov commented Dec 23, 2015

Regarding the content security model: the algorithm for transferring an ImageBitmap simply copies the value of the origin-clean flag. So no tainting happens when the ImageBitmap is tranferred to a cross-origin script. I am pretty sure this is the right thing to do, but I wanted to point this out because it is a bit tricky and I would like to make sure the security implications are considered by those who review this.

</ul>

<div w-nodev>

<p>The following IDL block formalizes this:</p>

<pre class="idl">typedef (<span>ArrayBuffer</span> or <span>CanvasProxy</span> or <span>MessagePort</span>) <dfn>Transferable</dfn>;</pre>
<pre class="idl">typedef (<span>ArrayBuffer</span> or <span>CanvasProxy</span> or
<span>MessagePort</span> or <span>ImageBitmap</span>) <dfn>Transferable</dfn>;</pre>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match other multiline typedefs this should look more like

typedef (ArrayBuffer or
         CanvasProxy or
         MessagePort or
         ImageBitmap) Transferable;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are here if you could fix a mistake I made and correct <span>ArrayBuffer</span> to <span data-x="idl-ArrayBuffer">ArrayBuffer</span> that would be lovely <3.

@domenic
Copy link
Member

domenic commented Dec 29, 2015

Reviewed, and looks good apart from editorial things. The newest build script (do a git pull in your html-build directory) gives better error output, which can help with some things.

@junov
Copy link
Member Author

junov commented Jan 14, 2016

New patch.
Applied all editorial fixes from this thread.
Updated html-build -> no errors

or <span>CanvasProxy</span>
or <span>MessagePort</span>
or <span>ImageBitmap</span>) <dfn>Transferable</dfn>;
</pre>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we try to avoid putting <pre> and </pre> on distinct lines. There's a bit of subtlety there display-wise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

ImageBitmap objects can already be sent using postMessage(), but this
requires a duplication of the bitmap data in memory, which is
inefficient and often unnecessary. This change is a pre-requisite
for the OffscreenCanvas proposal, which relies on ImageBitmaps as
an efficient means of transferring bitmap data to and from Workers.
See: https://wiki.whatwg.org/wiki/OffscreenCanvas
@annevk
Copy link
Member

annevk commented Jan 15, 2016

Committed as 334f9ed. Sorry for not linking the PR, I had the mistaken impression this was rebased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants