Open
Bug 1218990
Opened 9 years ago
Updated 2 years ago
Lock CSS images only when visible
Categories
(Core :: Layout: Images, Video, and HTML Frames, defect)
Core
Layout: Images, Video, and HTML Frames
Tracking
()
NEW
People
(Reporter: seth, Unassigned)
References
(Depends on 1 open bug, Blocks 2 open bugs)
Details
(Whiteboard: [MemShrink:P2])
Attachments
(2 files, 2 obsolete files)
We should only lock CSS images (background-image, border-image, etc) when they're visible. After bug 1157546, this can be implemented by locking CSS images in nsIFrame::OnBecameVisible() and unlocking them in nsIFrame::OnBecameNonvisible(). We'll also need to remove the existing code that locks them forever and throws away the key.
Reporter | ||
Updated•9 years ago
|
Blocks: 1151373
Summary: Lock CSS images only when visibile → Lock CSS images only when visible
Comment 1•9 years ago
|
||
checking in on this since it blocks a performance regression!
Reporter | ||
Comment 2•9 years ago
|
||
(In reply to Joel Maher (:jmaher) from comment #1)
> checking in on this since it blocks a performance regression!
Patches coming right up. Unfortunately I had to rewrite this one a few times to get an implementation I was really happy with.
Reporter | ||
Comment 3•9 years ago
|
||
Here's the patch! Again, there's only one part, but I've separated the patch in
two for easier reviewing.
Part 1a takes care of removing the old tracking code for CSS images that's no
longer needed given the changes in part 1b. In particular, the style structs
that contain images no longer need to support TrackImage() and UntrackImage()
calls, and we can just delete the code that calls those methods in most cases,
as in part 1b we start relying on the image visibility mechanism instead.
Attachment #8685311 -
Flags: review?(tnikkel)
Reporter | ||
Comment 4•9 years ago
|
||
This part (the final part) actually implements visibility tracking for CSS
images.
It turns out to be pretty simple:
- In ImageLoader, AssociateRequestToFrame() now registers the image with the
document (locking it) if the frame is visible. DisassociateRequestFromFrame()
similarly unregisters the image if the frame is visible.
- We also need to consider dynamic changes in visibility, so ImageLoader gains
two new methods: RegisterImagesForFrame() and UnregisterImagesForFrame().
These methods are called from nsIFrame::OnBecameVisible() and
nsIFrame::OnBecameNonvisible() respectively.
That's really about it! Since AssociateRequestToFrame() and
DisassociateRequestFromFrame() are already called in the appropriate places
(e.g. when a CSS background-image is added or removed for a given frame), these
changes are pretty much all we need to make things work. Easy!
(Though I have to admit, it took me a couple of passes to realize things could
be this simple!)
Attachment #8685312 -
Flags: review?(tnikkel)
Reporter | ||
Comment 5•9 years ago
|
||
Reporter | ||
Comment 6•9 years ago
|
||
Looks like there are a few failures in that try job:
image/test/mochitest/test_background_image_anim.html (in oth)
layout/base/tests/browser_onbeforeunload_only_after_interaction_in_frame.js (in bc3)
layout/reftests/bugs/1114526-1.html (in R1 or R2)
Surprisingly few considering what a fundamental change this is.
I'll investigate those and upload an updated version of the patch.
Reporter | ||
Comment 7•9 years ago
|
||
Reporter | ||
Comment 8•9 years ago
|
||
^^^ This updated try job includes bug 1223747, bug 1223751, and bug 1223753 , which should fix all of the failures above. It's worth noting that these were all existing issues that were just exposed by accurately tracking visibility of CSS images.
Reporter | ||
Comment 9•9 years ago
|
||
A minor rebase was required because of changes in the blocking bugs.
Attachment #8686381 -
Flags: review?(tnikkel)
Reporter | ||
Updated•9 years ago
|
Attachment #8685312 -
Attachment is obsolete: true
Attachment #8685312 -
Flags: review?(tnikkel)
Reporter | ||
Comment 10•9 years ago
|
||
Reporter | ||
Updated•9 years ago
|
Whiteboard: [MemShrink]
Reporter | ||
Comment 11•9 years ago
|
||
Updated this patch to use IsVisible() when possible.
Attachment #8687052 -
Flags: review?(tnikkel)
Reporter | ||
Updated•9 years ago
|
Attachment #8686381 -
Attachment is obsolete: true
Attachment #8686381 -
Flags: review?(tnikkel)
Reporter | ||
Comment 12•9 years ago
|
||
Reporter | ||
Comment 13•9 years ago
|
||
Based upon the try results above, it looks like this entire patch stack is now ready to land module review.
Comment 14•9 years ago
|
||
Comment on attachment 8687052 [details] [diff] [review]
(Part 1b) - Register CSS images with the document when their associated frame is visible.
>@@ -88,16 +91,47 @@ ImageLoader::AssociateRequestToFrame(imgIRequest* aRequest,
>+ if (aFrame->IsVisible()) {
>+ nsIDocument* doc = aFrame->PresContext()->Document();
>+ if (doc) {
>+ doc->AddImage(aRequest);
>+ }
>+ }
>+ }
>+}
You can count me as the first victim of the naming of IsVisible, because as I would reading this I was thinking "why is the css style 'visibility: visible' all we need to check here??".
Comment 15•9 years ago
|
||
Comment on attachment 8687052 [details] [diff] [review]
(Part 1b) - Register CSS images with the document when their associated frame is visible.
Are you planning to respond to UnlockedDraw notifications? Because I think you need to (for animation purposes at least).
Updated•9 years ago
|
Whiteboard: [MemShrink] → [MemShrink:P1]
Updated•8 years ago
|
Attachment #8687052 -
Flags: review?(tnikkel)
Updated•8 years ago
|
Attachment #8685311 -
Flags: review?(tnikkel)
Comment 16•8 years ago
|
||
Jet, is there someone who can pick this work back up again or should we deprioritize it?
Flags: needinfo?(bugs)
Comment 17•7 years ago
|
||
tn: is this something we should still try to get landed? If yes, can you help summarize the remaining pieces needed? Thx!
Flags: needinfo?(bugs) → needinfo?(tnikkel)
Comment 18•7 years ago
|
||
It doesn't seem like it's that high of priority. It doesn't cause us problems in common cases most of the time.
The work remaining is similar to the two patches that are posted in this bug, although they have surely bitrot.
Flags: needinfo?(tnikkel)
Updated•6 years ago
|
Product: Core → Core Graveyard
Updated•6 years ago
|
Product: Core Graveyard → Core
Updated•6 years ago
|
Whiteboard: [MemShrink:P1] → [MemShrink:P2]
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•