Open Bug 893916 Opened 8 years ago Updated 2 years ago

Consider starting image loads async if we can


(Core :: DOM: Core & HTML, defect, P5)





(Reporter: bzbarsky, Unassigned, NeedInfo)


(Blocks 1 open bug)


It's not clear to me how we can do that given that image cache _hits_ need to be synchronous....
Unless we decouple checking the image cache from doing the image load somehow?
Flags: needinfo?(joe)
I need more context. :) What do you want to start asynchronously? The network load? The decode? Both?
Flags: needinfo?(joe) → needinfo?(bzbarsky)
As much as we can.  Basically, see bug 893113.
Flags: needinfo?(bzbarsky)
So specifically, here's a list of things I want to do async:

1)  CheckLoadURI checks
2)  Content policy checks.

That means the asyncOpen needs to be async too.

But if things are in the image cache, I need to know that sync...
Flags: needinfo?(joe)
It wouldn't be terribly hard to do that. Of course we can't always respond that something is definitely in the cache, if we need to do an If-Modified-Since, but as long as it's OK for some "cache hits" to be asynchronous we should be OK.

Although - why do cache hits even need to be synchronous? Leaving aside the HTML5 parser's preloading, what do you need on an imgIRequest that we wouldn't be able to give?
Flags: needinfo?(joe)
Right; we just need the "preloaded image" case to be sync.

> why do cache hits even need to be synchronous?

Becuase of web compat.  Specifically, the .with and .height of the HTMLImageElement need to synchronously change to the new value if the image is preloaded in a situation like this:

  var img = new Image();
  img.src = somethingIPreloaded;
  var width = img.width;

etc.  See bug 721659.
Right. Crap.
Seth, do you know who might have time to take this on?

Note that this might also be complicated by the outcome of the security work Christoph has been doing and how the results of the security checks are communicated to HTMLImageElement.  As in, we may need to restructure the imgloader API to have explicit ways to do the cache hit check (sync) and then the actual load (started async from ImageLoadingContent) code, instead of just having imagelib put work off async...
Flags: needinfo?(seth)
Priority: -- → P5
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.