Open Bug 1506874 Opened 7 years ago Updated 3 years ago

Layout sidebar panel re-render 3 times for every new selection

Categories

(DevTools :: Inspector, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: pbro, Unassigned)

References

(Blocks 1 open bug)

Details

Steps: - Add some console.log statement to the render method of /devtools/client/inspector/layout/components/LayoutApp.js - Build and launch Firefox - Select nodes in the inspector with the Layout sidebar visible Expected: the console.log should be displayed once only when you select a new element Actual: the console.log appears 3 times. This means that the entire sidebar is being re-rendered 3 times in a row, for nothing. We should probably use shouldComponentUpdate, but I'm not sure how we would effectively compare the props to return true/false based on whether they changed, because the store is really complex and deep. I don't know how this part of React works exactly, but it seems to me like the LayoutApp component should only re-render if the list of accordion items changes (e.g. when you select an element that is a flex item and a flex container). However if, say, the width/height displayed in the boxmodel component change, then the LayoutApp shouldn't re-render, only the boxmodel component inside of it should. Right? That doesn't seem to be the case today and it seems like that would make the sidebar more performant if it was. Note that I'm making this block bug 1503197 because it's tricky to add new telemetry probes for the flexbox inspector when the panel re-renders more than it should.
Gabriel, with your work on the layout sidebar and on performance, I'm thinking this might be something for you to evaluate.
Flags: needinfo?(gl)
Flags: needinfo?(gl)
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.