Closed Bug 800859 Opened 12 years ago Closed 12 years ago

Make MozAfterPaint fire after composition

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: dao, Assigned: roc)

References

Details

(Whiteboard: [Snappy:P1])

Attachments

(4 files, 2 obsolete files)

From bug 715402 comment 77:

> > > > Currently MozAfterPaint fires when we've finished drawing the window
> > > > contents to the layer tree, but before we composite that to the window. But
> > > > let's fix that.
> > > 
> > > Actually, let's not, since MozAfterPaint was designed to tell us about which
> > > areas of the window have been redrawn, so it needs to fire after they've
> > > been drawn and before new dirty areas are accumulated.
> > 
> > That's not really what most MozAfterPaint consumers I've seen want. What
> > also seems worrisome to me here is that talos makes extensive use of
> > MozAfterPaint, apparently missing an important last step.
> 
> OK.
> 
> > > What you really want here is something to tell you when the window has been
> > > composited, and we have no event for that. Plus we're driving towards having
> > > that happen off the main thread, which makes this tricky.
> > 
> > When composition happens off the main thread, a MozAfterPaint listener won't
> > block it and we won't care about it as far as this bug is concerned, right?
> 
> You probably still want to delay your delayedStartup work until after the
> compositor thread has composited the window, since the two threads can still
> contend for resources.
> 
> I *suppose* we could make MozAfterPaint fire after the composite, carrying a
> list of the rectangles we repainted in the paint phase before the composite,
> even if new stuff has been invalidated between the paint and the composite.
> Maybe we should do that.
Blocks: 715402
p1 since it blocks a p1.
Whiteboard: [Snappy] → [Snappy:P1]
(In reply to Taras Glek (:taras) from comment #1)
> p1 since it blocks a p1.

Also the fact that this affects talos might be enough to make this a p1...
Assignee: nobody → roc
These patches change invariants slightly ... right after a MozAfterPaint fires, DOMWindowUtils.isMozAfterPaintPending can still return true, since we could have a pending paint event that hasn't been composited yet. I think that's OK.
This seems to have exposed a number of tests that expect subdocuments that aren't toplevel content documents to receive MozAfterPaint events.
Also, dom/browser-element/BrowserElementChild.js seems to require MozAfterPaint to fire on arbitrary subdocuments.

The strange thing is that I thought we disabled that in DLBI already, restricting MozAfterPaint to toplevel documents and toplevel content documents only.
Try to make MozAfterPaint work in all kinds of subdocuments:
https://tbpl.mozilla.org/?tree=Try&rev=8d660b0a8b2b
Attached patch Part 3 v2Splinter Review
Tightens up handling of mAllInvalidated to avoid bugs/assertions.
Attachment #673498 - Flags: review?(matt.woodrow)
This turns out to be super easy...
Attachment #673499 - Flags: review?(matt.woodrow)
Try results look good.
Attachment #673092 - Flags: review?(matt.woodrow) → review+
Attachment #673093 - Flags: review?(matt.woodrow) → review+
Comment on attachment 673498 [details] [diff] [review]
Part 3 v2

Review of attachment 673498 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/base/nsPresContext.cpp
@@ +2271,5 @@
>    }
>  
> +  if (!mFireAfterPaintEvents) {
> +    return;
> +  }

This change here is why we need part 4. Previously we were only checking for mFireAfterPaintEvent on the root pres context, and if true we would fire MozAfterPaint for all subdocuments (even though they wouldn't have any rects stored).
Attachment #673498 - Flags: review?(matt.woodrow) → review+
Comment on attachment 673499 [details] [diff] [review]
Part 4: Enable MozAfterPaint for all subdocuments

Review of attachment 673499 [details] [diff] [review]:
-----------------------------------------------------------------

Patch looks good, but are we sure that we want to do this? The extra compositing cost on BasicLayers might be an issue, not really convinced it's a problem though.

When we discussed this originally, we decided that it would be better to just send empty MozAfterPaint events to all subdocuments.
Attachment #673499 - Flags: review?(matt.woodrow) → review+
(In reply to Matt Woodrow (:mattwoodrow) from comment #15)
> This change here is why we need part 4. Previously we were only checking for
> mFireAfterPaintEvent on the root pres context, and if true we would fire
> MozAfterPaint for all subdocuments (even though they wouldn't have any rects
> stored).

True. However, part 4 also ensures we compute the correct invalidation rects for all subdocuments, which we weren't doing before.
(In reply to Matt Woodrow (:mattwoodrow) from comment #16)
> Patch looks good, but are we sure that we want to do this? The extra
> compositing cost on BasicLayers might be an issue, not really convinced it's
> a problem though.
> When we discussed this originally, we decided that it would be better to
> just send empty MozAfterPaint events to all subdocuments.

Now that you mention it, we don't want to do this. I had been thinking it would only force subdocuments to have layers when they have MozAfterPaint listeners registered on them, but of course if there's a MozAfterPaint listener registered on a window then nsPresContext::MayHavePaintEventListener will return true for all its descendants. So a single MozAfterPaint listener on a toplevel content document would layerize all its IFRAMEs, which could be bad.
Attachment #673094 - Attachment is obsolete: true
Attachment #673499 - Attachment is obsolete: true
Attachment #673094 - Flags: review?(matt.woodrow)
Attachment #674048 - Flags: review?(matt.woodrow)
Attachment #674048 - Flags: review?(matt.woodrow) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: