Contact emails
vmp...@chromium.org, dom...@chromium.org
Spec
Spec proposal is here:
https://github.com/whatwg/html/pull/2332
The spec has been reviewed and is considered ready to merge by the editors but we'd like sign off from WebKit before performing the merge.
Summary
This change allows web developers to request to decode an img element. The call to a new HTML <img> element’s decode() function returns a promise, which, when fulfilled, ensures that the image can be appended to the DOM without causing a decoding delay on the next frame.
Sample code:
var img = new Image();
img.src = "nebula.jpg";
img.decode().then(function() {
document.getElementById("container").appendChild(img);
});
Motivation
Currently there is no simple way for the web developer to insert an image into the DOM without causing a decoding delay.
You can see a demo of a prototype here:
https://drive.google.com/file/d/0B5cKk7MxQ2LsUUotR3RuWUlpSXc/view?usp=sharing
The first page, sync.html, uses an onload handler, which when fired will append the image to the DOM. This causes a noticeable delay in the requestAnimationFrame-driven animation of the spinning arrow.
The second page, async.html, uses decode() functionality (similar to the sample code above), which when resolved will append the image to the DOM. Note a significant reduction in the delay during the raf animation of the spinning arrow.
The video was made using a prototype patch (still work in progress):
https://codereview.chromium.org/2769823002/
Interoperability and Compatibility Risk
This feature has interest and support from WebKit, who initiated the discussion. There are no signals from Edge or Gecko at this time.
As for compatibility: as long as web developers feature-detect for this API, it can be removed without risk. If they do not, then removing it could break the image display on pages using code similar to the sample above, or cause other program flow errors. This could be mitigated by replacing it with a no-op method that always returns a fulfilled promise.
Discussion links:
Initial proposal: https://github.com/whatwg/html/issues/1920
More discussion: https://github.com/whatwg/html/issues/2037
Ongoing technical constraints
None. As mentioned, this is a promise based approach which means that the work to decode the image could happen asynchronously on any thread. As long as the promise is satisfied with correct behavior results, the way the work gets done is up to the UA.
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes
Requesting approval to ship?
No
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.