From 3fb0aba6e616c56c17cb33e833cf8e06b519f299 Mon Sep 17 00:00:00 2001
From: wangyujie
Date: Sat, 16 Nov 2024 18:52:53 +0800
Subject: [PATCH 01/38] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dnative=20memory?=
=?UTF-8?q?=E9=9D=9E=E7=BB=9F=E8=AE=A1=E6=A8=A1=E5=BC=8F=20=E5=90=AF?=
=?UTF-8?q?=E5=8A=A8=E6=A8=A1=E5=BC=8F=E6=8A=93=E5=8F=96=EF=BC=8C=E9=A6=96?=
=?UTF-8?q?=E6=AC=A1=E6=A1=86=E9=80=89=EF=BC=8Ctab=E9=A1=B5=E6=97=A0?=
=?UTF-8?q?=E6=B3=95=E6=8B=96=E5=8A=A8=E9=97=AE=E9=A2=98=EF=BC=9B=E4=BF=AE?=
=?UTF-8?q?=E5=A4=8D=E6=8C=89=E7=9D=80wasd=E5=BF=AB=E6=8D=B7=E9=94=AE?=
=?UTF-8?q?=EF=BC=8C=E6=8B=96=E5=8A=A8tab=E9=A1=B5=EF=BC=8Ctab=E9=A1=B5?=
=?UTF-8?q?=E4=BC=9A=E9=9A=8F=E9=BC=A0=E6=A0=87=E5=8A=A8=E7=9A=84=E9=97=AE?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: wangyujie
---
ide/src/trace/component/SpSystemTrace.event.ts | 10 ++++------
ide/src/trace/component/SpSystemTrace.ts | 5 ++---
ide/src/trace/component/trace/base/TraceSheet.ts | 3 ---
ide/src/trace/component/trace/search/Search.ts | 6 ------
ide/src/trace/component/trace/sheet/TabPaneCurrent.ts | 1 -
ide/src/trace/component/trace/sheet/TabPaneFilter.ts | 1 -
.../trace/component/trace/timer-shaft/TabPaneFlag.ts | 1 -
7 files changed, 6 insertions(+), 21 deletions(-)
diff --git a/ide/src/trace/component/SpSystemTrace.event.ts b/ide/src/trace/component/SpSystemTrace.event.ts
index 60d590885..27fd47bdb 100644
--- a/ide/src/trace/component/SpSystemTrace.event.ts
+++ b/ide/src/trace/component/SpSystemTrace.event.ts
@@ -621,7 +621,6 @@ export function spSystemTraceDocumentOnMouseOut(sp: SpSystemTrace, ev: MouseEven
}
export function spSystemTraceDocumentOnKeyPress(this: unknown, sp: SpSystemTrace, ev: KeyboardEvent): void {
- SpSystemTrace.isKeyUp = false;
if (!sp.loadTraceCompleted || SpSystemTrace.isAiAsk) {
return;
}
@@ -771,6 +770,10 @@ export function spSystemTraceDocumentOnMouseUp(sp: SpSystemTrace, ev: MouseEvent
if (!sp.loadTraceCompleted || !sp.mouseEventEnable) {
return;
}
+ //@ts-ignore
+ if ((window as unknown).isSheetMove) {
+ return;
+ }
if (sp.isWASDKeyPress()) {
ev.preventDefault();
ev.stopPropagation();
@@ -786,10 +789,6 @@ export function spSystemTraceDocumentOnMouseUp(sp: SpSystemTrace, ev: MouseEvent
}
TraceRow.isUserInteraction = false;
sp.rangeSelect.isMouseDown = false;
- //@ts-ignore
- if ((window as unknown).isSheetMove) {
- return;
- }
if (sp.isMouseInSheet(ev)) {
return;
}
@@ -804,7 +803,6 @@ export function spSystemTraceDocumentOnKeyUp(sp: SpSystemTrace, ev: KeyboardEven
if (SpSystemTrace.isAiAsk) {
return;
}
- SpSystemTrace.isKeyUp = true;
if (sp.times.size > 0) {
for (let timerId of sp.times) {
clearTimeout(timerId);
diff --git a/ide/src/trace/component/SpSystemTrace.ts b/ide/src/trace/component/SpSystemTrace.ts
index ec193b177..de0981083 100644
--- a/ide/src/trace/component/SpSystemTrace.ts
+++ b/ide/src/trace/component/SpSystemTrace.ts
@@ -154,7 +154,6 @@ type SlicesTimeAlias = SlicesTime | undefined | null;
@element('sp-system-trace')
export class SpSystemTrace extends BaseElement {
mouseCurrentPosition = 0;
- static isKeyUp: boolean = true;
offsetMouse = 0;
static isMouseLeftDown = false;
static scrollViewWidth = 0;
@@ -899,7 +898,7 @@ export class SpSystemTrace extends BaseElement {
// @ts-ignore
context!.moveTo(x0!, y0!);
// @ts-ignore
- if (SpSystemTrace.isKeyUp || curveDrawList.length < 90) {
+ if (curveDrawList.length < 90) {
// @ts-ignore
for (let i = 0; i < curveDrawList.length - 1; i++) {
// @ts-ignore
@@ -912,7 +911,7 @@ export class SpSystemTrace extends BaseElement {
// @ts-ignore
context.closePath();
// @ts-ignore
- } else if (!SpSystemTrace.isKeyUp && curveDrawList.length >= 90) {
+ } else if (curveDrawList.length >= 90) {
let x;
let y;
// @ts-ignore
diff --git a/ide/src/trace/component/trace/base/TraceSheet.ts b/ide/src/trace/component/trace/base/TraceSheet.ts
index aae578e1b..4a8d2bcd7 100644
--- a/ide/src/trace/component/trace/base/TraceSheet.ts
+++ b/ide/src/trace/component/trace/base/TraceSheet.ts
@@ -427,9 +427,6 @@ export class TraceSheet extends BaseElement {
let that = this;
// 节点挂载时给Tab面板绑定鼠标按下事件
this.nav!.onmousedown = (event): void => {
- if (SpSystemTrace.isKeyUp === false) {
- return;
- }
// @ts-ignore
(window as unknown).isSheetMove = true;
// 获取所有标签页的节点数组
diff --git a/ide/src/trace/component/trace/search/Search.ts b/ide/src/trace/component/trace/search/Search.ts
index 03c14b425..517c8df9d 100644
--- a/ide/src/trace/component/trace/search/Search.ts
+++ b/ide/src/trace/component/trace/search/Search.ts
@@ -248,18 +248,15 @@ export class LitSearch extends BaseElement {
this.searchBlurListener();
});
this.search!.addEventListener('keyup', (e: KeyboardEvent) => {
- SpSystemTrace.isKeyUp = true;
this._retarge_index!.value = '';
this.searchKeyupListener(e);
});
//阻止事件冒泡
this.search!.addEventListener('keydown', (e: KeyboardEvent) => {
- SpSystemTrace.isKeyUp = false;
e.stopPropagation();
});
this.search!.addEventListener('keypress', (e: KeyboardEvent) => {
- SpSystemTrace.isKeyUp = false;
e.stopPropagation();
});
this.shadowRoot?.querySelector('#arrow-left')?.addEventListener('click', (): void => {
@@ -283,12 +280,10 @@ export class LitSearch extends BaseElement {
this.keyUpListener();
//阻止事件冒泡
this.shadowRoot?.querySelector("input[name='retarge_index']")?.addEventListener('keydown', (e: unknown) => {
- SpSystemTrace.isKeyUp = false;
// @ts-ignore
e.stopPropagation();
});
this.shadowRoot?.querySelector("input[name='retarge_index']")?.addEventListener('keypress', (e: unknown) => {
- SpSystemTrace.isKeyUp = false;
// @ts-ignore
e.stopPropagation();
});
@@ -359,7 +354,6 @@ export class LitSearch extends BaseElement {
this._retarge_index!.value = '';
}, 2000);
}
- SpSystemTrace.isKeyUp = true;
// @ts-ignore
e.target.blur();
}
diff --git a/ide/src/trace/component/trace/sheet/TabPaneCurrent.ts b/ide/src/trace/component/trace/sheet/TabPaneCurrent.ts
index 414e01995..54762cc97 100644
--- a/ide/src/trace/component/trace/sheet/TabPaneCurrent.ts
+++ b/ide/src/trace/component/trace/sheet/TabPaneCurrent.ts
@@ -210,7 +210,6 @@ export class TabPaneCurrent extends BaseElement {
tr[i].querySelector('#text-input')!.value = this.slicesTimeList[i - 1].text;
// // 点击色块修改颜色
tr[i].querySelector('#text-input')?.addEventListener('keyup', (event: unknown) => {
- SpSystemTrace.isKeyUp = true;
if (
// @ts-ignore
this.tableDataSource[i].startTime === this.slicesTimeList[i - 1].startTime &&
diff --git a/ide/src/trace/component/trace/sheet/TabPaneFilter.ts b/ide/src/trace/component/trace/sheet/TabPaneFilter.ts
index 65238dded..121e104c6 100644
--- a/ide/src/trace/component/trace/sheet/TabPaneFilter.ts
+++ b/ide/src/trace/component/trace/sheet/TabPaneFilter.ts
@@ -714,7 +714,6 @@ export class TabPaneFilter extends BaseElement {
this.value = this.value.replace(/\D/g, '');
};
e.addEventListener('keyup', (event: unknown): void => {
- SpSystemTrace.isKeyUp = true;
// @ts-ignore
event.stopPropagation();
// @ts-ignore
diff --git a/ide/src/trace/component/trace/timer-shaft/TabPaneFlag.ts b/ide/src/trace/component/trace/timer-shaft/TabPaneFlag.ts
index ab73e814a..0e5be4219 100644
--- a/ide/src/trace/component/trace/timer-shaft/TabPaneFlag.ts
+++ b/ide/src/trace/component/trace/timer-shaft/TabPaneFlag.ts
@@ -189,7 +189,6 @@ export class TabPaneFlag extends BaseElement {
private textInputKeyUpEventByFlag(index: number, tr: HTMLDivElement): void {
tr.querySelector('#text-input')?.addEventListener('keyup', (event: unknown) => {
- SpSystemTrace.isKeyUp = true;
// @ts-ignore
if (this.tableDataSource[index].startTime === this.flagList[index - 1].time && event.code === 'Enter' || event.code === 'NumpadEnter') {
// @ts-ignore
--
Gitee
From 08447e666518f838f1e499860f4fff02bfffdb54 Mon Sep 17 00:00:00 2001
From: wangyujie
Date: Sat, 16 Nov 2024 18:57:13 +0800
Subject: [PATCH 02/38] =?UTF-8?q?fix:=E5=88=A0=E9=99=A4Data=20Selection?=
=?UTF-8?q?=E3=80=81Data=20Distribution=E3=80=81Total=20Duration=20tab?=
=?UTF-8?q?=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: wangyujie
---
.../component/trace/base/TraceSheetConfig.ts | 18 -
.../TabPaneSampleInstructionDistributions.ts | 424 ---------------
.../TabPaneSampleInstructionSelection.ts | 493 ------------------
...PaneSampleInstructionSelectionTotalTime.ts | 399 --------------
4 files changed, 1334 deletions(-)
delete mode 100644 ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionDistributions.ts
delete mode 100644 ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelection.ts
delete mode 100644 ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelectionTotalTime.ts
diff --git a/ide/src/trace/component/trace/base/TraceSheetConfig.ts b/ide/src/trace/component/trace/base/TraceSheetConfig.ts
index f1d1af535..88665a2fc 100644
--- a/ide/src/trace/component/trace/base/TraceSheetConfig.ts
+++ b/ide/src/trace/component/trace/base/TraceSheetConfig.ts
@@ -127,9 +127,6 @@ import { TabPaneHiSysEventSummary } from '../sheet/hisysevent/TabPaneHiSysEventS
import { TabPaneBinders } from '../sheet/binder/TabPaneBinders';
import { TabPaneGpufreq } from '../sheet/gpufreq/TabPaneGpufreqUsage';
import { TabPaneSampleInstruction } from '../sheet/bpftrace/TabPaneSampleInstruction';
-import { TabPaneSampleInstructionDistributions } from '../sheet/bpftrace/TabPaneSampleInstructionDistributions';
-import { TabPaneSampleInstructionTotalTime } from '../sheet/bpftrace/TabPaneSampleInstructionSelectionTotalTime';
-import { TabPaneSampleInstructionSelection } from '../sheet/bpftrace/TabPaneSampleInstructionSelection';
import { TabPaneDataCut } from '../sheet/TabPaneDataCut';
import { TabPaneGpuCounterSelection } from '../sheet/gpu-counter/TabPaneGpuCounterSelection';
import { TabPaneGpuCounter } from '../sheet/gpu-counter/TabPaneGpuCounter';
@@ -699,21 +696,6 @@ export let tabConfig: {
require: (param: SelectionParam) => param.threadIds.length > 0 ||
(param.clockMapData.size > 0 && param.clockMapData.has('gpufreq Frequency') === true),
},
- 'box-sample-instruction-selection': {
- title: 'Data Selection',
- type: TabPaneSampleInstructionSelection,
- require: (param: SelectionParam) => param.sampleData.length > 0,
- },
- 'box-sample-instruction-distribution-selection': {
- title: 'Data Distribution',
- type: TabPaneSampleInstructionDistributions,
- require: (param: SelectionParam) => param.sampleData.length > 0,
- },
- 'box-sample-instruction-totaltime-selection': {
- title: 'Total Duration',
- type: TabPaneSampleInstructionTotalTime,
- require: (param: SelectionParam) => param.sampleData.length > 0,
- },
'box-sample-instruction': {
title: 'Data Flow',
type: TabPaneSampleInstruction,
diff --git a/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionDistributions.ts b/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionDistributions.ts
deleted file mode 100644
index ef58348a3..000000000
--- a/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionDistributions.ts
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * Copyright (C) 2022 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { BaseElement, element } from '../../../../../base-ui/BaseElement';
-import { SelectionParam } from '../../../../bean/BoxSelection';
-import { debounce } from '../../../Utils';
-const paddingLeft = 100;
-const paddingBottom = 15;
-const xStep = 50; // x轴间距
-const barWidth = 2; // 柱子宽度
-
-@element('tab-sample-instructions-distrubtions-chart')
-export class TabPaneSampleInstructionDistributions extends BaseElement {
- private instructionChartEle: HTMLCanvasElement | undefined | null;
- private ctx: CanvasRenderingContext2D | undefined | null;
- private onReadableData: Array = [];
- private hintContent = ''; //悬浮框内容
- private floatHint!: HTMLDivElement | undefined | null; //悬浮框
- private canvasScrollTop = 0; // tab页上下滚动位置
- private isUpdateCanvas = false;
- private cacheData: Array = [];
- private canvasX = -1; // 鼠标当前所在画布x坐标
- private canvasY = -1; // 鼠标当前所在画布y坐标
- private startX = 0; // 画布相对于整个界面的x坐标
- private startY = 0; // 画布相对于整个界面的y坐标
- private hoverBar: unknown;
- private isChecked: boolean = false;
- private xCount = 0; //x轴刻度个数
- private xMaxValue = 0; //x轴上数据最大值
- private xSpacing = 50; //x轴间距
- private xAvg = 0; //根据xMaxValue进行划分 用于x轴上刻度显示
- private yAvg = 0; //根据yMaxValue进行划分 用于y轴上刻度显示
-
- initHtml(): string {
- return `
-
-
-
- `;
- }
-
- initElements(): void {
- this.instructionChartEle = this.shadowRoot?.querySelector('#instruct-chart-canvas');
- this.ctx = this.instructionChartEle?.getContext('2d');
- this.floatHint = this.shadowRoot?.querySelector('#float_hint');
- }
-
- set data(SampleParam: SelectionParam) {
- // @ts-ignore
- this.onReadableData = SampleParam.sampleData[0].property;
- this.calInstructionRangeCount(this.isChecked);
- }
-
- connectedCallback(): void {
- super.connectedCallback();
- this.parentElement!.onscroll = () => {
- this.canvasScrollTop = this.parentElement!.scrollTop;
- this.hideTip();
- };
- this.instructionChartEle!.onmousemove = (e): void => {
- if (!this.isUpdateCanvas) {
- this.updateCanvasCoord();
- }
- this.canvasX = e.clientX - this.startX;
- this.canvasY = e.clientY - this.startY + this.canvasScrollTop;
- this.onMouseMove();
- };
- this.instructionChartEle!.onmouseleave = () => {
- this.hideTip();
- };
- document.addEventListener('sample-popver-change', (e: unknown) => {
- // @ts-ignore
- const select = Number(e.detail.select);
- this.isChecked = Boolean(select);
- this.calInstructionRangeCount(this.isChecked);
- });
- this.listenerResize();
- }
-
- /**
- * 更新canvas坐标
- */
- updateCanvasCoord(): void {
- if (this.instructionChartEle instanceof HTMLCanvasElement) {
- this.isUpdateCanvas = this.instructionChartEle.clientWidth !== 0;
- if (this.instructionChartEle.getBoundingClientRect()) {
- const box = this.instructionChartEle.getBoundingClientRect();
- const D = this.parentElement!;
- this.startX = box.left + Math.max(D.scrollLeft, document.body.scrollLeft) - D.clientLeft;
- this.startY = box.top + Math.max(D.scrollTop, document.body.scrollTop) - D.clientTop + this.canvasScrollTop;
- }
- }
- }
-
- /**
- * 获取鼠标悬停的函数
- * @param nodes
- * @param canvasX
- * @param canvasY
- * @returns
- */
- searchDataByCoord(nodes: unknown, canvasX: number, canvasY: number): void | null {
- // @ts-ignore
- for (let i = 0; i < nodes.length; i++) {
- // @ts-ignore
- const element = nodes[i];
- if (this.isContains(element, canvasX, canvasY)) {
- return element;
- }
- }
- return null;
- }
-
- /**
- * 鼠标移动
- */
- onMouseMove(): void {
- const lastNode = this.hoverBar;
- //查找鼠标所在的node
- const searchResult = this.searchDataByCoord(this.cacheData, this.canvasX, this.canvasY);
- if (searchResult) {
- this.hoverBar = searchResult;
- //鼠标悬浮的node未改变则不需重新渲染文字
- if (searchResult !== lastNode) {
- this.updateTipContent();
- }
- this.showTip();
- } else {
- this.hideTip();
- this.hoverBar = undefined;
- }
- }
-
- /**
- * 隐藏悬浮框
- */
- hideTip(): void {
- if (this.floatHint) {
- this.floatHint.style.display = 'none';
- this.instructionChartEle!.style.cursor = 'default';
- }
- }
-
- /**
- * 显示悬浮框
- */
- showTip(): void {
- this.floatHint!.innerHTML = this.hintContent;
- this.floatHint!.style.display = 'block';
- this.instructionChartEle!.style.cursor = 'pointer';
- let x = this.canvasX;
- let y = this.canvasY - this.canvasScrollTop;
- //右边的函数悬浮框显示在左侧
- if (this.canvasX + this.floatHint!.clientWidth > (this.instructionChartEle!.clientWidth || 0)) {
- x -= this.floatHint!.clientWidth - 1;
- } else {
- x += 20;
- }
- //最下边的函数悬浮框显示在上方
- y -= this.floatHint!.clientHeight - 1;
- this.floatHint!.style.transform = `translate(${x}px, ${y}px)`;
- }
-
- /**
- * 更新悬浮框内容
- * @returns
- */
- updateTipContent(): void {
- const hoverNode = this.hoverBar;
- if (!hoverNode) {
- return;
- }
- const detail = hoverNode!;
- this.hintContent = `
- ${
- // @ts-ignore
- detail.instruct}
- ${
- // @ts-ignore
- parseFloat(detail.heightPer)}
- `;
- }
-
- /**
- * 判断鼠标当前在那个函数上
- * @param frame
- * @param x
- * @param y
- * @returns
- */
- isContains(point: unknown, x: number, y: number): boolean {
- // @ts-ignore
- return x >= point.x && x <= point.x + 2 && point.y <= y && y <= point.y + point.height;
- }
-
- /**
- * 统计onReadable数据各指令的个数
- * @param isCycles
- */
- calInstructionRangeCount(isCycles: boolean) {
- if (this.onReadableData.length === 0) return;
- this.cacheData.length = 0;
- const count = this.onReadableData.length;
- let instructions = {};
- if (isCycles) {
- // @ts-ignore
- instructions = this.onReadableData.reduce((pre: unknown, current: unknown) => {
- // @ts-ignore
- (pre[`${Math.ceil(current.cycles)}`] = pre[`${Math.ceil(current.cycles)}`] || []).push(current);
- return pre;
- }, {});
- } else {
- // @ts-ignore
- instructions = this.onReadableData.reduce((pre: unknown, current: unknown) => {
- // @ts-ignore
- (pre[`${Math.ceil(current.instructions)}`] = pre[`${Math.ceil(current.instructions)}`] || []).push(current);
- return pre;
- }, {});
- }
- this.ctx!.clearRect(0, 0, this.instructionChartEle!.width, this.instructionChartEle!.height);
- this.instructionChartEle!.width = this.clientWidth;
-
- this.xMaxValue =
- Object.keys(instructions)
- .map((i) => Number(i))
- .reduce((pre, cur) => Math.max(pre, cur), 0) + 10;
- const yMaxValue = Object.values(instructions).reduce(
- // @ts-ignore
- (pre: number, cur: unknown) => Math.max(pre, Number((cur.length / count).toFixed(2))),
- 0
- );
- this.yAvg = Number(((yMaxValue / 5) * 1.5).toFixed(2)) || yMaxValue;
- const height = this.instructionChartEle!.height;
- const width = this.instructionChartEle!.width;
- this.drawLineLabelMarkers(width, height, isCycles);
- this.drawBar(instructions, height, count);
- }
-
- /**
- * 绘制柱状图
- * @param instructionData
- * @param height
- * @param count
- */
- drawBar(instructionData: unknown, height: number, count: number): void {
- const yTotal = Number((this.yAvg * 5).toFixed(2));
- const interval = Math.floor((height - paddingBottom) / 6);
- // @ts-ignore
- for (const x in instructionData) {
- const xNum = Number(x);
- const xPosition = xStep + (xNum / (this.xCount * this.xAvg)) * (this.xCount * this.xSpacing) - barWidth / 2;
- // @ts-ignore
- const yNum = Number((instructionData[x].length / count).toFixed(3));
- const percent = Number((yNum / yTotal).toFixed(2));
- const barHeight = (height - paddingBottom - interval) * percent;
- this.drawRect(xPosition, height - paddingBottom - barHeight, barWidth, barHeight);
- // @ts-ignore
- const existX = this.cacheData.find((i) => i.instruct === x);
- if (!existX) {
- this.cacheData.push({
- instruct: x,
- x: xPosition,
- y: height - paddingBottom - barHeight,
- height: barHeight,
- heightPer: parseFloat((yNum * 100).toFixed(2)),
- });
- } else {
- // @ts-ignore
- existX.x = xPosition;
- }
- }
- }
-
- /**
- * 绘制x y轴
- * @param width
- * @param height
- * @param isCycles
- */
- drawLineLabelMarkers(width: number, height: number, isCycles: boolean) {
- this.ctx!.font = '12px Arial';
- this.ctx!.lineWidth = 1;
- this.ctx!.fillStyle = '#333';
- this.ctx!.strokeStyle = '#ccc';
- if (isCycles) {
- this.ctx!.fillText('cycles数(1e5)', width - paddingLeft + 10, height - paddingBottom);
- } else {
- this.ctx!.fillText('指令数(1e5)', width - paddingLeft + 10, height - paddingBottom);
- }
-
- //绘制x轴
- this.drawLine(xStep, height - paddingBottom, width - paddingLeft, height - paddingBottom);
- //绘制y轴
- this.drawLine(xStep, 5, xStep, height - paddingBottom);
- //绘制标记
- this.drawMarkers(width, height);
- }
-
- /**
- * 绘制横线
- * @param x
- * @param y
- * @param X
- * @param Y
- */
- drawLine(x: number, y: number, X: number, Y: number) {
- this.ctx!.beginPath;
- this.ctx!.moveTo(x, y);
- this.ctx!.lineTo(X, Y);
- this.ctx!.stroke();
- this.ctx!.closePath();
- }
-
- /**
- * 绘制x y轴刻度
- * @param width
- * @param height
- */
- drawMarkers(width: number, height: number) {
- this.xCount = 0;
- //绘制x轴锯齿
- let serrateX = 50;
- let y = height - paddingBottom;
- const clientWidth = width - paddingLeft - 50;
- if (clientWidth > this.xMaxValue) {
- this.xSpacing = Math.floor(clientWidth / 20);
- this.xAvg = Math.ceil(this.xMaxValue / 20);
- } else {
- this.xSpacing = Math.floor(clientWidth / 10);
- this.xAvg = Math.ceil(this.xMaxValue / 10);
- }
- while (serrateX <= clientWidth) {
- this.xCount++;
- serrateX += this.xSpacing;
- this.drawLine(serrateX, y, serrateX, y + 5);
- }
- //绘制x轴刻度
- this.ctx!.textAlign = 'center';
- for (let i = 0; i <= this.xCount; i++) {
- const x = xStep + i * this.xSpacing;
- this.ctx!.fillText(`${i * this.xAvg}`, x, height);
- }
- //绘制y轴刻度
- this.ctx!.textAlign = 'center';
- const yPadding = Math.floor((height - paddingBottom) / 6);
- for (let i = 0; i < 6; i++) {
- if (i === 0) {
- this.ctx!.fillText(`${i}%`, 30, y);
- } else {
- const y = height - paddingBottom - i * yPadding;
- this.drawLine(xStep, y, width - paddingLeft, y);
- this.ctx!.fillText(`${parseFloat((i * this.yAvg).toFixed(2)) * 100}%`, 30, y);
- }
- }
- }
-
- /**
- * 监听页面size变化
- */
- listenerResize(): void {
- new ResizeObserver(
- debounce(() => {
- if (this.instructionChartEle!.getBoundingClientRect()) {
- const box = this.instructionChartEle!.getBoundingClientRect();
- const element = this.parentElement!;
- this.startX = box.left + Math.max(element.scrollLeft, document.body.scrollLeft) - element.clientLeft;
- this.startY =
- box.top + Math.max(element.scrollTop, document.body.scrollTop) - element.clientTop + this.canvasScrollTop;
- this.calInstructionRangeCount(this.isChecked);
- }
- }, 100)
- ).observe(this.parentElement!);
- }
- /**
- * 绘制方块
- * @param x
- * @param y
- * @param X
- * @param Y
- */
- drawRect(x: number, y: number, X: number, Y: number) {
- this.ctx!.beginPath();
- this.ctx!.rect(x, y, X, Y);
- this.ctx!.fill();
- this.ctx!.closePath();
- }
-}
diff --git a/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelection.ts b/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelection.ts
deleted file mode 100644
index 96b91294e..000000000
--- a/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelection.ts
+++ /dev/null
@@ -1,493 +0,0 @@
-/*
- * Copyright (C) 2022 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { BaseElement, element } from '../../../../../base-ui/BaseElement';
-import { SelectionParam } from '../../../../bean/BoxSelection';
-import { Rect, drawString } from '../../../../database/ui-worker/ProcedureWorkerCommon';
-import { ColorUtils } from '../../base/ColorUtils';
-import { SampleStruct } from '../../../../database/ui-worker/ProcedureWorkerBpftrace';
-import { SpApplication } from '../../../../SpApplication';
-
-const SAMPLE_STRUCT_HEIGHT = 30;
-const Y_PADDING = 4;
-
-@element('tab-sample-instruction-selection')
-export class TabPaneSampleInstructionSelection extends BaseElement {
- private instructionEle: HTMLCanvasElement | undefined | null;
- private ctx: CanvasRenderingContext2D | undefined | null;
- private textEle: HTMLSpanElement | undefined | null;
- private instructionArray: Array = [];
- private instructionData: Array = [];
- private isUpdateCanvas = false;
- private canvasX = -1; // 鼠标当前所在画布x坐标
- private canvasY = -1; // 鼠标当前所在画布y坐标
- private startX = 0; // 画布相对于整个界面的x坐标
- private startY = 0; // 画布相对于整个界面的y坐标
- private hintContent = ''; //悬浮框内容
- private floatHint: HTMLDivElement | undefined | null; //悬浮框
- private canvasScrollTop = 0; // tab页上下滚动位置
- private hoverSampleStruct: unknown | undefined;
- private isChecked: boolean = false;
- private maxDepth = 0;
-
- initHtml(): string {
- return `
-
-
- `;
- }
-
- initElements(): void {
- this.instructionEle = this.shadowRoot?.querySelector('#instruct-select-canvas');
- this.textEle = this.shadowRoot?.querySelector('.headline');
- this.ctx = this.instructionEle?.getContext('2d');
- this.floatHint = this.shadowRoot?.querySelector('#select_float_hint');
- }
-
- set data(SampleParam: SelectionParam) {
- this.hoverSampleStruct = undefined;
- this.instructionData = SampleParam.sampleData;
- this.getAvgInstructionData(this.instructionData);
- queueMicrotask(() => {
- this.updateCanvas(this.clientWidth);
- this.drawInstructionData(this.isChecked);
- });
- }
-
- connectedCallback(): void {
- super.connectedCallback();
- this.parentElement!.onscroll = () => {
- this.canvasScrollTop = this.parentElement!.scrollTop;
- this.hideTip();
- };
- this.instructionEle!.onmousemove = (e): void => {
- if (!this.isUpdateCanvas) {
- this.updateCanvasCoord();
- }
- this.canvasX = e.clientX - this.startX;
- this.canvasY = e.clientY - this.startY + this.canvasScrollTop;
- this.onMouseMove();
- };
- this.instructionEle!.onmouseleave = () => {
- this.hideTip();
- };
- document.addEventListener('sample-popver-change', (e: unknown) => {
- // @ts-ignore
- const select = Number(e.detail.select);
- this.hoverSampleStruct = undefined;
- this.isChecked = Boolean(select);
- this.drawInstructionData(this.isChecked);
- });
- this.listenerResize();
- }
-
- /**
- * 初始化窗口大小
- * @param newWidth
- */
- updateCanvas(newWidth?: number): void {
- if (this.instructionEle instanceof HTMLCanvasElement) {
- this.instructionEle.style.width = `${100}%`;
- this.instructionEle.style.height = `${(this.maxDepth + 1) * SAMPLE_STRUCT_HEIGHT}px`;
- if (this.instructionEle.clientWidth === 0 && newWidth) {
- this.instructionEle.width = newWidth;
- } else {
- this.instructionEle.width = this.instructionEle.clientWidth;
- }
- this.instructionEle.height = (this.maxDepth + 1) * SAMPLE_STRUCT_HEIGHT;
- }
- }
-
- /**
- * 鼠标移动
- */
- onMouseMove(): void {
- const lastNode = this.hoverSampleStruct;
- //查找鼠标所在的node
- const searchResult = this.searchDataByCoord(this.instructionArray!, this.canvasX, this.canvasY);
- if (searchResult) {
- this.hoverSampleStruct = searchResult;
- //鼠标悬浮的node未改变则不需重新渲染文字
- if (searchResult !== lastNode) {
- this.updateTipContent();
- this.ctx!.clearRect(0, 0, this.instructionEle!.width, this.instructionEle!.height);
- this.ctx!.beginPath();
- for (const key in this.instructionArray) {
- // @ts-ignore
- for (let i = 0; i < this.instructionArray[key].length; i++) {
- // @ts-ignore
- const cur = this.instructionArray[key][i];
- this.draw(this.ctx!, cur);
- }
- }
- this.ctx!.closePath();
- }
- this.showTip();
- } else {
- this.hideTip();
- this.hoverSampleStruct = undefined;
- }
- }
-
- /**
- * 隐藏悬浮框
- */
- hideTip(): void {
- if (this.floatHint) {
- this.floatHint.style.display = 'none';
- }
- }
-
- /**
- * 显示悬浮框
- */
- showTip(): void {
- this.floatHint!.innerHTML = this.hintContent;
- this.floatHint!.style.display = 'block';
- let x = this.canvasX;
- let y = this.canvasY - this.canvasScrollTop;
- //右边的函数悬浮框显示在左侧
- if (this.canvasX + this.floatHint!.clientWidth > this.instructionEle!.clientWidth || 0) {
- x -= this.floatHint!.clientWidth - 1;
- } else {
- x += 30;
- }
- //最下边的函数悬浮框显示在上方
- y -= this.floatHint!.clientHeight - 1;
- this.floatHint!.style.transform = `translate(${x}px, ${y}px)`;
- }
-
- /**
- * 更新悬浮框内容
- * @returns
- */
- updateTipContent(): void {
- const hoverNode = this.hoverSampleStruct;
- if (!hoverNode) {
- return;
- }
- // @ts-ignore
- this.hintContent = `${hoverNode.detail}(${hoverNode.name})
- ${
- // @ts-ignore
- this.isChecked ? hoverNode.hoverCycles : hoverNode.hoverInstructions}
-
- `;
- }
-
- /**
- * 设置绘制所需的坐标及宽高
- * @param sampleNode
- * @param instructions
- * @param x
- */
- setSampleFrame(sampleNode: SampleStruct, instructions: number, x: number): void {
- if (!sampleNode.frame) {
- sampleNode.frame! = new Rect(0, 0, 0, 0);
- }
- sampleNode.frame!.x = x;
- sampleNode.frame!.y = sampleNode.depth! * SAMPLE_STRUCT_HEIGHT;
- sampleNode.frame!.width = instructions;
- sampleNode.frame!.height = SAMPLE_STRUCT_HEIGHT;
- }
-
- /**
- * 判断鼠标当前在那个函数上
- * @param frame
- * @param x
- * @param y
- * @returns
- */
- isContains(frame: unknown, x: number, y: number): boolean {
- // @ts-ignore
- return x >= frame.x && x <= frame.x + frame.width && frame.y <= y && y <= frame.y + frame.height;
- }
-
- /**
- * 绘制
- * @param isCycles
- */
- drawInstructionData(isCycles: boolean): void {
- this.isChecked ? (this.textEle!.innerText = 'cycles数据流') : (this.textEle!.innerText = 'instructions数据流');
- const clientWidth = this.instructionEle!.width;
- //将数据转换为层级结构
- const instructionArray = this.instructionData
- // @ts-ignore
- .filter((item: unknown) => (isCycles ? item.cycles : item.instructions))
- .reduce((pre: unknown, cur: unknown) => {
- // @ts-ignore
- (pre[`${cur.depth}`] = pre[`${cur.depth}`] || []).push(cur);
- return pre;
- }, {});
- // @ts-ignore
- for (const key in instructionArray) {
- // @ts-ignore
- for (let i = 0; i < instructionArray[key].length; i++) {
- // @ts-ignore
- const cur = instructionArray[key][i];
- //第一级节点直接将宽度设置为容器宽度
- if (key === '0') {
- this.setSampleFrame(cur, clientWidth, 0);
- } else {
- //获取上一层级节点数据
- // @ts-ignore
- const preList = instructionArray[Number(key) - 1];
- //获取当前节点的父节点
- const parentNode = preList.find((node: SampleStruct) => node.name === cur.parentName);
- //计算当前节点下指令数之和 用于计算每个节点所占的宽度比
- const total = isCycles
- // @ts-ignore
- ? instructionArray[key]
- // @ts-ignore
- .filter((i: unknown) => i.parentName === parentNode.name)
- .reduce((pre: number, cur: SampleStruct) => pre + cur.cycles!, 0)
- // @ts-ignore
- : instructionArray[key]
- // @ts-ignore
- .filter((i: unknown) => i.parentName === parentNode.name)
- .reduce((pre: number, cur: SampleStruct) => pre + cur.instructions!, 0);
- const curWidth = isCycles ? cur.cycles : cur.instructions;
- const width = Math.floor(parentNode.frame.width * (curWidth / total));
- if (i === 0) {
- this.setSampleFrame(cur, width, parentNode.frame.x);
- } else {
- // @ts-ignore
- const preNode = instructionArray[key][i - 1];
- preNode.parentName === parentNode.name
- ? this.setSampleFrame(cur, width, preNode.frame.x + preNode.frame.width)
- : this.setSampleFrame(cur, width, parentNode.frame.x);
- }
- }
- }
- }
- // @ts-ignore
- this.instructionArray = instructionArray;
-
- this.ctx!.clearRect(0, 0, this.instructionEle!.width, this.instructionEle!.height);
- this.ctx!.beginPath();
- // @ts-ignore
- for (const key in instructionArray) {
- // @ts-ignore
- for (let i = 0; i < instructionArray[key].length; i++) {
- // @ts-ignore
- const cur = instructionArray[key][i];
- this.draw(this.ctx!, cur);
- }
- }
- this.ctx!.closePath();
- }
-
- /**
- * 更新canvas坐标
- */
- updateCanvasCoord(): void {
- if (this.instructionEle instanceof HTMLCanvasElement) {
- this.isUpdateCanvas = this.instructionEle.clientWidth !== 0;
- if (this.instructionEle.getBoundingClientRect()) {
- const box = this.instructionEle.getBoundingClientRect();
- const D = document.documentElement;
- this.startX = box.left + Math.max(D.scrollLeft, document.body.scrollLeft) - D.clientLeft;
- this.startY = box.top + Math.max(D.scrollTop, document.body.scrollTop) - D.clientTop + this.canvasScrollTop;
- }
- }
- }
-
- /**
- * 获取鼠标悬停的函数
- * @param nodes
- * @param canvasX
- * @param canvasY
- * @returns
- */
- searchDataByCoord(nodes: unknown, canvasX: number, canvasY: number): void | null {
- // @ts-ignore
- for (const key in nodes) {
- // @ts-ignore
- for (let i = 0; i < nodes[key].length; i++) {
- // @ts-ignore
- const cur = nodes[key][i];
- if (this.isContains(cur.frame, canvasX, canvasY)) {
- return cur;
- }
- }
- }
- return null;
- }
-
- /**
- * 绘制方法
- * @param ctx
- * @param data
- */
- draw(ctx: CanvasRenderingContext2D, data: SampleStruct) {
- let spApplication = document.getElementsByTagName('sp-application')[0];
- if (data.frame) {
- ctx.globalAlpha = 1;
- ctx.fillStyle =
- ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.name || '', data.depth!, ColorUtils.FUNC_COLOR.length)];
- const textColor =
- ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.name || '', data.depth!, ColorUtils.FUNC_COLOR.length)];
- ctx.lineWidth = 0.4;
- // @ts-ignore
- if (this.hoverSampleStruct && data.name == this.hoverSampleStruct.name) {
- if (spApplication.dark) {
- ctx.strokeStyle = '#fff';
- } else {
- ctx.strokeStyle = '#000';
- }
- } else {
- if (spApplication.dark) {
- ctx.strokeStyle = '#000';
- } else {
- ctx.strokeStyle = '#fff';
- }
- }
- ctx.strokeRect(data.frame.x, data.frame.y, data.frame.width, SAMPLE_STRUCT_HEIGHT - Y_PADDING);
- ctx.fillRect(data.frame.x, data.frame.y, data.frame.width, SAMPLE_STRUCT_HEIGHT - Y_PADDING);
- ctx.fillStyle = ColorUtils.funcTextColor(textColor);
- drawString(ctx, `${data.detail}(${data.name})`, 5, data.frame, data);
- }
- }
-
- /**
- * 统计框选指令数的平均值
- * @param instructionData
- * @returns
- */
- getAvgInstructionData(instructionData: Array): unknown {
- // @ts-ignore
- const length = instructionData[0].property.length;
- // @ts-ignore
- const knowData = instructionData.filter((instruction) => instruction.name.indexOf('unknown') < 0);
- knowData.forEach((instruction) => {
- // @ts-ignore
- if (instruction.property.length > 0) {
- // @ts-ignore
- const totalInstruction = instruction.property.reduce(
- (pre: number, cur: SampleStruct) => pre + Math.ceil(cur.instructions!),
- 0
- );
- // @ts-ignore
- const totalCycles = instruction.property.reduce(
- (pre: number, cur: SampleStruct) => pre + Math.ceil(cur.cycles!),
- 0
- );
- // @ts-ignore
- instruction.instructions = Math.ceil(totalInstruction / length) || 1;
- // @ts-ignore
- instruction.cycles = Math.ceil(totalCycles / length) || 1;
- // @ts-ignore
- instruction.hoverInstructions = Math.ceil(totalInstruction / length);
- // @ts-ignore
- instruction.hoverCycles = Math.ceil(totalCycles / length);
- // @ts-ignore
- this.maxDepth = Math.max(this.maxDepth, instruction.depth);
- }
- });
- // @ts-ignore
- const unknownData = instructionData.filter((instruction) => instruction.name.indexOf('unknown') > -1);
- let instructionSum = 0;
- let cyclesSum = 0;
- let hoverInstructionsSum = 0;
- let hoverCyclesSum = 0;
- unknownData.forEach((unknown) => {
- instructionSum = 0;
- cyclesSum = 0;
- hoverInstructionsSum = 0;
- hoverCyclesSum = 0;
- // @ts-ignore
- for (const key in unknown.children) {
- // @ts-ignore
- const child = instructionData.find((instruction) => instruction.name === key);
- // @ts-ignore
- instructionSum += child.instructions ?? 0;
- // @ts-ignore
- cyclesSum += child.cycles ?? 0;
- // @ts-ignore
- hoverInstructionsSum += child.hoverInstructions ?? 0;
- // @ts-ignore
- hoverCyclesSum += child.hoverCycles ?? 0;
- }
- // @ts-ignore
- unknown.instructions = instructionSum;
- // @ts-ignore
- unknown.cycles = cyclesSum;
- // @ts-ignore
- unknown.hoverInstructions = hoverInstructionsSum;
- // @ts-ignore
- unknown.hoverCycles = hoverCyclesSum;
- });
- return instructionData;
- }
-
- /**
- * 监听页面size变化
- */
- listenerResize(): void {
- new ResizeObserver(() => {
- if (this.instructionEle!.getBoundingClientRect()) {
- const box = this.instructionEle!.getBoundingClientRect();
- const element = document.documentElement;
- this.startX = box.left + Math.max(element.scrollLeft, document.body.scrollLeft) - element.clientLeft;
- this.startY =
- box.top + Math.max(element.scrollTop, document.body.scrollTop) - element.clientTop + this.canvasScrollTop;
- }
- }).observe(this.parentElement!);
- }
-}
diff --git a/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelectionTotalTime.ts b/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelectionTotalTime.ts
deleted file mode 100644
index 5015f1577..000000000
--- a/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelectionTotalTime.ts
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * Copyright (C) 2022 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { BaseElement, element } from '../../../../../base-ui/BaseElement';
-import { SelectionParam } from '../../../../bean/BoxSelection';
-import { debounce } from '../../../Utils';
-
-const paddingLeft = 100;
-const paddingBottom = 15;
-const xStart = 50; // x轴起始位置
-const barWidth = 2; // 柱子宽度
-const millisecond = 1_000_000;
-
-@element('tab-sample-instructions-totaltime-selection')
-export class TabPaneSampleInstructionTotalTime extends BaseElement {
- private instructionChartEle: HTMLCanvasElement | undefined | null;
- private ctx: CanvasRenderingContext2D | undefined | null;
- private cacheData: Array = [];
- private canvasX = -1; // 鼠标当前所在画布x坐标
- private canvasY = -1; // 鼠标当前所在画布y坐标
- private startX = 0; // 画布相对于整个界面的x坐标
- private startY = 0; // 画布相对于整个界面的y坐标
- private hoverBar: unknown;
- private onReadableData: Array = [];
- private hintContent = ''; //悬浮框内容
- private floatHint: HTMLDivElement | undefined | null; //悬浮框
- private canvasScrollTop = 0; // tab页上下滚动位置
- private isUpdateCanvas = false;
- private xCount = 0; //x轴刻度个数
- private xMaxValue = 0; //x轴上数据最大值
- private xSpacing = 50; //x轴间距
- private xAvg = 0; //根据xMaxValue进行划分 用于x轴上刻度显示
- private yAvg = 0; //根据yMaxValue进行划分 用于y轴上刻度显示
-
- initHtml(): string {
- return `
-
-
-
- `;
- }
-
- initElements(): void {
- this.instructionChartEle = this.shadowRoot?.querySelector('#instruct-chart-canvas');
- this.ctx = this.instructionChartEle?.getContext('2d');
- this.floatHint = this.shadowRoot?.querySelector('#float_hint');
- }
-
- set data(SampleParam: SelectionParam) {
- // @ts-ignore
- this.onReadableData = SampleParam.sampleData[0].property;
- this.calInstructionRangeCount();
- }
-
- connectedCallback(): void {
- super.connectedCallback();
- this.parentElement!.onscroll = () => {
- this.canvasScrollTop = this.parentElement!.scrollTop;
- this.hideTip();
- };
- this.instructionChartEle!.onmousemove = (e): void => {
- if (!this.isUpdateCanvas) {
- this.updateCanvasCoord();
- }
- this.canvasX = e.clientX - this.startX;
- this.canvasY = e.clientY - this.startY + this.canvasScrollTop;
- this.onMouseMove();
- };
- this.instructionChartEle!.onmouseleave = () => {
- this.hideTip();
- };
- this.listenerResize();
- }
-
- /**
- * 更新canvas坐标
- */
- updateCanvasCoord(): void {
- if (this.instructionChartEle instanceof HTMLCanvasElement) {
- this.isUpdateCanvas = this.instructionChartEle.clientWidth !== 0;
- if (this.instructionChartEle.getBoundingClientRect()) {
- const box = this.instructionChartEle.getBoundingClientRect();
- const D = this.parentElement!;
- this.startX = box.left + Math.max(D.scrollLeft, document.body.scrollLeft) - D.clientLeft;
- this.startY = box.top + Math.max(D.scrollTop, document.body.scrollTop) - D.clientTop + this.canvasScrollTop;
- }
- }
- }
-
- /**
- * 获取鼠标悬停的函数
- * @param nodes
- * @param canvasX
- * @param canvasY
- * @returns
- */
- searchDataByCoord(nodes: unknown, canvasX: number, canvasY: number):unknown {
- // @ts-ignore
- for (let i = 0; i < nodes.length; i++) {
- // @ts-ignore
- const element = nodes[i];
- if (this.isContains(element, canvasX, canvasY)) {
- return element;
- }
- }
- return null;
- }
-
- /**
- * 鼠标移动
- */
- onMouseMove(): void {
- const lastNode = this.hoverBar;
- //查找鼠标所在的node
- const searchResult = this.searchDataByCoord(this.cacheData, this.canvasX, this.canvasY);
- if (searchResult) {
- this.hoverBar = searchResult;
- //鼠标悬浮的node未改变则不需重新渲染文字
- if (searchResult !== lastNode) {
- this.updateTipContent();
- }
- this.showTip();
- } else {
- this.hideTip();
- this.hoverBar = undefined;
- }
- }
-
- /**
- * 隐藏悬浮框
- */
- hideTip(): void {
- if (this.floatHint) {
- this.floatHint.style.display = 'none';
- this.instructionChartEle!.style.cursor = 'default';
- }
- }
-
- /**
- * 显示悬浮框
- */
- showTip(): void {
- this.floatHint!.innerHTML = this.hintContent;
- this.floatHint!.style.display = 'block';
- this.instructionChartEle!.style.cursor = 'pointer';
- let x = this.canvasX;
- let y = this.canvasY - this.canvasScrollTop;
- //右边的函数悬浮框显示在左侧
- if (this.canvasX + this.floatHint!.clientWidth > (this.instructionChartEle!.clientWidth || 0)) {
- x -= this.floatHint!.clientWidth - 1;
- } else {
- x += 30;
- }
- //最下边的函数悬浮框显示在上方
- y -= this.floatHint!.clientHeight - 1;
- this.floatHint!.style.transform = `translate(${x}px, ${y}px)`;
- }
-
- /**
- * 更新悬浮框内容
- */
- updateTipContent(): void {
- const hoverNode = this.hoverBar;
- if (!hoverNode) {
- return;
- }
- const detail = hoverNode!;
- // @ts-ignore
- this.hintContent = ` ${detail.instruct}${parseFloat(
- // @ts-ignore
- detail.heightPer
- )} `;
- }
-
- /**
- * 判断鼠标当前在那个函数上
- * @param frame
- * @param x
- * @param y
- * @returns
- */
- isContains(point: unknown, x: number, y: number): boolean {
- // @ts-ignore
- return x >= point.x && x <= point.x + 2 && point.y <= y && y <= point.y + point.height;
- }
-
- /**
- * 统计onReadable数据各指令数个数
- */
- calInstructionRangeCount() {
- if (this.onReadableData.length === 0) return;
- this.cacheData.length = 0;
- const count = this.onReadableData.length;
- const onReadableData = this.onReadableData;
- const instructionArray = onReadableData.reduce((pre: unknown, current: unknown) => {
- // @ts-ignore
- const dur = parseFloat(((current.end - current.begin) / millisecond).toFixed(1));
- // @ts-ignore
- (pre[dur] = pre[dur] || []).push(current);
- return pre;
- }, {});
- this.ctx!.clearRect(0, 0, this.instructionChartEle!.width, this.instructionChartEle!.height);
- this.instructionChartEle!.width = this.clientWidth;
-
- this.xMaxValue =
- // @ts-ignore
- Object.keys(instructionArray)
- .map((i) => Number(i))
- .reduce((pre, cur) => Math.max(pre, cur), 0) + 5; // @ts-ignore
- const yMaxValue = Object.values(instructionArray).reduce(
- // @ts-ignore
- (pre: number, cur: unknown) => Math.max(pre, Number((cur.length / count).toFixed(2))),
- 0
- );
- this.yAvg = Number(((yMaxValue / 5) * 1.5).toFixed(2));
- const height = this.instructionChartEle!.height;
- const width = this.instructionChartEle!.width;
- this.drawLineLabelMarkers(width, height);
- this.drawBar(instructionArray, height, count);
- }
-
- /**
- * 绘制柱状图
- * @param instructionData
- * @param height
- * @param count
- */
- drawBar(instructionData: unknown, height: number, count: number): void {
- const yTotal = Number((this.yAvg * 5).toFixed(2));
- const interval = Math.floor((height - paddingBottom) / 6); // @ts-ignore
- for (const x in instructionData) {
- const xNum = Number(x);
- const xPosition = xStart + (xNum / (this.xCount * this.xAvg)) * (this.xCount * this.xSpacing) - barWidth / 2; // @ts-ignore
- const yNum = Number((instructionData[x].length / count).toFixed(3));
- const percent = Number((yNum / yTotal).toFixed(2));
- const barHeight = (height - paddingBottom - interval) * percent;
- this.drawRect(xPosition, height - paddingBottom - barHeight, barWidth, barHeight); // @ts-ignore
- const existX = this.cacheData.find((i) => i.instruct === x);
- if (!existX) {
- this.cacheData.push({
- instruct: x,
- x: xPosition,
- y: height - paddingBottom - barHeight,
- height: barHeight,
- heightPer: parseFloat((yNum * 100).toFixed(2)),
- });
- } else {
- // @ts-ignore
- existX.x = xPosition;
- }
- }
- }
-
- /**
- * 绘制x y轴
- * @param width
- * @param height
- */
- drawLineLabelMarkers(width: number, height: number) {
- this.ctx!.font = '12px Arial';
- this.ctx!.lineWidth = 1;
- this.ctx!.fillStyle = '#333';
- this.ctx!.strokeStyle = '#ccc';
-
- this.ctx!.fillText('时长 / ms', width - paddingLeft, height - paddingBottom);
-
- //绘制x轴
- this.drawLine(xStart, height - paddingBottom, width - paddingLeft, height - paddingBottom);
- //绘制y轴
- this.drawLine(xStart, 5, xStart, height - paddingBottom);
- //绘制标记
- this.drawMarkers(width, height);
- }
-
- /**
- * 绘制横线
- * @param x
- * @param y
- * @param X
- * @param Y
- */
- drawLine(x: number, y: number, X: number, Y: number) {
- this.ctx!.beginPath;
- this.ctx!.moveTo(x, y);
- this.ctx!.lineTo(X, Y);
- this.ctx!.stroke();
- this.ctx!.closePath();
- }
-
- /**
- * 绘制x y轴刻度
- * @param width
- * @param height
- */
- drawMarkers(width: number, height: number) {
- this.xCount = 0;
- //绘制x轴锯齿
- let serrateX = 50;
- let yHeight = height - paddingBottom;
- const clientWidth = width - paddingLeft - 50;
- if (clientWidth > this.xMaxValue) {
- this.xSpacing = Math.floor(clientWidth / 20);
- this.xAvg = Math.ceil(this.xMaxValue / 20);
- } else {
- this.xSpacing = Math.floor(clientWidth / 10);
- this.xAvg = Math.ceil(this.xMaxValue / 10);
- }
- while (serrateX <= clientWidth) {
- this.xCount++;
- serrateX += this.xSpacing;
- this.drawLine(serrateX, yHeight, serrateX, yHeight + 5);
- }
- //绘制x轴刻度
- this.ctx!.textAlign = 'center';
- for (let i = 0; i <= this.xCount; i++) {
- const x = xStart + i * this.xSpacing;
- this.ctx!.fillText(`${i * this.xAvg}`, x, height);
- }
- //绘制y轴刻度
- this.ctx!.textAlign = 'center';
- const yPadding = Math.floor((height - paddingBottom) / 6);
- for (let i = 0; i < 6; i++) {
- const y = height - paddingBottom - i * yPadding;
- if (i === 0) {
- this.ctx!.fillText(`${i}%`, 30, y);
- } else {
- this.drawLine(xStart, y, width - paddingLeft, y);
- this.ctx!.fillText(`${parseFloat((i * this.yAvg).toFixed(2)) * 100}%`, 30, y);
- }
- }
- }
-
- /**
- * 监听页面size变化
- */
- listenerResize(): void {
- new ResizeObserver(
- debounce(() => {
- if (this.instructionChartEle!.getBoundingClientRect()) {
- const box = this.instructionChartEle!.getBoundingClientRect();
- const element = this.parentElement!;
- this.startX = box.left + Math.max(element.scrollLeft, document.body.scrollLeft) - element.clientLeft;
- this.startY =
- box.top + Math.max(element.scrollTop, document.body.scrollTop) - element.clientTop + this.canvasScrollTop;
- this.calInstructionRangeCount();
- }
- }, 100)
- ).observe(this.parentElement!);
- }
- /**
- * 绘制方块
- * @param x
- * @param y
- * @param X
- * @param Y
- */
- drawRect(x: number, y: number, X: number, Y: number) {
- this.ctx!.beginPath();
- this.ctx!.rect(x, y, X, Y);
- this.ctx!.fill();
- this.ctx!.closePath();
- }
-}
--
Gitee
From 50b837c8fe20d2d6fff3e5a9eb428e5732905619 Mon Sep 17 00:00:00 2001
From: wangyujie
Date: Mon, 18 Nov 2024 14:08:30 +0800
Subject: [PATCH 03/38] =?UTF-8?q?feat:slice=E9=A1=B5=E6=96=B0=E5=A2=9Eself?=
=?UTF-8?q?time?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: wangyujie
---
ide/src/trace/bean/BoxSelection.ts | 1 +
.../trace/sheet/process/TabPaneSliceChild.ts | 38 +++++++++-
.../trace/sheet/process/TabPaneSlices.ts | 41 ++++++++++-
ide/src/trace/database/sql/Func.sql.ts | 71 +++++++++++++++++++
.../trace/database/sql/ProcessThread.sql.ts | 1 +
5 files changed, 148 insertions(+), 4 deletions(-)
diff --git a/ide/src/trace/bean/BoxSelection.ts b/ide/src/trace/bean/BoxSelection.ts
index c0509abc1..f4ae309f8 100644
--- a/ide/src/trace/bean/BoxSelection.ts
+++ b/ide/src/trace/bean/BoxSelection.ts
@@ -1346,6 +1346,7 @@ export class SelectionData {
maxDuration: number = 0;
maxDurationFormat: string = '';
occurrences: number = 0;
+ selfTime: number = 0;
state: string = '';
trackId: number = 0;
delta: string = '';
diff --git a/ide/src/trace/component/trace/sheet/process/TabPaneSliceChild.ts b/ide/src/trace/component/trace/sheet/process/TabPaneSliceChild.ts
index 1e3cdfa83..65b1ddcdf 100644
--- a/ide/src/trace/component/trace/sheet/process/TabPaneSliceChild.ts
+++ b/ide/src/trace/component/trace/sheet/process/TabPaneSliceChild.ts
@@ -18,7 +18,7 @@ import { LitTable } from '../../../../../base-ui/table/lit-table';
import { SelectionData, SelectionParam, SliceBoxJumpParam } from '../../../../bean/BoxSelection';
import { Utils } from '../../base/Utils';
import { resizeObserver } from '../SheetUtils';
-import { getTabDetails, getGhDetails, getSfDetails } from '../../../../database/sql/Func.sql';
+import { getTabDetails, getGhDetails, getSfDetails, getParentDetail, getFuncChildren } from '../../../../database/sql/Func.sql';
@element('box-slice-child')
export class TabPaneSliceChild extends BaseElement {
@@ -120,14 +120,46 @@ export class TabPaneSliceChild extends BaseElement {
return promises;
};
this.sliceChildTbl!.loading = true;
- Promise.all([result1(), result2(), result3()]).then(res => {
+ Promise.all([result1(), result2(), result3()]).then(async res => {
this.sliceChildTbl!.loading = false;
let result: unknown = (res[0] || []).concat(res[1] || []).concat(res[2] || []);
this.sliceChildTbl!.loading = false;
// @ts-ignore
if (result.length !== null && result.length > 0) {
+ let funcIdArr: Array = [];
+ let minStartTS = Infinity;
+ let maxEndTS = -Infinity;
+ // @ts-ignore
+ let parentDetail: [{ startTS: number, endTS: number, depth: number, id: number, name: string }] = await getParentDetail(val.param.processId, val.param.threadId, val.param.leftNs, val.param.rightNs);
+
+ // @ts-ignore
+ parentDetail.forEach(item => {
+ funcIdArr.push(item.id);
+ if (item.depth === 0) {
+ if (item.startTS < minStartTS) {
+ minStartTS = item.startTS;
+ }
+ if (item.endTS > maxEndTS) {
+ maxEndTS = item.endTS;
+ }
+ }
+ });
+
+ let FuncChildrenList = await getFuncChildren(funcIdArr, val.param.processId, val.param.threadId, minStartTS, maxEndTS, true);
+ let childDurMap = new Map();
+ FuncChildrenList.forEach((it: any) => {
+ if (!childDurMap.has(it.parentId)) {
+ childDurMap.set(it.parentId, it.duration);
+ } else {
+ let dur = childDurMap.get(it.parentId)
+ dur += it.duration
+ childDurMap.set(it.parentId, dur!);
+ }
+ });
// @ts-ignore
result.map((e: unknown) => {
+ // @ts-ignore
+ e.selfTime = childDurMap.has(e.id) ? (e.duration - childDurMap.get(e.id)) / 1000000 : e.duration / 1000000;
// @ts-ignore
e.startTime = Utils.getTimeString(e.startNs);
// @ts-ignore
@@ -179,6 +211,8 @@ export class TabPaneSliceChild extends BaseElement {
+
+
`;
}
diff --git a/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts b/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts
index 49509b0b0..6edab339c 100644
--- a/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts
+++ b/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts
@@ -20,7 +20,7 @@ import { SpSystemTrace } from '../../../SpSystemTrace';
import { TraceRow } from '../../base/TraceRow';
import { LitSearch } from '../../search/Search';
import { resizeObserver } from '../SheetUtils';
-import { getTabSlicesAsyncFunc, getTabSlicesAsyncCatFunc } from '../../../../database/sql/Func.sql';
+import { getTabSlicesAsyncFunc, getTabSlicesAsyncCatFunc, getParentDetail, getFuncChildren } from '../../../../database/sql/Func.sql';
import { getTabSlices } from '../../../../database/sql/ProcessThread.sql';
import { FuncStruct } from '../../../../database/ui-worker/ProcedureWorkerFunc';
import { Utils } from '../../base/Utils';
@@ -147,13 +147,45 @@ export class TabPaneSlices extends BaseElement {
};
this.slicesTbl!.loading = true;
- Promise.all([result1(), result2(), result3()]).then(res => {
+ Promise.all([result1(), result2(), result3()]).then(async res => {
let processSlicesResult = (res[0] || []).concat(res[1] || []).concat(res[2] || []);
if (processSlicesResult !== null && processSlicesResult.length > 0) {
+ let funcIdArr: Array = [];
+ let minStartTS = Infinity;
+ let maxEndTS = -Infinity;
+ // @ts-ignore
+ let parentDetail: [{ startTS: number, endTS: number, depth: number, id: number, name: string }] = await getParentDetail(slicesParam.processIds, slicesParam.funTids, slicesParam.leftNs, slicesParam.rightNs);
+ // @ts-ignore
+ parentDetail.forEach(item => {
+ funcIdArr.push(item.id);
+ if (item.depth === 0) {
+ if (item.startTS < minStartTS) {
+ minStartTS = item.startTS;
+ }
+ if (item.endTS > maxEndTS) {
+ maxEndTS = item.endTS;
+ }
+ }
+ });
+
+ let FuncChildrenList = await getFuncChildren(funcIdArr, slicesParam.processIds, slicesParam.funTids, minStartTS, maxEndTS, false);
+ let childDurMap: Map> = new Map();
+ FuncChildrenList.forEach((it: any) => {
+ if (!childDurMap.has(it.parentId)) {
+ childDurMap.set(it.parentId, it.duration);
+ } else {
+ let dur = childDurMap.get(it.parentId)
+ dur += it.duration
+ childDurMap.set(it.parentId, dur!);
+ }
+ });
let sumWall = 0.0;
let sumOcc = 0;
+ let sumSelf = 0.0;
let processSlicesResultMap: Map = new Map();
for (let processSliceItem of processSlicesResult) {
+ //@ts-ignore
+ processSliceItem.selfTime = childDurMap.has(processSliceItem.id) ? parseFloat(((processSliceItem.wallDuration - childDurMap.get(processSliceItem.id)) / 1000000).toFixed(5)) : parseFloat((processSliceItem.wallDuration / 1000000).toFixed(5));
//@ts-ignore
processSliceItem.name = processSliceItem.name === null ? '' : processSliceItem.name;
//@ts-ignore
@@ -161,6 +193,8 @@ export class TabPaneSlices extends BaseElement {
//@ts-ignore
sumOcc += processSliceItem.occurrences;
//@ts-ignore
+ sumSelf += processSliceItem.selfTime;
+ //@ts-ignore
processSliceItem.wallDuration = parseFloat((processSliceItem.wallDuration / 1000000.0).toFixed(5));
//@ts-ignore
if (processSlicesResultMap.has(processSliceItem.name)) {//@ts-ignore
@@ -185,6 +219,7 @@ export class TabPaneSlices extends BaseElement {
count.process = ' ';
count.wallDuration = parseFloat((sumWall / 1000000.0).toFixed(5));
count.occurrences = sumOcc;
+ count.selfTime = parseFloat(sumSelf.toFixed(5));
count.tabTitle = 'Summary';
// @ts-ignore
count.allName = processSlicesResultsValue.map((item: unknown) => item.name);
@@ -337,6 +372,8 @@ export class TabPaneSlices extends BaseElement {
+
+
`;
}
diff --git a/ide/src/trace/database/sql/Func.sql.ts b/ide/src/trace/database/sql/Func.sql.ts
index f2a47dc58..eeaba5ff9 100644
--- a/ide/src/trace/database/sql/Func.sql.ts
+++ b/ide/src/trace/database/sql/Func.sql.ts
@@ -326,6 +326,7 @@ export const getTabSlicesAsyncFunc = (
let sql = `
SELECT
c.name AS name,
+ c.id,
sum( c.dur ) AS wallDuration,
count( c.name ) AS occurrences
FROM
@@ -368,6 +369,7 @@ export const getTabDetails = (
SELECT
c.name AS name,
c.dur AS duration,
+ c.id,
P.pid AS processId,
P.name AS process,
A.tid AS threadId,
@@ -408,6 +410,7 @@ export const getSfDetails = (
P.name AS process,
A.tid AS threadId,
A.name AS thread,
+ c.id,
c.ts - D.start_ts as startNs
FROM
(SELECT id, ts, parent_id, dur, name from callstack where cookie NOT NULL) C,
@@ -423,6 +426,73 @@ export const getSfDetails = (
`;
return query('getSfDetails', sql, {});
};
+export const getParentDetail = (
+ asyncPid: Array,
+ funTids: Array,
+ leftNS: number,
+ rightNS: number):
+ Promise> =>
+ query(
+ 'getParentTime',
+ ` SELECT
+ C.ts - D.start_ts AS startTS,
+ C.ts - D.start_ts + C.dur AS endTS,
+ C.depth,
+ c.id,
+ c.name
+ FROM
+ thread A
+ JOIN trace_range D
+ LEFT JOIN process P ON P.id = A.ipid
+ LEFT JOIN callstack C ON A.id = C.callid
+ WHERE
+ C.ts > 0
+ AND C.dur >= - 1
+ AND NOT (
+ ( C.ts - D.start_ts + C.dur < ${leftNS} )
+ OR ( C.ts - D.start_ts > ${rightNS} )
+ )
+ AND C.cookie IS NULL
+ AND A.tid IN (${funTids!.join(',')})
+ AND P.pid IN (${asyncPid.join(',')})
+ `
+ );
+export const getFuncChildren = (
+ funcIds: Array,
+ asyncPid: Array,
+ funTids: Array,
+ leftNS: number,
+ rightNS: number,
+ isChild: boolean
+): //@ts-ignore
+ Promise> => {
+ let durStr = isChild ? 'C.dur AS duration,' : 'SUM(COALESCE(C.dur, 0)) AS duration,';
+ let condition = isChild ? '' : 'group by parentName';
+ let sql = `
+ SELECT
+ c.parent_id parentId,
+ ${durStr}
+ c.id,
+ c.name,
+ c1.name parentName
+ FROM
+ thread A,trace_range D
+ LEFT JOIN process P ON P.id = A.ipid
+ LEFT JOIN callstack C ON A.id = C.callid
+ LEFT JOIN callstack C1 ON c.parent_id = C1.id
+ where
+ C.ts > 0
+ and
+ c.dur >= -1
+ and
+ not ((C.ts - D.start_ts + C.dur < ${leftNS}) or (C.ts - D.start_ts > ${rightNS}))
+ and A.tid in (${funTids!.join(',')})
+ and c.cookie is null
+ and P.pid in (${asyncPid.join(',')})
+ and c.parent_id in (${funcIds.join(',')})${condition}
+ `;
+ return query('getTabDetails', sql, {});
+};
export const getGhDetails = (
asyncNames: Array,
catName: string,
@@ -476,6 +546,7 @@ export const getTabSlicesAsyncCatFunc = (
`
select
c.name as name,
+ c.id,
sum(c.dur) as wallDuration,
count(c.name) as occurrences
from
diff --git a/ide/src/trace/database/sql/ProcessThread.sql.ts b/ide/src/trace/database/sql/ProcessThread.sql.ts
index 1fa345fe3..40812eabc 100644
--- a/ide/src/trace/database/sql/ProcessThread.sql.ts
+++ b/ide/src/trace/database/sql/ProcessThread.sql.ts
@@ -1215,6 +1215,7 @@ export const getTabSlices = (
`
select
c.name as name,
+ c.id,
sum(c.dur) as wallDuration,
count(c.name) as occurrences
from
--
Gitee
From 51bdd3b33887b19be8a540dcb03fbde9b0ea0617 Mon Sep 17 00:00:00 2001
From: liufei
Date: Tue, 19 Nov 2024 10:02:22 +0800
Subject: [PATCH 04/38] =?UTF-8?q?feat:=E9=85=8D=E7=BD=AEtrace=E7=82=B9?=
=?UTF-8?q?=E8=AF=A6=E6=83=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: liufei
---
ide/src/doc/funDetail.json | 384 +++++++++++++++++++++++++++++++++++--
1 file changed, 372 insertions(+), 12 deletions(-)
diff --git a/ide/src/doc/funDetail.json b/ide/src/doc/funDetail.json
index e9a08eb4d..9f8b36213 100644
--- a/ide/src/doc/funDetail.json
+++ b/ide/src/doc/funDetail.json
@@ -31,12 +31,6 @@
"EN": "this is an english translate for CN",
"flag": "0"
},
- {
- "slice": "FlushLayoutTask",
- "CN": "组件的布局,这一块可以确认是什么组件在创建或者复用",
- "EN": "this is an english translate for CN",
- "flag": "0"
- },
{
"slice": "CreateTaskMeasure",
"CN": "组件的测量。这一块可以确认是什么组件在创建",
@@ -49,12 +43,6 @@
"EN": "this is an english translate for CN",
"flag": "0"
},
- {
- "slice": "JSAnimation",
- "CN": "如果FlushVsync下面出现这个trace点,说明触发了ArkUI的动效,例如使用了属性动画animation属性或者显示动画animateTo。可以排查一下代码看一下这种场景是否需要触发这个动画,有时候会因为组件的刷新而出现该动画的冗余绘制",
- "EN": "this is an english translate for CN",
- "flag": "0"
- },
{
"slice": "BuildRecyle",
"CN": "如果出现这个trace说明,这个组件是走复用逻辑的。当前如果组件节点较多,也会导致组件复用的时候耗时比较长导致丢帧。",
@@ -186,6 +174,378 @@
"CN": "触发了shader编译,需要通过与之shader来避免。shader缓存是业界通用方案,在动效前几次执行的时候会概率性出现,用于创建该场景的着色器并将其缓存,以使之后的操作可以直接复用原有的着丝琪,从而提升系统的性能。但shader编译耗时太长导致RS侧丢帧造成动效卡顿",
"EN": "this is an english translate for CN",
"flag": "0"
+ },
+ {
+ "slice": "OnVsyncEvent now",
+ "CN": "收到Vsync信号,渲染流程开始(框架trace,)不用验证",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "UITaskScheduler::FlushTask",
+ "CN": "刷新UI界面,包括布局、渲染和动画等(框架trace,不用验证)",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "FlushMessages",
+ "CN": "发送消息通知图形侧进行渲染(框架trace,不用验证)",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "FlushRenderTask",
+ "CN": "总渲染任务执行(框架trace,不用验证)",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Layout",
+ "CN": "节点布局(框架trace,不用验证)",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "FrameNode::RenderTask",
+ "CN": "单个渲染任务执行(框架trace,不用验证)",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ListLayoutAlgorithm::MeasureListItem:",
+ "CN": "计算列表项的布局尺寸",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ListLayoutAlgorithm::MeasureListItemGroup:",
+ "CN": "计算列表ListItemGroup项的布局尺寸",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "HandleDragStart, id:",
+ "CN": "拖拽开始",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "HandleDragUpdate, mainDelta",
+ "CN": "拖拽中",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "HandleDragEnd, mainPosition:",
+ "CN": "拖拽结束",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Scrollable friction animation start,",
+ "CN": "抛滑动画开始",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Scrollable friction animation finish, id:",
+ "CN": "抛滑动画结束",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "StopFrictionAnimation, id:",
+ "CN": "关闭抛滑动画",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Scrollable spring animation start, start:",
+ "CN": "过界回弹动画开始",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Scrollable spring animation finish, id:",
+ "CN": "过界回弹动画结束",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Scrollable spring animation update, start:",
+ "CN": "更新过界回弹动画开始",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "StopSpringAnimation, id:",
+ "CN": "关闭过界回弹动画",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Scroll snap animation start, start:",
+ "CN": "Scroll的限位动画开始",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Scroll snap animation finish, id:",
+ "CN": "Scroll的限位动画结束",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "List start snap animation, start:",
+ "CN": "List的限位动画开始",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "List snap animation finish, id:",
+ "CN": "List的限位动画结束",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "StopSnapAnimation isSnapAnimationStop_:",
+ "CN": "关闭限位动画",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "APP_LIST_FLING",
+ "CN": "滑动阶段(包括所有的拖拽,抛滑、回弹、滚动控制器动画)",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "TRAILING_ANIMATION id:",
+ "CN": "动画的拖尾阶段",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "HandleTouchDown, panDirection:",
+ "CN": "手指按下",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "HandleTouchUp, isDragging_:",
+ "CN": "手指抬起(新增)",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "HandleTouchCancel, id:",
+ "CN": "取消手势",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ScrollAbort, no OnScrollStart, id:",
+ "CN": "ScrollAbort为true,触发OnScrollStart失败,(一般出现在抛滑后调用滚动控制器启动滚动动画)",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "OnScrollStart, id:",
+ "CN": "触发OnScrollStart成功",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ScrollAbort, no OnScrollStop, id:",
+ "CN": "ScrollAbort为true,触发OnScrollStop失败(一般出现在抛滑后调用滚动控制器启动滚动动画)",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "OnScrollStop, id:",
+ "CN": "触发OnScrollStop成功",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ScrollBy, offset:",
+ "CN": "滚动控制器触发ScrollBy",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ScrollTo with animation, position:",
+ "CN": "滚动控制器触发带动画的ScrollTo",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ScrollTo without animation, position:",
+ "CN": "滚动控制器触发不带动画的ScrollTo",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ScrollPage with animation, position",
+ "CN": "滚动控制器触发带动画的Scrollpage",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ScrollPage without animation, position:",
+ "CN": "滚动控制器触发不带动画的Scrollpage",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Fling, flingVelocity:",
+ "CN": "滚动控制器触发惯性滚动",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Scroll ScrollToEdge scrollEdgeType:",
+ "CN": "Scroll触发ScrollEdge",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ScrollToEdge scrollEdgeType:",
+ "CN": "滚动控制器触发的ScrollEdge",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ScrollToIndex, index:",
+ "CN": "滚动控制器触发ScrollToIndex",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "CUSTOM_ANIMATOR_SCROLLER_ANIMATION",
+ "CN": "滚动控制器触发ScrollTo滑动动画",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "HandleScroll, initOffset:",
+ "CN": "嵌套滚动处理偏移量",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "HandleScrollVelocity, IsOutOfBoundary:",
+ "CN": "嵌套滚动中处理离手速度",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "HandleOverScroll, IsOutOfBoundary:",
+ "CN": "离手时处理过界滚动",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "SCROLLER_FIX_VELOCITY_ANIMATION",
+ "CN": "控制器触发按固定速度滚动到边缘",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "CheckRestartSpring, sizeDiminished is true, do ProcessSpringUpdate, id:",
+ "CN": "回弹动画期间组件大小被修改导致触发回弹更新动画",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "CheckRestartSpring, do ProcessScrollOver, id:",
+ "CN": "在静态场景下因组件大小修改原因导致组件处于过界状态,触发回弹动画恢复到未过界状态",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ListItemGroup:",
+ "CN": "设置lane的ListItemGroup列表布局",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "ListItem:",
+ "CN": "设置lane的列表布局",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "change direction in spring animation and start fling animation, distance::",
+ "CN": "过界回弹动效中出现方向改变,并启动抛滑动效",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "scrollPause set true to stop ProcessScrollMotion, canOverScroll:",
+ "CN": "抛滑动效期间达成停止条件从而关闭抛滑动效,并触发结束回调(一般出现在快速抛滑过界的场景)",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Tabs.onChange index ",
+ "CN": "tabs页面切换后",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Tabs/Swiper drag start",
+ "CN": "跟手拖拽开始",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Tabs/Swiper drag end",
+ "CN": "跟手拖拽结束",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Tabs/Swiper start property animation, X:",
+ "CN": "属性动画开始",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Tabs/Swiper finish property animation, X: ",
+ "CN": "属性动画结束",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Tabs/Swiper start spring animation",
+ "CN": "回弹动画开始",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Tabs/Swiper finish spring animation, offset:",
+ "CN": "回弹动画结束",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Tabs/Swiper start translate animation",
+ "CN": "自定义属性动画开始",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "Tabs/Swiper finish translate animation",
+ "CN": "自定义属性动画结束",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
+ },
+ {
+ "slice": "FlushVsync",
+ "CN": "刷新视图同步事件,包括记录帧信息、刷新任务、绘制渲染上下文、处理用户输入",
+ "EN": "this is an english translate for CN",
+ "flag": "0"
}
]
}
\ No newline at end of file
--
Gitee
From b2af125fd7fef3e2ab567d2dfd3169d4e14420b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=9B=86=E5=B7=9D?=
Date: Wed, 20 Nov 2024 11:44:24 +0800
Subject: [PATCH 05/38] =?UTF-8?q?bugfix:=20WaitForParserEnd()=E5=9C=A8=5FT?=
=?UTF-8?q?raceStreamerParseDataEx=E5=92=8C=5FTraceStreamerInParseDataOver?=
=?UTF-8?q?=E9=83=BD=E6=9C=89=E8=B0=83=E7=94=A8,=20=E6=B8=85=E7=90=86?=
=?UTF-8?q?=E4=B8=80=E4=B8=AA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: 集川
---
ide/webpack.config.js | 2 +-
trace_streamer/src/rpc/rpc_server.cpp | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/ide/webpack.config.js b/ide/webpack.config.js
index 05f6d5aa4..955e330d8 100644
--- a/ide/webpack.config.js
+++ b/ide/webpack.config.js
@@ -89,7 +89,7 @@ function buildMultiPlatform() {
path.normalize(path.join(outPath, '/', `main.exe`)) :
path.normalize(path.join(outPath, '/', `main_${platform}`));
setEnv = '';
- if (os.type() === "Windows_NT") {
+ if (os.type() === 'Windows_NT') {
setEnv += `SET CGO_ENABLED=0&&SET GOOS=${platform}&&SET GOARCH=amd64&&`;
} else {
setEnv += `CGO_ENABLED=0 GOOS=${platform} GOARCH=amd64`;
diff --git a/trace_streamer/src/rpc/rpc_server.cpp b/trace_streamer/src/rpc/rpc_server.cpp
index 396aa27c4..c999fd5de 100644
--- a/trace_streamer/src/rpc/rpc_server.cpp
+++ b/trace_streamer/src/rpc/rpc_server.cpp
@@ -179,7 +179,6 @@ bool RpcServer::ReadAndParseData(const std::string &filePath)
break;
}
}
- ts_->WaitForParserEnd();
inputFile.close();
return true;
}
--
Gitee
From 8c5a487f3fd934ecd2e2e067f21df270674a74ef Mon Sep 17 00:00:00 2001
From: zhangyan
Date: Thu, 21 Nov 2024 09:44:09 +0800
Subject: [PATCH 06/38] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96ai=E8=AF=8A?=
=?UTF-8?q?=E6=96=AD=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: zhangyan
---
.../trace/component/SpAiAnalysisPage.html.ts | 4 +-
ide/src/trace/component/SpAiAnalysisPage.ts | 61 +++--
ide/src/webSocket/Constants.ts | 4 +
ide/src/webSocket/WebSocketManager.ts | 218 +++++++++++++-----
4 files changed, 210 insertions(+), 77 deletions(-)
diff --git a/ide/src/trace/component/SpAiAnalysisPage.html.ts b/ide/src/trace/component/SpAiAnalysisPage.html.ts
index de484aaff..ef10bdd7c 100644
--- a/ide/src/trace/component/SpAiAnalysisPage.html.ts
+++ b/ide/src/trace/component/SpAiAnalysisPage.html.ts
@@ -135,11 +135,11 @@ export const SpAiAnalysisPageHtml = `
display: flex;
justify-content: center;
align-items: center;
- width: 320px;
+ width: 90%;
height: 50%;
position: absolute;
top: 23%;
- left: 44%;
+ left: 45%;
transform: translateX(-50%);
background-color: sky-blue;
}
diff --git a/ide/src/trace/component/SpAiAnalysisPage.ts b/ide/src/trace/component/SpAiAnalysisPage.ts
index ee8c48995..b7469e7e9 100644
--- a/ide/src/trace/component/SpAiAnalysisPage.ts
+++ b/ide/src/trace/component/SpAiAnalysisPage.ts
@@ -62,6 +62,7 @@ export class SpAiAnalysisPage extends BaseElement {
private isNodata: boolean = true;
private md: unknown;
private isResultBack: boolean = true;
+ private timerId: unknown = undefined;
static startTime: number = 0;
static endTime: number = 0;
activeTime: Element | undefined | null;
@@ -187,15 +188,6 @@ export class SpAiAnalysisPage extends BaseElement {
this.tipsContainer!.style.display = 'none';
this.tipsContent!.style.display = 'none';
this.downloadBtn!.style.display = 'none';
- // 没有登陆,弹窗提示,退出逻辑
- if (!WebSocketManager.getInstance()?.isReady()) {
- this.tipsContent!.style.display = 'flex';
- let guideSrc = `https://${window.location.host.split(':')[0]}:${window.location.port
- }/application/?action=help_27`;
- let linkNodeTips = `未连接,请启动本地扩展程序再试![指导]`;
- this.abnormalPageTips(linkNodeTips, '', 4000);
- return;
- }
// 清空诊断报告的内容
this.reportContent = '';
// 隐藏诊断按钮
@@ -205,7 +197,7 @@ export class SpAiAnalysisPage extends BaseElement {
this.initiateDiagnosis();
} else {
// 首次诊断
- WebSocketManager.getInstance()!.registerMessageListener(TypeConstants.DIAGNOSIS_TYPE, this.webSocketCallBack);
+ WebSocketManager.getInstance()!.registerMessageListener(TypeConstants.DIAGNOSIS_TYPE, this.webSocketCallBack, this.eventCallBack);
// 看缓存中有没有db,没有的话拿一个进行诊断并存缓存
let fileName = sessionStorage.getItem('fileName');
caches.match(`${fileName}.db`).then(async (res) => {
@@ -510,6 +502,11 @@ export class SpAiAnalysisPage extends BaseElement {
//控制页面异常场景的显示
abnormalPageTips(tipStr: string, imgSrc: string, setTimeoutTime: number): void {
+ // 清除延时器,防止弹窗重叠互相影响
+ if (this.timerId) {
+ // @ts-ignore
+ clearTimeout(this.timerId);
+ }
this.tipsContainer!.style.display = 'flex';
this.tipsContainer!.innerHTML = '';
if (imgSrc !== '') {
@@ -531,7 +528,7 @@ export class SpAiAnalysisPage extends BaseElement {
}
if (setTimeoutTime) {
setTimeout(() => {
- this.tipsContainer!.style.display = 'none';
+ this.timerId = this.tipsContainer!.style.display = 'none';
}, setTimeoutTime);
}
}
@@ -562,7 +559,7 @@ export class SpAiAnalysisPage extends BaseElement {
}).catch((error) => {
this.appendMsg(dataList, i, suggestonDiv, timeList, error);
});
- this.draftList!.appendChild(itemDiv!);
+ this.draftList!.insertBefore(itemDiv!, this.loadingItem!);
itemDiv!.style.animation = 'opcityliner 3s';
}
@@ -651,7 +648,7 @@ export class SpAiAnalysisPage extends BaseElement {
this.isNodata = true;
this.draftList!.innerHTML = '';
this.contentsTable!.style.display = 'none';
- let textStr = '服务异常';
+ let textStr = '服务异常,请重新导trace!';
let imgsrc = 'img/no-report.png';
this.tipsContent!.style.display = 'none';
this.abnormalPageTips(textStr, imgsrc, 0);
@@ -679,6 +676,15 @@ export class SpAiAnalysisPage extends BaseElement {
}
}
+ // eventCallBack
+ eventCallBack = async (result: string) => {
+ this.draftList!.innerHTML = '';
+ this.tipsContent!.style.display = 'flex';
+ // @ts-ignore
+ this.abnormalPageTips(this.getStatusesPrompt()[result].prompt, '', 4000);
+ this.draftBtn!.style.display = 'inline-block';
+ }
+
// 发起诊断
initiateDiagnosis(): void {
let requestBodyObj = {
@@ -719,6 +725,35 @@ export class SpAiAnalysisPage extends BaseElement {
return true;
}
+ // 获取提示语
+ getStatusesPrompt(): unknown {
+ let guideSrc = `https://${window.location.host.split(':')[0]}:${window.location.port
+ }/application/?action=help_27`;
+ return {
+ unconnected: {
+ prompt: `未连接,请启动本地扩展程序再试![指导]`
+ },// 重连
+ connected: {
+ prompt: '扩展程序连接中,请稍后再试!'
+ }, // 中间
+ logined: {
+ prompt: '扩展程序连接中,请稍后再试!'
+ }, // 中间
+ loginFailedByLackSession: {
+ prompt: '当前所有会话都在使用中,请释放一些会话再试!'
+ }, // 重连
+ upgrading: {
+ prompt: '扩展程序连接中,请稍后再试!'
+ }, // 中间
+ upgradeSuccess: {
+ prompt: '扩展程序已完成升级,重启中,请稍后再试!'
+ }, // 重连
+ upgradeFailed: {
+ prompt: '刷新页面触发升级,或卸载扩展程序重装!'
+ },// 重连
+ }
+ }
+
initHtml(): string {
return SpAiAnalysisPageHtml;
}
diff --git a/ide/src/webSocket/Constants.ts b/ide/src/webSocket/Constants.ts
index f39f64e1b..0c8595626 100644
--- a/ide/src/webSocket/Constants.ts
+++ b/ide/src/webSocket/Constants.ts
@@ -17,8 +17,12 @@ export class Constants {
static INTERVAL_TIME = 30000;
static LOGIN_PARAM = { type: 0, cmd: 1 };
static LOGIN_CMD = 2;// cmd 2 有效 3无效
+ static SESSION_EXCEED = 3; // session满了
static GET_CMD = 1;
static UPDATE_CMD = 3;
+ static GET_VERSION_CMD = 1;
+ static UPDATE_SUCCESS_CMD = 2; // 升级成功
+ static UPDATE_FAIL_CMD = 4; // 升级失败
}
export class TypeConstants {
diff --git a/ide/src/webSocket/WebSocketManager.ts b/ide/src/webSocket/WebSocketManager.ts
index cb9689055..e049ba855 100644
--- a/ide/src/webSocket/WebSocketManager.ts
+++ b/ide/src/webSocket/WebSocketManager.ts
@@ -15,15 +15,32 @@
import { Utils, MessageParam } from './Util';
import { Constants, TypeConstants } from './Constants';
+// 状态枚举
+enum GetStatuses {
+ UNCONNECTED = 'unconnected', // 服务器未连接
+ CONNECTED = 'connected', // 服务器已连接
+ LOGINED = 'logined', // 已登录
+ LOGINFAILEDBYLACKSESSION = 'loginFailedByLackSession', // session已满
+ UPFRADING = 'upgrading', // 正在升级
+ UPGRADESUCCESS = 'upgradeSuccess', // 升级成功
+ UPGRADEFAILED = 'upgradeFailed', // 升级失败
+ READY = 'ready' // 服务与扩展程序准备就绪
+}
+const INTERMEDIATE_STATE = 'Intermediate state';
+const FAILED_STATE = 'Failed state';
+
+
export class WebSocketManager {
static instance: WebSocketManager | null | undefined = null;
- url: string = `ws://localhost:${Constants.NODE_PORT}`;//8080后期需要修改
+ url: string = `ws://localhost:${Constants.NODE_PORT}`;
private websocket: WebSocket | null | undefined = null;
- private ready: boolean = false;
- private distributeMap: Map = new Map();
+ private distributeMap: Map = new Map();
private sessionId: number | null | undefined;
private session: bigint | null | undefined;
private heartbeatInterval: number | null | undefined;
+ private status: string = GetStatuses.UNCONNECTED;
+ private cacheInfo: Map = new Map();
+ private reconnect: number = -1;
constructor() {
if (WebSocketManager.instance) {
@@ -38,10 +55,11 @@ export class WebSocketManager {
this.websocket = new WebSocket(this.url);
this.websocket.binaryType = 'arraybuffer';
this.websocket.onopen = (): void => {
+ this.status = GetStatuses.CONNECTED;
// 设置心跳定时器
this.sendHeartbeat();
- //检查版本
- this.getVersion();
+ // 连接后登录
+ this.login();
};
//接受webSocket的消息
@@ -59,9 +77,11 @@ export class WebSocketManager {
};
this.websocket.onclose = (event): void => {
- this.initLoginInfor();
+ this.status = GetStatuses.UNCONNECTED;
+ this.finalStatus();
+ //初始化标志位
+ this.initLoginInfo();
this.clearHeartbeat();
- this.reconnect(event);
};
}
@@ -71,39 +91,61 @@ export class WebSocketManager {
* 其他业务数据分发
*/
onmessage(decode: MessageParam): void {
- // 解码event 调decode
- if (decode.type === TypeConstants.UPDATE_TYPE) {// 升级
- if (decode.cmd === Constants.GET_CMD) {
- // 小于则升级
- let targetVersion = '1.0.1';
- let currentVersion = new TextDecoder().decode(decode.data);
- let result = this.compareVersion(currentVersion, targetVersion);
- if (result === -1) {
- this.updateVersion();
- } else {
- // 连接后登录
- this.login();
- }
- }
- } else if (decode.type === TypeConstants.LOGIN_TYPE) {// 登录
- if (decode.cmd === Constants.LOGIN_CMD) {
- this.ready = true;
- this.sessionId = decode.session_id;
- this.session = decode.session;
- }
+ if (decode.type === TypeConstants.LOGIN_TYPE) { // 先登录
+ this.loginMessage(decode);
+ } else if (decode.type === TypeConstants.UPDATE_TYPE) {// 升级
+ this.updateMessage(decode);
} else {// type其他
- for (let [key, callback] of this.distributeMap.entries()) {
- if (key === decode.type) {
- callback(decode.cmd, decode.data);
- }
- };
+ this.businessMessage(decode)
+ }
+ }
+
+ // 登录
+ loginMessage(decode: MessageParam): void {
+ if (decode.cmd === Constants.LOGIN_CMD) {
+ this.status = GetStatuses.LOGINED;
+ this.sessionId = decode.session_id;
+ this.session = decode.session;
+ //检查版本
+ this.getVersion();
+ } else if (decode.cmd === Constants.SESSION_EXCEED) { // session满了
+ this.status = GetStatuses.LOGINFAILEDBYLACKSESSION;
+ this.finalStatus();
+ }
+ }
+
+ // 升级
+ updateMessage(decode: MessageParam): void {
+ if (decode.cmd === Constants.GET_VERSION_CMD) {
+ // 小于则升级
+ let targetVersion = '1.0.1';
+ let currentVersion = new TextDecoder().decode(decode.data);
+ let result = this.compareVersion(currentVersion, targetVersion);
+ if (result === -1) {
+ this.status = GetStatuses.UPFRADING;
+ this.updateVersion();
+ return;
+ }
+ this.status = GetStatuses.READY;
+ this.finalStatus();
+ } else if (decode.cmd === Constants.UPDATE_SUCCESS_CMD) { // 升级成功
+ this.status = GetStatuses.UPGRADESUCCESS;
+ this.finalStatus();
+ } else if (decode.cmd === Constants.UPDATE_FAIL_CMD) { // 升级失败
+ this.status = GetStatuses.UPGRADEFAILED;
+ this.finalStatus();
}
}
+ // 业务
+ businessMessage(decode: MessageParam): void {
+ this.distributeMap.get(decode.type!)?.messageCallback(decode.cmd, decode.data);
+ }
+
// get版本
getVersion(): void {
// 获取扩展程序版本
- this.send(TypeConstants.UPDATE_TYPE, Constants.GET_CMD);
+ this.send(TypeConstants.UPDATE_TYPE, Constants.GET_VERSION_CMD);
}
//check版本
@@ -140,6 +182,8 @@ export class WebSocketManager {
}).then((arrayBuffer) => {
this.send(TypeConstants.UPDATE_TYPE, Constants.UPDATE_CMD, new Uint8Array(arrayBuffer));
}).catch((error) => {
+ this.status = GetStatuses.UPGRADEFAILED;
+ this.finalStatus();
console.error(error);
});
}
@@ -157,19 +201,14 @@ export class WebSocketManager {
return WebSocketManager.instance
}
- // WebSocket是否登录成功
- isReady(): boolean {
- return this.ready;
- }
-
/**
* 消息监听器
* listener是不同模块传来接收数据的函数
* 模块调用
*/
- registerMessageListener(type: number, callback: Function): void {
+ registerMessageListener(type: number, callback: Function, eventCallBack: Function): void {
if (!this.distributeMap.has(type)) {
- this.distributeMap.set(type, callback);
+ this.distributeMap.set(type, { 'messageCallback': callback, 'eventCallBack': eventCallBack });
}
}
@@ -178,11 +217,16 @@ export class WebSocketManager {
* 模块调
*/
sendMessage(type: number, cmd?: number, data?: Uint8Array): void {
- // 检查WebSocket是否登录成功
- if (!this.ready) {// 改判断条件 ready
- return;
+ // 初始化重连标志位
+ this.reconnect = -1;
+ // 检查状态
+ if (this.status !== GetStatuses.READY) {
+ // 缓存数据
+ this.cache(type, cmd, data);
+ this.checkStatus(type);
+ } else {
+ this.send(type, cmd, data);
}
- this.send(type, cmd, data);
}
send(type: number, cmd?: number, data?: Uint8Array): void {
@@ -198,25 +242,12 @@ export class WebSocketManager {
this.websocket!.send(encode!);
}
- /**
- * 传递数据信息至webSocket
- * 模块调
- */
- reconnect(event: unknown): void {
- //@ts-ignore
- if (event.wasClean) {// 正常关闭
- return;
- }
- // 未连接成功打开定时器
- setTimeout(() => {
- this.connectWebSocket();
- }, Constants.INTERVAL_TIME);
- }
-
// 定时检查心跳
sendHeartbeat(): void {
this.heartbeatInterval = window.setInterval(() => {
- this.sendMessage(TypeConstants.HEARTBEAT_TYPE);
+ if (this.status === GetStatuses.READY) {
+ this.send(TypeConstants.HEARTBEAT_TYPE, undefined, undefined);
+ }
}, Constants.INTERVAL_TIME);
}
@@ -224,8 +255,7 @@ export class WebSocketManager {
* 重连时初始化登录信息
* 在异常关闭时调用
*/
- initLoginInfor(): void {
- this.ready = false;
+ initLoginInfo(): void {
this.sessionId = null;
this.session = null;
}
@@ -237,4 +267,68 @@ export class WebSocketManager {
this.heartbeatInterval = null;
}
}
+
+ // 缓存数据
+ cache(type: number, cmd?: number, data?: Uint8Array): void {
+ if (!this.cacheInfo.has(type)) {
+ this.cacheInfo.set(type, { type, cmd, data });
+ } else {
+ let obj = this.cacheInfo.get(type);
+ // @ts-ignore
+ obj.cmd = cmd;
+ //@ts-ignore
+ obj.data = data
+ }
+ }
+
+ // 检查状态 中间状态,最终失败状态,最终成功状态
+ checkStatus(reconnect: number): void {
+ // @ts-ignore
+ let statuses = this.getStatusesPrompt()[this.status];
+ if (statuses.type === INTERMEDIATE_STATE) {
+ this.distributeMap.get(reconnect)!.eventCallBack(this.status);
+ } else if (statuses.type === FAILED_STATE) {
+ this.reconnect = reconnect;
+ this.connectWebSocket()
+ }
+ }
+
+ // 重连后确认最终状态
+ finalStatus(): void {
+ if (this.reconnect !== -1) {
+ if (this.status === GetStatuses.READY) {
+ // @ts-ignore
+ this.sendMessage(this.reconnect, this.cacheInfo.get(this.reconnect)!.cmd, this.cacheInfo.get(this.reconnect)!.data);
+ return;
+ }
+ this.distributeMap.get(this.reconnect)!.eventCallBack(this.status);
+ }
+ this.reconnect = -1;
+ }
+
+ getStatusesPrompt(): unknown {
+ return {
+ unconnected: {
+ type: FAILED_STATE
+ },// 重连
+ connected: {
+ type: INTERMEDIATE_STATE
+ }, // 中间
+ logined: {
+ type: INTERMEDIATE_STATE
+ }, // 中间
+ loginFailedByLackSession: {
+ type: FAILED_STATE
+ }, // 重连
+ upgrading: {
+ type: INTERMEDIATE_STATE
+ }, // 中间
+ upgradeSuccess: {
+ type: FAILED_STATE,
+ }, // 重连
+ upgradeFailed: {
+ type: FAILED_STATE,
+ },// 重连
+ }
+ }
}
--
Gitee
From 7a98d2c13adaebb3b776b659029cf7a9a810c672 Mon Sep 17 00:00:00 2001
From: wangyujie
Date: Thu, 21 Nov 2024 09:56:21 +0800
Subject: [PATCH 07/38] =?UTF-8?q?fix:=E5=B9=BF=E5=91=8A=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: wangyujie
---
ide/src/trace/component/SpAdvertisement.ts | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/ide/src/trace/component/SpAdvertisement.ts b/ide/src/trace/component/SpAdvertisement.ts
index acf2ad462..7b041238d 100644
--- a/ide/src/trace/component/SpAdvertisement.ts
+++ b/ide/src/trace/component/SpAdvertisement.ts
@@ -39,9 +39,11 @@ export class SpAdvertisement extends BaseElement {
this.message = resp.data.data;
localStorage.setItem('message', this.message);
let parts = this.message.split(';');
- let linkInfo = parts[2].match(/链接:([^\s]+)/)![1] || '';
- let link = `${parts[1]}`;
- let finalString = `${parts[0]}
${link}`;
+ let registrationLinkInfo = (parts[2].match(/报名链接:([^\s]+)/) || [])[1] || '';
+ let onlineMeetingLinkInfo = (parts[3].match(/线上会议链接:([^\s]+)/) || [])[1] || '';
+ let registrationLink = `报名链接`;
+ let onlineMeetingLink = `线上会议链接`;
+ let finalString = `${parts[0]}
${parts[1]}
${registrationLink} ${onlineMeetingLink}
${parts[4]}`;
this.noticeEl!.innerHTML = `${finalString}
`;
if (publish) {
if (resp.data.data !== publish) {
--
Gitee
From d35778b827869edb18eb95d74a97bb2859476569 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=9B=86=E5=B7=9D?=
Date: Thu, 21 Nov 2024 09:59:42 +0800
Subject: [PATCH 08/38] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DRpcServer::ReadA?=
=?UTF-8?q?ndParseData=E5=87=BD=E6=95=B0=E6=9C=AA=E5=A4=84=E7=90=86ParseTr?=
=?UTF-8?q?aceDataSegment=E7=9A=84=E8=BF=94=E5=9B=9E=E5=80=BC=E5=AF=BC?=
=?UTF-8?q?=E8=87=B4=E9=99=B7=E5=85=A5=E5=BE=AA=E7=8E=AF=E7=9A=84=E9=97=AE?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: 集川
---
trace_streamer/src/rpc/rpc_server.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/trace_streamer/src/rpc/rpc_server.cpp b/trace_streamer/src/rpc/rpc_server.cpp
index c999fd5de..524a9b1bb 100644
--- a/trace_streamer/src/rpc/rpc_server.cpp
+++ b/trace_streamer/src/rpc/rpc_server.cpp
@@ -174,7 +174,9 @@ bool RpcServer::ReadAndParseData(const std::string &filePath)
std::unique_ptr buf = std::make_unique(G_CHUNK_SIZE);
inputFile.read(reinterpret_cast(buf.get()), G_CHUNK_SIZE);
auto readSize = inputFile.gcount();
- ts_->ParseTraceDataSegment(std::move(buf), readSize, false, inputFile.eof());
+ if (!ts_->ParseTraceDataSegment(std::move(buf), readSize, false, inputFile.eof())) {
+ return false;
+ }
if (inputFile.eof()) {
break;
}
--
Gitee
From 86496ba1f278009b62c3612ae3e5c5dfad5682f2 Mon Sep 17 00:00:00 2001
From: liufei
Date: Thu, 21 Nov 2024 14:04:09 +0800
Subject: [PATCH 09/38] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9nativememorytab?=
=?UTF-8?q?=E9=A1=B5=E6=95=B0=E6=8D=AE=E9=87=8F=E8=B6=8550000=E6=8A=A5?=
=?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98=EF=BC=8C=E5=8E=BB=E9=99=A4trace?=
=?UTF-8?q?=E7=82=B9=E8=AF=A6=E6=83=85=E5=BD=95=E5=85=A5=E5=A4=9A=E4=BD=99?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: liufei
---
ide/src/doc/funDetail.json | 12 ++++++------
.../trace/sheet/native-memory/TabPaneNMemory.ts | 15 ++++++++++++++-
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/ide/src/doc/funDetail.json b/ide/src/doc/funDetail.json
index 9f8b36213..9bca062d7 100644
--- a/ide/src/doc/funDetail.json
+++ b/ide/src/doc/funDetail.json
@@ -177,37 +177,37 @@
},
{
"slice": "OnVsyncEvent now",
- "CN": "收到Vsync信号,渲染流程开始(框架trace,)不用验证",
+ "CN": "收到Vsync信号,渲染流程开始",
"EN": "this is an english translate for CN",
"flag": "0"
},
{
"slice": "UITaskScheduler::FlushTask",
- "CN": "刷新UI界面,包括布局、渲染和动画等(框架trace,不用验证)",
+ "CN": "刷新UI界面,包括布局、渲染和动画等",
"EN": "this is an english translate for CN",
"flag": "0"
},
{
"slice": "FlushMessages",
- "CN": "发送消息通知图形侧进行渲染(框架trace,不用验证)",
+ "CN": "发送消息通知图形侧进行渲染",
"EN": "this is an english translate for CN",
"flag": "0"
},
{
"slice": "FlushRenderTask",
- "CN": "总渲染任务执行(框架trace,不用验证)",
+ "CN": "总渲染任务执行",
"EN": "this is an english translate for CN",
"flag": "0"
},
{
"slice": "Layout",
- "CN": "节点布局(框架trace,不用验证)",
+ "CN": "节点布局",
"EN": "this is an english translate for CN",
"flag": "0"
},
{
"slice": "FrameNode::RenderTask",
- "CN": "单个渲染任务执行(框架trace,不用验证)",
+ "CN": "单个渲染任务执行",
"EN": "this is an english translate for CN",
"flag": "0"
},
diff --git a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMemory.ts b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMemory.ts
index bf838087e..0752fed98 100644
--- a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMemory.ts
+++ b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMemory.ts
@@ -135,7 +135,20 @@ export class TabPaneNMemory extends BaseElement {
this.tblData!.recycleDataSource = [];
this.setNmMemoryLoading(false);
if (results.length > 0) {
- results.forEach((item) => {
+ let isTwoArray: boolean = results.some(item => {
+ return Array.isArray(item);
+ })
+ let dataList: unknown = [];
+ if (isTwoArray) {
+ results.forEach(v => {
+ // @ts-ignore
+ dataList = dataList.concat(v);
+ })
+ } else {
+ dataList = results;
+ }
+ // @ts-ignore
+ dataList.forEach((item) => {
//@ts-ignore
let tmpNumber = item.addr.split('x');
//@ts-ignore
--
Gitee
From 0c380e5c411084a7c4af7808b0aaa78f0105988b Mon Sep 17 00:00:00 2001
From: danghongquan
Date: Thu, 21 Nov 2024 17:07:42 +0800
Subject: [PATCH 10/38] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8DTab=E9=A1=B5?=
=?UTF-8?q?=E7=82=B9=E5=87=BB=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: danghongquan
---
ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts b/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts
index 6edab339c..21adc2c47 100644
--- a/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts
+++ b/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts
@@ -239,6 +239,10 @@ export class TabPaneSlices extends BaseElement {
});
}
async orgnazitionData(data: Object): Promise {
+ // @ts-ignore
+ if (data!.tabTitle === 'Summary') {
+ FuncStruct.funcSelect = true;
+ }
let spApplication = document.querySelector('body > sp-application');
let spSystemTrace = spApplication?.shadowRoot?.querySelector(
'div > div.content > sp-system-trace'
--
Gitee
From 9b286aac3624df5d0d8cff364610fe15ab0bdf76 Mon Sep 17 00:00:00 2001
From: danghongquan
Date: Thu, 21 Nov 2024 20:03:10 +0800
Subject: [PATCH 11/38] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E8=AE=BE=E5=A4=87?=
=?UTF-8?q?=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5=E5=90=8E=E4=B8=8D=E6=8F=90?=
=?UTF-8?q?=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: danghongquan
---
ide/src/trace/component/SpRecordTrace.ts | 26 +++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/ide/src/trace/component/SpRecordTrace.ts b/ide/src/trace/component/SpRecordTrace.ts
index 158bcd66d..01fdb6cf9 100644
--- a/ide/src/trace/component/SpRecordTrace.ts
+++ b/ide/src/trace/component/SpRecordTrace.ts
@@ -196,10 +196,10 @@ export class SpRecordTrace extends BaseElement {
let option = document.createElement('option');
option.className = 'select';
if (typeof dev.serialNumber === 'string') {
- optionNum++;
- option.value = dev.serialNumber;
- option.textContent = dev!.serialNumber ? dev!.serialNumber!.toString() : 'hdc Device';
- this.deviceSelect!.appendChild(option);
+ optionNum++;
+ option.value = dev.serialNumber;
+ option.textContent = dev!.serialNumber ? dev!.serialNumber!.toString() : 'hdc Device';
+ this.deviceSelect!.appendChild(option);
if (dev.serialNumber === sn) {
option.selected = true;
this.recordButton!.hidden = false;
@@ -501,7 +501,19 @@ export class SpRecordTrace extends BaseElement {
// @ts-ignore
HdcDeviceManager.findDevice().then((usbDevices): void => {
log(usbDevices);
- this.refreshDeviceList(usbDevices.serialNumber);
+ HdcDeviceManager.connect(usbDevices.serialNumber).then((res) => {
+ if (res) {
+ this.refreshDeviceList(usbDevices.serialNumber);
+ } else {
+ this.recordButton!.hidden = true;
+ this.disconnectButton!.hidden = true;
+ this.devicePrompt!.innerText = 'Device not connected';
+ this.hintEl!.innerHTML = DEVICE_NOT_CONNECT;
+ if (!this.showHint) {
+ this.showHint = true;
+ }
+ }
+ })
});
}
};
@@ -794,7 +806,7 @@ export class SpRecordTrace extends BaseElement {
this.MenuItemEbpfHtml = th;
}
this.menuGroup!.appendChild(th);
- if (item.title === 'Ark Ts') {
+ if (item.title === 'Ark Ts') {
this.menuGroup!.removeChild(th);
}
});
@@ -901,7 +913,7 @@ export class SpRecordTrace extends BaseElement {
this.buildMenuItem('Ark Ts', 'file-config', this.spArkTs!),
this.buildMenuItem('FFRT', 'file-config', this.spFFRTConfig!),
this.buildMenuItem('Hilog', 'realIntentionBulb', this.spHiLog!),
- this.buildMenuItem('Xpower', 'externaltools', this.spXPower!),
+ this.buildMenuItem('Xpower', 'externaltools', this.spXPower!),
];
}
--
Gitee
From d562fc894f72f5ebbf8d883dc213f0eeb9f8000a Mon Sep 17 00:00:00 2001
From: wangyujie
Date: Fri, 22 Nov 2024 10:11:03 +0800
Subject: [PATCH 12/38] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dtab=E9=A1=B5?=
=?UTF-8?q?=E5=B7=A6=E5=8F=B3=E6=8B=96=E5=8A=A8=EF=BC=8C=E9=BC=A0=E6=A0=87?=
=?UTF-8?q?=E4=B8=8D=E5=8F=97=E6=8E=A7=E5=88=B6=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: wangyujie
---
ide/src/base-ui/slicer/lit-slicer.ts | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ide/src/base-ui/slicer/lit-slicer.ts b/ide/src/base-ui/slicer/lit-slicer.ts
index e9a1bc387..86f9061f0 100644
--- a/ide/src/base-ui/slicer/lit-slicer.ts
+++ b/ide/src/base-ui/slicer/lit-slicer.ts
@@ -153,6 +153,8 @@ export class LitSlicerTrack extends HTMLElement {
) {
previousElementSibling!.style.width = preWidth + e1.pageX - preX + 'px';
nextElementSibling!.style.width = nextWidth + preX - e1.pageX + 'px';
+ } else {
+ this.draging = false;
}
}
};
--
Gitee
From af749aba7abe9dea7ecdbdfab85086bcadfeb823 Mon Sep 17 00:00:00 2001
From: liufei
Date: Fri, 22 Nov 2024 17:13:30 +0800
Subject: [PATCH 13/38] =?UTF-8?q?fix:=E5=A4=9A=E7=BD=91=E9=A1=B5=E5=90=8C?=
=?UTF-8?q?=E6=97=B6=E8=AF=8A=E6=96=AD=E5=90=8C=E4=B8=80trace=E6=8A=A5?=
=?UTF-8?q?=E9=94=99=E5=A4=84=E7=90=86=EF=BC=8Cnative=5Fmamoey=E2=80=94?=
=?UTF-8?q?=E2=80=94call=20info=E9=A1=B5=E7=AD=9B=E9=80=89=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: liufei
---
ide/src/trace/SpApplication.ts | 11 ++---
ide/src/trace/component/SpAiAnalysisPage.ts | 48 ++++++++++---------
.../ProcedureLogicWorkerCommon.ts | 2 +-
3 files changed, 32 insertions(+), 29 deletions(-)
diff --git a/ide/src/trace/SpApplication.ts b/ide/src/trace/SpApplication.ts
index 62e1e7d2c..a793515bc 100644
--- a/ide/src/trace/SpApplication.ts
+++ b/ide/src/trace/SpApplication.ts
@@ -2534,12 +2534,11 @@ export class SpApplication extends BaseElement {
clearInterval(timer);
}, 4000);
// 存入缓存
- await caches.open(`${fileName}`).then(async (cache) => {
- let headers = new Headers();
- headers.append('Content-type', 'application/octet-stream');
- headers.append('Content-Transfer-Encoding', 'binary');
- return cache.put(`${fileName}`, new Response(reqBufferDB, { status: 200 }));
- });
+ const blob = new Blob([reqBufferDB]);
+ const response = new Response(blob)
+ caches.open('DB-file').then(cache => {
+ return cache.put(`/${fileName}`, response);
+ })
},
'download-db'
);
diff --git a/ide/src/trace/component/SpAiAnalysisPage.ts b/ide/src/trace/component/SpAiAnalysisPage.ts
index ee8c48995..2d8fc5041 100644
--- a/ide/src/trace/component/SpAiAnalysisPage.ts
+++ b/ide/src/trace/component/SpAiAnalysisPage.ts
@@ -208,17 +208,28 @@ export class SpAiAnalysisPage extends BaseElement {
WebSocketManager.getInstance()!.registerMessageListener(TypeConstants.DIAGNOSIS_TYPE, this.webSocketCallBack);
// 看缓存中有没有db,没有的话拿一个进行诊断并存缓存
let fileName = sessionStorage.getItem('fileName');
- caches.match(`${fileName}.db`).then(async (res) => {
- if (!res) {
- this.cacheDb(fileName);
+ await caches.match(`/${fileName}.db`).then(response => {
+ if (response) {
+ response.blob().then(blob => {
+ const reader = new FileReader();
+ reader.readAsArrayBuffer(blob);
+ reader.onloadend = () => {
+ const dbBuffer = reader.result;
+ // @ts-ignore
+ const reqBufferDB = new Uint8Array(dbBuffer);
+ // 使用uint8Array
+ WebSocketManager.getInstance()!.sendMessage(
+ TypeConstants.DIAGNOSIS_TYPE,
+ TypeConstants.SENDDB_CMD,
+ reqBufferDB
+ );
+ };
+ });
} else {
- WebSocketManager.getInstance()!.sendMessage(
- TypeConstants.DIAGNOSIS_TYPE,
- TypeConstants.SENDDB_CMD,
- new TextEncoder().encode(await res!.text())
- );
+ // 如果缓存中没有,从网络获取并存储
+ this.cacheDb(fileName);
}
- });
+ })
};
// 点击一键诊断时先挂载loading
this.loadingItem = this.loading('style="position:absolute;top:45%;left:45%;z-index:999"');
@@ -553,7 +564,7 @@ export class SpAiAnalysisPage extends BaseElement {
timeList: Array
): void {
SpStatisticsHttpUtil.askAi({
- token: this.token,
+ token: this.token,
// @ts-ignore
question: dataList[i].description + ',请问该怎么优化?',
collection: ''
@@ -613,18 +624,11 @@ export class SpAiAnalysisPage extends BaseElement {
(reqBufferDB: Uint8Array) => {
WebSocketManager.getInstance()!.sendMessage(TypeConstants.DIAGNOSIS_TYPE, TypeConstants.SENDDB_CMD, reqBufferDB);
// 存入缓存
- caches.open(`${fileName}.db`).then((cache) => {
- let headers = new Headers();
- headers.append('Content-Type', 'application/octet-stream');
- headers.append('Content-Transfer-Encoding', 'binary');
- return cache
- .put(
- `${fileName}.db`,
- new Response(reqBufferDB, {
- status: 200,
- })
- );
- });
+ const blob = new Blob([reqBufferDB]);
+ const response = new Response(blob)
+ caches.open('DB-file').then(cache => {
+ return cache.put(`/${fileName}.db`, response);
+ })
},
'download-db'
);
diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts
index e610e76e9..46f2e0cfe 100644
--- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts
+++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts
@@ -264,7 +264,7 @@ class MerageBeanDataSplit {
*/
//@ts-ignore
let parentNode = item.parentNode;
- while (parentNode !== undefined && !(parentNode.isStore === 0 && parentNode.searchShow)) {
+ while (parentNode !== undefined && !(parentNode.isStore === 0 && parentNode.searchShow) && parentNode.addr) {
parentNode = parentNode.parentNode;
}
if (parentNode) {
--
Gitee
From 4e027e29912093cf2ae665e65dbfaa7190916718 Mon Sep 17 00:00:00 2001
From: danghongquan
Date: Sat, 23 Nov 2024 10:26:49 +0800
Subject: [PATCH 14/38] =?UTF-8?q?fix:=E6=89=A9=E5=B1=95=E6=9C=8D=E5=8A=A1?=
=?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E5=8D=87=E7=BA=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: danghongquan
---
ide/src/webSocket/WebSocketManager.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ide/src/webSocket/WebSocketManager.ts b/ide/src/webSocket/WebSocketManager.ts
index cb9689055..eab76dd8d 100644
--- a/ide/src/webSocket/WebSocketManager.ts
+++ b/ide/src/webSocket/WebSocketManager.ts
@@ -75,7 +75,7 @@ export class WebSocketManager {
if (decode.type === TypeConstants.UPDATE_TYPE) {// 升级
if (decode.cmd === Constants.GET_CMD) {
// 小于则升级
- let targetVersion = '1.0.1';
+ let targetVersion = '1.0.2';
let currentVersion = new TextDecoder().decode(decode.data);
let result = this.compareVersion(currentVersion, targetVersion);
if (result === -1) {
--
Gitee
From b92857f2d8351bbc2712d777c4d70424db487c4a Mon Sep 17 00:00:00 2001
From: danghongquan
Date: Sat, 23 Nov 2024 11:55:00 +0800
Subject: [PATCH 15/38] =?UTF-8?q?fix:=E6=9B=B4=E6=96=B0=E6=89=A9=E5=B1=95?=
=?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=9A=84=E7=89=88=E6=9C=AC=E5=8F=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: danghongquan
---
ide/src/webSocket/WebSocketManager.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ide/src/webSocket/WebSocketManager.ts b/ide/src/webSocket/WebSocketManager.ts
index e049ba855..364779920 100644
--- a/ide/src/webSocket/WebSocketManager.ts
+++ b/ide/src/webSocket/WebSocketManager.ts
@@ -118,7 +118,7 @@ export class WebSocketManager {
updateMessage(decode: MessageParam): void {
if (decode.cmd === Constants.GET_VERSION_CMD) {
// 小于则升级
- let targetVersion = '1.0.1';
+ let targetVersion = '1.0.2';
let currentVersion = new TextDecoder().decode(decode.data);
let result = this.compareVersion(currentVersion, targetVersion);
if (result === -1) {
--
Gitee
From 1e9e12fc1add0b35aea39e66bc967c5bab9b8638 Mon Sep 17 00:00:00 2001
From: danghongquan
Date: Sat, 23 Nov 2024 14:41:03 +0800
Subject: [PATCH 16/38] =?UTF-8?q?fix:=E6=9B=B4=E6=94=B9=E5=B8=AE=E5=8A=A9?=
=?UTF-8?q?=E6=96=87=E6=A1=A3=E6=89=A9=E5=B1=95=E6=9C=8D=E5=8A=A1=E7=9A=84?=
=?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: danghongquan
---
ide/src/doc/quickstart_extensions.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ide/src/doc/quickstart_extensions.html b/ide/src/doc/quickstart_extensions.html
index 647ab76b2..c9e47bf43 100644
--- a/ide/src/doc/quickstart_extensions.html
+++ b/ide/src/doc/quickstart_extensions.html
@@ -811,7 +811,7 @@
在hi-smart-perf-host-extend目录下,找到stop.bat文件,右键选择以管理员身份运行,即可关闭扩展服务。
- 备注:当前扩展服务版本为1.0.1,如果本地存在以其他方式安装的非正式版本,请手动关闭扩展服务,并重新按照该指导安装
+ 备注:当前扩展服务版本为1.0.2,如果本地存在以其他方式安装的非正式版本,请手动关闭扩展服务,并重新按照该指导安装
--
Gitee
From 08b9f9aa03c6b9024ba7d8b1d59a8efbaad9f995 Mon Sep 17 00:00:00 2001
From: "wupoli3@huawei.com"
Date: Mon, 25 Nov 2024 10:45:19 +0800
Subject: [PATCH 17/38] =?UTF-8?q?fix:=20F=E9=94=AE=E9=97=AE=E9=A2=98?=
=?UTF-8?q?=EF=BC=8C=E5=BD=93duration=E4=B8=BA0=E6=97=B6=E4=B8=94=E4=B8=8D?=
=?UTF-8?q?=E5=9C=A8=E5=8F=AF=E8=A7=86=E5=8C=BA=E5=9F=9F=E6=98=BE=E7=A4=BA?=
=?UTF-8?q?=E6=97=B6=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: wupoli3@huawei.com
---
.../component/trace/timer-shaft/RangeRuler.ts | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts
index 841a2d440..e1d9f65f5 100644
--- a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts
+++ b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts
@@ -633,18 +633,15 @@ export class RangeRuler extends Graph {
}
if (startTime === endTime) {
let midNs = (this.range.endNS - this.range.startNS) / 2;
- if (startTime > midNs && startTime - midNs < this.range.totalNS - this.range.endNS) {
- this.range.startNS = this.range.startNS + startTime - midNs;
- this.range.endNS = this.range.endNS + startTime - midNs;
- } else if (startTime < midNs && midNs - startTime < this.range.startNS) {
- this.range.startNS = this.range.startNS - midNs + startTime;
- this.range.endNS = this.range.endNS - midNs + startTime;
- } else if (startTime > midNs && startTime - midNs > this.range.totalNS - this.range.endNS) {
- this.range.startNS = 2 * startTime - this.range.totalNS;
- this.range.endNS = this.range.totalNS;
- } else if (startTime < midNs && midNs - startTime > this.range.startNS) {
+ if (startTime === midNs) {
+ return;
+ }
+ if(startTime * 2 < this.range.totalNS) {
this.range.startNS = 0;
- this.range.endNS = 2 * startTime;
+ this.range.endNS = startTime * 2;
+ } else {
+ this.range.startNS = (startTime * 2) - this.range.totalNS;
+ this.range.endNS = this.range.totalNS;
}
} else {
let startX = midX - 150;
--
Gitee
From cdcef5940d2eec429a0d9c1e0e283eea7ad0563e Mon Sep 17 00:00:00 2001
From: JustinTY
Date: Mon, 25 Nov 2024 14:22:31 +0800
Subject: [PATCH 18/38] =?UTF-8?q?feat=20SmartPerf=E7=B3=BB=E7=BB=9F?=
=?UTF-8?q?=E8=B0=83=E7=94=A8=E6=A0=88=E5=88=86=E6=9E=90=E8=83=BD=E5=8A=9B?=
=?UTF-8?q?=E5=A2=9E=E5=BC=BA-=20=E7=81=AB=E7=84=B0=E5=9B=BE=E5=A2=9E?=
=?UTF-8?q?=E5=8A=A0=E5=8F=AA=E5=B1=95=E7=A4=BA=E5=86=85=E6=A0=B8=E6=A0=88?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../database/logic-worker/ProcedureLogicWorkerPerf.ts | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts
index e3279c731..b05a55870 100644
--- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts
+++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts
@@ -586,10 +586,12 @@ export class ProcedureLogicWorkerPerf extends LogicHandler {
//@ts-ignore
symbolName = perfCallChains[topIndex].name;
}
- let perfRootNode = this.currentTreeMapData[symbolName + perfSample.pid];
+ // 只展示内核栈合并进程栈
+ const usePidAsKey = this.isOnlyKernel ? '': perfSample.pid;
+ let perfRootNode = this.currentTreeMapData[symbolName + usePidAsKey];
if (perfRootNode === undefined) {
perfRootNode = new PerfCallChainMerageData();
- this.currentTreeMapData[symbolName + perfSample.pid] = perfRootNode;
+ this.currentTreeMapData[symbolName + usePidAsKey] = perfRootNode;
this.currentTreeList.push(perfRootNode);
}
PerfCallChainMerageData.merageCallChainSample(perfRootNode, perfCallChains[topIndex], perfSample, false);
@@ -602,6 +604,11 @@ export class ProcedureLogicWorkerPerf extends LogicHandler {
this.allProcess = Object.values(rootMerageMap);
}
private mergeNodeData(totalEventCount: number, totalSamplesCount: number): MergeMap {
+ // 只展示内核栈不添加进程这一级的结构
+ if (this.isOnlyKernel){
+ return this.currentTreeMapData;
+ }
+ // 添加进程级结构
let rootMerageMap: MergeMap = {};
// @ts-ignore
Object.values(this.currentTreeMapData).forEach((merageData: PerfCallChainMerageData): void => {
--
Gitee
From ff7f2c809edf431feebd9f633b5dbe75599b69f9 Mon Sep 17 00:00:00 2001
From: "wupoli3@huawei.com"
Date: Tue, 26 Nov 2024 19:08:32 +0800
Subject: [PATCH 19/38] =?UTF-8?q?fix:=20perf=20output=20data=20chart?=
=?UTF-8?q?=E6=B3=B3=E9=81=93=E6=8A=A5=E9=94=99=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: wupoli3@huawei.com
---
ide/src/trace/component/chart/SpPerfOutputDataChart.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ide/src/trace/component/chart/SpPerfOutputDataChart.ts b/ide/src/trace/component/chart/SpPerfOutputDataChart.ts
index 5a3f79c20..5c2330c68 100644
--- a/ide/src/trace/component/chart/SpPerfOutputDataChart.ts
+++ b/ide/src/trace/component/chart/SpPerfOutputDataChart.ts
@@ -44,7 +44,7 @@ export class SpPerfOutputDataChart {
this.dur = 3000000000;
}
// @ts-ignore
- this.perfOutputArr = perfOutputData[0].name.split(':')[2].split(',');
+ this.perfOutputArr = perfOutputData[0].name.includes(':') ? perfOutputData[0].name.split(':')[2].includes(',') ? perfOutputData[0].name.split(':')[2].split(',') : [] : [];
// @ts-ignore
let endTime: number = perfOutputData[0].ts;
this.startTime = endTime - window.recordStartNS - this.dur!;
--
Gitee
From 4a3cd5c76aa52b0febcef62983f46b0ec2528d2e Mon Sep 17 00:00:00 2001
From: danghongquan
Date: Wed, 27 Nov 2024 15:50:14 +0800
Subject: [PATCH 20/38] =?UTF-8?q?fix:=E8=AE=BE=E5=A4=87=E8=BF=9E=E6=8E=A5?=
=?UTF-8?q?=E7=95=8C=E9=9D=A2=E7=89=88=E6=9C=AC=E5=8F=B7=E9=BB=98=E8=AE=A4?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: danghongquan
---
ide/src/trace/component/SpRecordConfigModel.ts | 4 ++--
ide/src/trace/component/SpRecordTrace.ts | 11 ++++++-----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/ide/src/trace/component/SpRecordConfigModel.ts b/ide/src/trace/component/SpRecordConfigModel.ts
index 01cb2789b..3c9703764 100644
--- a/ide/src/trace/component/SpRecordConfigModel.ts
+++ b/ide/src/trace/component/SpRecordConfigModel.ts
@@ -512,7 +512,7 @@ export function createNativePluginConfig(
if (spAllocations!.appProcess !== '' && spAllocations!.startSamp) {
let nativeConfig = initNativePluginConfig(spAllocations, selectVersion);
let maxProcessSize = 4;
- if (selectVersion !== undefined && selectVersion !== '3.2') {
+ if (selectVersion !== undefined && selectVersion !== '3.2' && selectVersion !=='unknown') {
nativeConfig.callframeCompress = true;
nativeConfig.recordAccurately = spAllocations!.record_accurately;
nativeConfig.offlineSymbolization = spAllocations!.offline_symbolization;
@@ -552,7 +552,7 @@ function initNativePluginConfig(spAllocations: SpAllocations, selectVersion: str
let appProcess = spAllocations!.appProcess;
let processName = '';
let processId = '';
- if (spAllocations!.startup_mode && selectVersion !== '3.2') {
+ if (spAllocations!.startup_mode && selectVersion !== '3.2'&& selectVersion !=='unknown') {
processName = appProcess;
} else {
if (appProcess.indexOf('(') !== -1) {
diff --git a/ide/src/trace/component/SpRecordTrace.ts b/ide/src/trace/component/SpRecordTrace.ts
index 01fdb6cf9..e428c237f 100644
--- a/ide/src/trace/component/SpRecordTrace.ts
+++ b/ide/src/trace/component/SpRecordTrace.ts
@@ -81,7 +81,7 @@ export class SpRecordTrace extends BaseElement {
public static selectVersion: string | null;
public static isVscode = false;
public static cancelRecord = false;
- static supportVersions = ['3.2', '4.0+', '5.0+'];
+ static supportVersions = ['unknown','3.2', '4.0+', '5.0+'];
public deviceSelect: HTMLSelectElement | undefined;
public deviceVersion: HTMLSelectElement | undefined;
private _menuItems: Array