Closed Bug 1501794 Opened 6 years ago Closed 5 years ago

support the img.decode() API

Categories

(Core :: Graphics: ImageLib, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox65 --- wontfix
firefox66 --- wontfix
firefox67 --- wontfix
firefox68 --- fixed

People

(Reporter: dholbert, Assigned: aosmond)

References

(Depends on 2 open bugs, )

Details

(Keywords: dev-doc-complete, feature)

Attachments

(1 file)

Filing this bug to track the img.decode() API.

Apparently Google Images uses it (or wants to) to swap seamlessly from the low-res to high-res image -- right now, that can trigger a flash (in Firefox at least) due to the high res image not being fully decoded when they swap it in. More info in https://twitter.com/jaffathecake/status/925702096300707842 .

(See also bug 1416328 for the decoding attribute, which addresses similar use-cases more declaratively.)

Spec link:
https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-decode

Chrome's intent-to-implement a while back (they've shipped it now, perhaps WebKit has as well, not sure):
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/LMV9dBG_1-I

GitHub issue where it was specced:
https://github.com/whatwg/html/issues/2037
Also: there's a good overview of the difference between the use-cases for <img decoding="..."> attribute vs. the img.decode() API in this github comment: https://github.com/whatwg/html/issues/1920#issuecomment-256114499
I looked into what needed to be done on another bug around the time I implemented the attribute, but as I recall I just never got around to implementing it.
Assignee: nobody → aosmond
Flags: needinfo?(aosmond)
Severity: normal → enhancement
Flags: needinfo?(aosmond)
Keywords: feature
Priority: -- → P3
Still one test failing (locally) but most of the way there now:

try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=1ceedbd18674054ceee009fc296db9a3043aa64a
(In reply to Andrew Osmond [:aosmond] from comment #4)
> Still one test failing (locally) but most of the way there now:
> 
> try:
> https://treeherder.mozilla.org/#/
> jobs?repo=try&revision=1ceedbd18674054ceee009fc296db9a3043aa64a

The last failure is weird. The promise is indeed rejected, but it doesn't bubble up to the test framework.
(In reply to Andrew Osmond [:aosmond] from comment #5)
> (In reply to Andrew Osmond [:aosmond] from comment #4)
> > Still one test failing (locally) but most of the way there now:
> > 
> > try:
> > https://treeherder.mozilla.org/#/
> > jobs?repo=try&revision=1ceedbd18674054ceee009fc296db9a3043aa64a
> 
> The last failure is weird. The promise is indeed rejected, but it doesn't
> bubble up to the test framework.

Spoke with arai on IRC about this, it looks like we kill the global object when the iframe is removed, so the promises are dropped on the floor, despite me issuing the rejection. I'll leave the test case failing for now.
The img decode API allows a web author to request that an image be
decoded at its intrinsic size and be notified when it has been
completed. This is useful to ensure an image is ready to display before
adding it to the DOM tree -- this will help reduce flickering.

(In reply to Eric Shepherd [:sheppy] from comment #10)

Documentation updated:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode
https://developer.mozilla.org/en-US/docs/Web/API/SVGImageElement/decode
https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement
https://developer.mozilla.org/en-US/docs/Web/API/SVGImageElement

Submitted BCD PR https://github.com/mdn/browser-compat-data/pull/3331 to update compatibility tables

Added to Firefox 65 for developers

Eric, this didn't land, and won't in time for 66 either since I have not been able to prioritize this work since. 67 is my new target.

@:aosmond -- Thanks for the reply; that's helpful. I'll update our schedule for documenting this, and will revise my PR to indicate we don't support this yet (instead of "no data").

Bug 1522288 is about potentially changing how we do image loads, in which case we probably also want to change how the decode api is implemented. See https://bugzilla.mozilla.org/show_bug.cgi?id=1522288#c8

I restarted rebasing/cleaning this up. Let's get this in 68 finally...

Pushed by aosmond@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/5a7f8303d682
Implement img decode API. r=bzbarsky,tnikkel
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
Regressions: 1544668

Submitted BCD PR 4345 to note this was added to Firefox 68.

Depends on: 1565542
Regressions: 1601826
Regressions: 1719083
No longer regressions: 1719083
Depends on: 1758035
Depends on: 1572360
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: