On Fri, Apr 18, 2014 at 6:12 AM, Julien Wajsberg <[email protected]> wrote: >> On Wed, Apr 16, 2014 at 10:45 AM, ben turner <[email protected]> >> wrote: >>> >>> >>> ---------- Forwarded message ---------- >>> From: Julien Wajsberg <[email protected]> >>> Date: Wed, Apr 16, 2014 at 9:30 AM >>> Subject: [b2g] Using blobs to display images >>> To: dev-b2g <[email protected]> >>> >>> >>> Hey, >>> >>> Basically, I'd like to know whether it's better to revoke a blob URL >>> just after an image has been loaded, even if it's still displayed, or to >>> keep the blob url valid until the image is hidden. >> >> tl;dr: You should revoke it when the onload or onerror events fire. > > Ok, I see that I forgot one important bit of information: I'm actually > concerned about background images. For normal images in <img> it's easy to > do in onerror/onload. > > I tried to do clever things like loading asychronously (after setTimeout) an > in-memory image with the same blob url and discarding at onload/onerror but > this randomly fails. > > The "best" solution I have right now is to put a timer of say 30 seconds and > revoke the URL then, but I'm afraid to retain memory in case of memory > pressure. But maybe that's good enough?
Ouch, yeah, this is a bit of a problem. At the very least you can revoke the URL when we stop displaying the image. I.e. if we change the background to some other URL, or if that part of the UI is completely hidden (I don't know what piece of UI that we're talking about here). However it would also be good to have some sort of event fired once layout code has fully loaded any resources that it depends on, such as background images. However I just talked to dbaron and he pointed out that this would be of pretty narrow functionality since it wouldn't necessarily mean that the page is ready to be painted (asynchronous image decoding might still need to happen), and it also wouldn't work in cases where we avoid doing image loads for images that are outside of the current visible part of the page. Another solution here would be if we added support for URLs that map directly into indexedDB. See http://lists.w3.org/Archives/Public/public-webapps/2013JulSep/0081.html / Jonas _______________________________________________ dev-b2g mailing list [email protected] https://lists.mozilla.org/listinfo/dev-b2g
