Skip to content

Commit

Permalink
[Optimize flamechart][4/4] Split FlamechartView into row views
Browse files Browse the repository at this point in the history
Allow the view system to render only affected flamechart rows. This
greatly improves flamechart hover performance, which has a high impact
on our app's performance as the flamechart is the slowest view to
render.

Also adds a new `ColorView` view that fills the flamechart area with a
solid background color to fix these issues:

1. Black empty areas appearing below flamecharts without much stack
   depth
2. Lines appearing between flamechart rows. My hypothesis is that these
   are appearing due to subpixel rendering, even though the flamechart
   rows' `visibleArea`s are all integers.

Related to #50.

* `yarn flow`: no errors in changed code
* `yarn lint`
* `yarn start`: 60 FPS hovers on our Facebook.com profile
* `yarn test`
  • Loading branch information
taneliang committed Jul 30, 2020
1 parent f3d6ee0 commit 5fe70a3
Show file tree
Hide file tree
Showing 6 changed files with 264 additions and 123 deletions.
11 changes: 5 additions & 6 deletions src/CanvasPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,13 @@ function AutoSizedCanvas({data, height, width}: AutoSizedCanvasProps) {
surfaceRef.current,
{origin: zeroPoint, size: {width, height}},
data.flamechart,
data,
data.duration,
);
flamechartViewRef.current = flamechartView;
const flamechartVScrollWrapper = new VerticalScrollView(
surfaceRef.current,
{origin: zeroPoint, size: {width, height}},
flamechartView,
flamechartView.intrinsicSize.height,
);

const stackedZoomables = new StaticLayoutView(
Expand All @@ -166,7 +165,7 @@ function AutoSizedCanvas({data, height, width}: AutoSizedCanvasProps) {
surfaceRef.current,
{origin: zeroPoint, size: {width, height}},
stackedZoomables,
flamechartView.intrinsicSize.width,
reactEventsView.intrinsicSize.width,
);

rootViewRef.current = new StaticLayoutView(
Expand Down Expand Up @@ -250,7 +249,7 @@ function AutoSizedCanvas({data, height, width}: AutoSizedCanvasProps) {

const {current: flamechartView} = flamechartViewRef;
if (flamechartView) {
flamechartView.onHover = flamechartStackFrame => {
flamechartView.setOnHover(flamechartStackFrame => {
if (
!hoveredEvent ||
hoveredEvent.flamechartStackFrame !== flamechartStackFrame
Expand All @@ -262,7 +261,7 @@ function AutoSizedCanvas({data, height, width}: AutoSizedCanvasProps) {
data,
});
}
};
});
}
}, [
reactEventsViewRef,
Expand All @@ -287,7 +286,7 @@ function AutoSizedCanvas({data, height, width}: AutoSizedCanvasProps) {

const {current: flamechartView} = flamechartViewRef;
if (flamechartView) {
flamechartView.setHoveredFlamechartNode(
flamechartView.setHoveredFlamechartStackFrame(
hoveredEvent ? hoveredEvent.flamechartStackFrame : null,
);
}
Expand Down
Loading

1 comment on commit 5fe70a3

@vercel
Copy link

@vercel vercel bot commented on 5fe70a3 Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.