Closed Bug 1222880 Opened 9 years ago Closed 9 years ago

Build a tree of AnimatedGeometryRoot objects to optimize finding ancestors

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: mattwoodrow, Assigned: mattwoodrow)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 3 obsolete files)

FLB frequently walks up AnimatedGeometryRoots (usually looking for scrollable frames), and this adds up to a fair amount of time in some profiles.

We already basically have this information during display list building as AutoBuildingDisplayList stores each AnimatedGeometryRoot on the stack. I want to copy this into the display list arena so that FLB can use it.
I also want to get rid of the nsLayoutUtils functions for finding AGRs, and require that you obtain them from a display item instead.

We had confusion previously where the AGR for a frame wasn't always defined (transforms, background-attachment:fixed etc), and this should fix that.
Attached patch [WIP] first attempt (obsolete) — Splinter Review
Attached patch [WIP] passes most tests (obsolete) — Splinter Review
Attachment #8684765 - Attachment is obsolete: true
Attachment #8685811 - Attachment is obsolete: true
Attachment #8685935 - Flags: review?(roc)
Attachment #8685935 - Flags: review?(tnikkel)
Comment on attachment 8685935 [details] [diff] [review]
Keep a tree of AGRs for faster traversal

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

::: layout/base/nsDisplayList.cpp
@@ +669,5 @@
>                             getter_AddRefs(mBoundingSelection));
>      }
>    }
>  
> +  mAnimatedGeometryRootCache.Put(aReferenceFrame, &mRootAGR);

Call this mFrameToAnimatedGeometryRootMap to indicate it's not a cache.

::: layout/base/nsDisplayList.h
@@ +107,5 @@
>    virtual const char* Name() override { return n; } \
>    virtual Type GetType() override { return e; }
>  
> +
> +struct AnimatedGeometryRoot

Needs documentation

@@ +1122,5 @@
>  
>      uint32_t mBudget;
>    };
>  
> +  nsIFrame* const                      mReferenceFrame;

fix indent, or just stop aligning all these fields
Attachment #8685935 - Flags: review?(roc) → review+
Comment on attachment 8685935 [details] [diff] [review]
Keep a tree of AGRs for faster traversal

Since you are removing the only user of nsDisplayTransform::IsReferenceFrameBoundary can you remove that function too?

So this effectively removes the frame->AGR cache, and replaces it with an frameAGR->AGR struct cache. Why not just make it a frame->AGR struct cache?

>+nsDisplayListBuilder::WrapAGRForFrame(nsIFrame* aAnimatedGeometryRoot,
>+      nsIFrame* parentFrame = nsLayoutUtils::GetCrossDocParentFrame(aAnimatedGeometryRoot);

Can you add an assert that this doesn't go above the root reference frame?

> nsDisplayListBuilder::RecomputeCurrentAnimatedGeometryRoot()
> {
>+  if (*mCurrentAGR != mCurrentFrame &&
>+      IsAnimatedGeometryRoot(const_cast<nsIFrame*>(mCurrentFrame))) {
>+    mCurrentAGR = WrapAGRForFrame(const_cast<nsIFrame*>(mCurrentFrame), mCurrentAGR);
>+  }
> }

This technically isn't enough since any child AGR struct of mCurrentFrame will point to mCurrentAGR when it should point to mCurrentFrame.

It's gross, but should we iterate the hash table of AGR structs and update their fields?

>+struct AnimatedGeometryRoot
>+  AnimatedGeometryRoot* mParent;

Can we call this mParentAGR? Otherwise it's too easy to get confused between the AGR parent and the frame parent.
Attachment #8685935 - Attachment is obsolete: true
Attachment #8685935 - Flags: review?(tnikkel)
Attachment #8691270 - Flags: review?(tnikkel)
Comment on attachment 8691270 [details] [diff] [review]
Keep a tree of AGRs for faster traversal v2

Thanks.

We'll have to keep on eye on RecomputeCurrentAnimatedGeometryRoot because if we force activate a scrollframe that is deeply nested inside other scrollframes we'll have to force activate them all, and call RecomputeCurrentAnimatedGeometryRoot for them all. But that should be rare (because we set a displayport on all ancestors when setting a displayport on a child, and it should only last one paint because we set a displayport when we force layerize.
Attachment #8691270 - Flags: review?(tnikkel) → review+
Depends on: 1235186
Depends on: 1247949
Depends on: 1294133
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: