Skip to content

Commit 29b7e5c

Browse files
committed
merge to oslabs
2 parents b6dd2c0 + eac0970 commit 29b7e5c

File tree

10 files changed

+708
-18697
lines changed

10 files changed

+708
-18697
lines changed

package-lock.json

Lines changed: 0 additions & 18318 deletions
This file was deleted.

src/app/components/PerfView.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable react-hooks/exhaustive-deps */
12
/* eslint-disable max-len */
23
/* eslint-disable @typescript-eslint/ban-types */
34
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
@@ -11,13 +12,11 @@
1112
/* eslint-disable no-plusplus */
1213
/* eslint-disable func-names */
1314
/* eslint-disable no-shadow */
14-
/* eslint-disable no-multi-spaces */
1515
/* eslint-disable newline-per-chained-call */
1616
/* eslint-disable object-curly-newline */
1717
/* eslint-disable object-property-newline */
1818
/* eslint-disable class-methods-use-this */
1919
// eslint-disable-next-line object-curly-newline
20-
/* eslint-disable comma-dangle */
2120
/* eslint-disable indent */
2221
/* eslint-disable no-console */
2322

@@ -32,10 +31,11 @@ interface PerfViewProps {
3231
viewIndex:number;
3332
width: number;
3433
height: number;
34+
setNoRenderData: any;
3535
}
3636

3737
const PerfView = (props:PerfViewProps) => {
38-
const { snapshots, viewIndex, width, height } = props;
38+
const { snapshots, viewIndex, width, height, setNoRenderData } = props;
3939
const adjustedSize = Math.min(width, height);
4040
const svgRef = useRef(null);
4141

@@ -47,7 +47,7 @@ const PerfView = (props:PerfViewProps) => {
4747
// Set up color scaling function
4848
const colorScale = d3.scaleLinear()
4949
.domain([0, 7])
50-
.range(['hsl(200,60%,60%)', 'hsl(255,30%,60%)'])
50+
.range(['hsl(200,60%,60%)', 'hsl(255,30%,40%)'])
5151
.interpolate(d3.interpolateHcl);
5252

5353
// Set up circle-packing layout function
@@ -60,6 +60,10 @@ const PerfView = (props:PerfViewProps) => {
6060
.sort((a:{value:number}, b:{value:number}) => { return b.value - a.value; }));
6161
}, [adjustedSize]);
6262

63+
function handleNoRenderData(isNoRenderData) {
64+
setNoRenderData(isNoRenderData);
65+
}
66+
6367
// If indexToDisplay changes, clear old tree nodes
6468
useEffect(() => {
6569
while (svgRef.current.hasChildNodes()) {
@@ -75,7 +79,7 @@ const PerfView = (props:PerfViewProps) => {
7579

7680
// Generate tree with our data
7781
const packedRoot = packFunc(snapshots[indexToDisplay]);
78-
console.log('PerfView -> packedRoot', packedRoot);
82+
// console.log('PerfView -> packedRoot', packedRoot);
7983

8084
// Set initial focus to root node
8185
let curFocus = packedRoot;
@@ -84,10 +88,6 @@ const PerfView = (props:PerfViewProps) => {
8488
let view;
8589

8690
// Set up viewBox dimensions and onClick for parent svg
87-
88-
// console.log("PerfView -> height", height)
89-
// console.log("PerfView -> width", width)
90-
// console.log("PerfView -> adjustedSize", adjustedSize)
9191
const svg = d3.select(svgRef.current)
9292
.attr('viewBox', `-${adjustedSize / 2} -${adjustedSize / 2} ${width} ${height}`)
9393
.on('click', () => zoomToNode(packedRoot));
@@ -111,9 +111,12 @@ const PerfView = (props:PerfViewProps) => {
111111
.enter().append('text')
112112
.style('fill-opacity', (d:{parent:object}) => (d.parent === packedRoot ? 1 : 0))
113113
.style('display', (d:{parent?:object}) => (d.parent === packedRoot ? 'inline' : 'none'))
114-
.text((d:{data:{name:string, componentData?:{actualDuration:any}}}) => {
114+
.text((d:{data:{name:string, componentData?:{actualDuration:any}}}) => {
115+
// console.log("PerfView -> d.data", d.data);
116+
if (!d.data.componentData.actualDuration) handleNoRenderData(true);
117+
else handleNoRenderData(false);
115118
return `${d.data.name}: ${Number.parseFloat(d.data.componentData.actualDuration || 0).toFixed(2)}ms`;
116-
});
119+
});
117120

118121
// Remove any unused nodes
119122
label.exit().remove();
@@ -150,7 +153,7 @@ const PerfView = (props:PerfViewProps) => {
150153

151154
curFocus = newFocus;
152155
}
153-
}, [colorScale, packFunc, width, height, indexToDisplay, snapshots, adjustedSize]);
156+
}, [colorScale, packFunc, width, height, indexToDisplay, snapshots, adjustedSize, handleNoRenderData]);
154157

155158
return (
156159
<div className="perf-d3-container">
@@ -161,6 +164,3 @@ const PerfView = (props:PerfViewProps) => {
161164
};
162165

163166
export default PerfView;
164-
165-
// d3.quantize(d3.interpolateHcl('#60c96e', '#4d4193'), 10);
166-
// const colorScale = d3.scaleOrdinal(colorScheme);

src/app/components/StateRoute.tsx

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/* eslint-disable @typescript-eslint/no-var-requires */
55
/* eslint-disable max-len */
66
/* eslint-disable object-curly-newline */
7-
import React from 'react';
7+
import React, { useState } from 'react';
88
import { MemoryRouter as Router, Route, NavLink, Switch } from 'react-router-dom';
99
import Tree from './Tree';
1010
import PerfView from './PerfView';
@@ -24,6 +24,8 @@ interface StateRouteProps {
2424

2525
const StateRoute = (props:StateRouteProps) => {
2626
const { snapshot, hierarchy, snapshots, viewIndex } = props;
27+
const [noRenderData, setNoRenderData] = useState(false);
28+
2729
// the hierarchy gets set on the first click in the page
2830
// when the page is refreshed we may not have a hierarchy, so we need to check if hierarchy was initialized
2931
// if true involk render chart with hierarchy
@@ -44,19 +46,26 @@ const StateRoute = (props:StateRouteProps) => {
4446
return <div className="noState">{NO_STATE_MSG}</div>;
4547
};
4648

47-
// the hierarchy gets set on the first click in the page
48-
// when the page is refreshed we may not have a hierarchy, so we need to check if hierarchy was initialized
49-
// if true involk render Performance graphic with snapshots
50-
const renderPerfView = () => {
51-
if (hierarchy) {
52-
return (
53-
<ErrorHandler>
54-
<PerfView viewIndex={viewIndex} snapshots={snapshots} width={600} height={1000} />
55-
</ErrorHandler>
56-
);
57-
}
58-
return <div className="noState">{NO_STATE_MSG}</div>;
59-
};
49+
let perfChart;
50+
if (!noRenderData) {
51+
perfChart = (
52+
<PerfView
53+
viewIndex={viewIndex}
54+
snapshots={snapshots}
55+
setNoRenderData={setNoRenderData}
56+
width={600}
57+
height={1000}
58+
/>
59+
);
60+
} else {
61+
perfChart = <div className="no-data-message">Rendering Data is not available for this application</div>;
62+
}
63+
64+
const renderPerfView = () => (
65+
<ErrorHandler>
66+
{perfChart}
67+
</ErrorHandler>
68+
);
6069

6170
return (
6271
<Router>

src/app/styles/components/d3graph.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,4 @@ div.tooltip {
122122
fill: #2a2f3a;
123123
pointer-events: none;
124124
text-anchor: middle;
125-
};
125+
};

src/app/styles/layout/_stateContainer.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
@extend %disable-highlight
4141
}
4242

43+
44+
.no-data-message {
45+
font: 1.2em sans-serif;
46+
padding: 10px;
47+
// margin: 10px;
48+
color: hsl(0%, 50%, 50%);
49+
}
50+
4351
.state-container {
4452
.main-navbar-text {
4553
margin: 6px;

src/backend/linkFiber.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@ export default (snap: Snapshot, mode: Mode): ()=>void => {
237237
const devTools = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
238238
const reactInstance = devTools ? devTools.renderers.get(1) : null;
239239
fiberRoot = devTools.getFiberRoots(1).values().next().value;
240-
const throttledUpdateSnapshot = throttle(updateSnapShotTree, 140);
240+
241+
const throttledUpdateSnapshot = throttle(updateSnapShotTree, 70);
241242
document.addEventListener('visibilitychange', onVisibilityChange);
243+
242244
if (reactInstance && reactInstance.version) {
243245
devTools.onCommitFiberRoot = (function (original) {
244246
return function (...args) {

tests/manual-tests/ConcurrentMode/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)