diff --git a/ide/src/base-ui/tabs/lit-tabs.ts b/ide/src/base-ui/tabs/lit-tabs.ts
index 1187d8bc7242b6a7f8f1b7b11c954536fb57b104..e0f8eb54022db63ec2c8dd1eccf449ca294a0c53 100644
--- a/ide/src/base-ui/tabs/lit-tabs.ts
+++ b/ide/src/base-ui/tabs/lit-tabs.ts
@@ -417,6 +417,7 @@ export class LitTabs extends HTMLElement {
+
diff --git a/ide/src/trace/SpApplication.ts b/ide/src/trace/SpApplication.ts
index d5ec88d636cee2bec7d5c9879f7e253feeb76104..b9ab3c5bc6852764c89610fc79d372714a4a68c9 100644
--- a/ide/src/trace/SpApplication.ts
+++ b/ide/src/trace/SpApplication.ts
@@ -59,6 +59,8 @@ import { type SpKeyboard } from './component/SpKeyboard';
import './component/SpKeyboard';
import { parseKeyPathJson } from './component/Utils';
import { Utils } from './component/trace/base/Utils';
+import { SpThirdParty } from './component/SpThirdParty';
+import './component/SpThirdParty'
@element('sp-application')
export class SpApplication extends BaseElement {
@@ -567,6 +569,8 @@ export class SpApplication extends BaseElement {
+
+
@@ -603,6 +607,7 @@ export class SpApplication extends BaseElement {
let chartFilter = this.shadowRoot?.querySelector('.chart-filter') as TraceRowConfig;
let cutTraceFile = this.shadowRoot?.querySelector('.cut-trace-file') as HTMLImageElement;
let longTracePage = that.shadowRoot!.querySelector('.long_trace_page') as HTMLDivElement;
+ let spThirdParty = this.shadowRoot!.querySelector('#sp-third-party') as SpThirdParty;
cutTraceFile.addEventListener('click', () => {
this.croppingFile(progressEL, litSearch);
});
@@ -624,7 +629,17 @@ export class SpApplication extends BaseElement {
spRecordTemplate,
spFlags,
SpKeyboard,
+ spThirdParty,
];
+
+ document.addEventListener('file-error', () => {
+ litSearch.setPercent('This File is Error!', -1);
+ });
+
+ document.addEventListener('file-correct', () => {
+ litSearch.setPercent('', 101);
+ });
+
document.addEventListener('visibilitychange', function () {
if (document.visibilityState === 'visible') {
if (window.localStorage.getItem('Theme') == 'dark') {
@@ -1421,6 +1436,16 @@ export class SpApplication extends BaseElement {
function handleWasmMode(ev: any, showFileName: string, fileSize: string, fileName: string) {
litSearch.setPercent('', 1);
+ if (fileName.endsWith('.json')) {
+ progressEL.loading = true;
+ spSystemTrace!.loadSample(ev).then(() => {
+ showContent(spSystemTrace!);
+ litSearch.setPercent('', 101);
+ that.freshMenuDisable(false);
+ chartFilter!.setAttribute('mode', '');
+ progressEL.loading = false;
+ })
+ } else {
threadPool.init('wasm').then((res) => {
let reader: FileReader | null = new FileReader();
reader.readAsArrayBuffer(ev as any);
@@ -1545,6 +1570,7 @@ export class SpApplication extends BaseElement {
};
});
}
+ }
let openFileInit = () => {
this.clearTraceFileCache();
@@ -1947,6 +1973,14 @@ export class SpApplication extends BaseElement {
});
},
},
+ {
+ title: '第三方文件',
+ icon: 'file-fill',
+ clickHandler: function (item: MenuItem) {
+ that.search = false;
+ showContent(spThirdParty!);
+ },
+ },
],
},
];
diff --git a/ide/src/trace/bean/BoxSelection.ts b/ide/src/trace/bean/BoxSelection.ts
index 0744b5623b34e3201343deb6ef5c2a792aa63925..1f87c5b129e70af8cfba4d68b1c77e12c73e1fe8 100644
--- a/ide/src/trace/bean/BoxSelection.ts
+++ b/ide/src/trace/bean/BoxSelection.ts
@@ -114,6 +114,7 @@ export class SelectionParam {
gpuMemoryTrackerData: Array = [];
hiLogs: Array = [];
hiSysEvents: Array = [];
+ sampleData: Array = [];
}
export class BoxJumpParam {
diff --git a/ide/src/trace/component/SpSystemTrace.ts b/ide/src/trace/component/SpSystemTrace.ts
index 6834c59f069e8bd4183819c49f92db070f011994..366cb73d4f10c39cefca38b5ffb25a1e983a9a00 100644
--- a/ide/src/trace/component/SpSystemTrace.ts
+++ b/ide/src/trace/component/SpSystemTrace.ts
@@ -111,6 +111,7 @@ import { type SpKeyboard } from '../component/SpKeyboard';
import { drawVSync, enableVSync, setVSyncDisable } from './chart/VSync';
import { LtpoStruct } from '../database/ui-worker/ProcedureWorkerLTPO';
import { HitchTimeStruct } from '../database/ui-worker/ProcedureWorkerHitchTime'
+import { SampleStruct } from '../database/ui-worker/ProcedureWorkerSample';
function dpr() {
return window.devicePixelRatio || 1;
@@ -682,7 +683,19 @@ export class SpSystemTrace extends BaseElement {
selection.rightNs = TraceRow.rangeSelectObject?.endNS || 0;
selection.recordStartNs = (window as any).recordStartNS;
rows.forEach((it) => {
- if (it.rowType == TraceRow.ROW_TYPE_CPU) {
+ if (it.rowType == TraceRow.ROW_TYPE_SAMPLE) {
+ let dataList: SampleStruct[] = JSON.parse(JSON.stringify(it.dataList));
+ dataList.forEach(
+ SampleStruct => {
+ SampleStruct.property = SampleStruct.property!.filter((i : any) =>
+ ((i.begin! - i.startTs!) ?? 0) >= TraceRow.rangeSelectObject!.startNS! &&
+ ((i.end! - i.startTs!) ?? 0) <= TraceRow.rangeSelectObject!.endNS!)
+ }
+ )
+ if (dataList[0].property!.length !== 0) {
+ selection.sampleData.push(...dataList);
+ }
+ } else if (it.rowType == TraceRow.ROW_TYPE_CPU) {
selection.cpus.push(parseInt(it.rowId!));
info('load CPU traceRow id is : ', it.rowId);
} else if (it.rowType == TraceRow.ROW_TYPE_CPU_STATE) {
@@ -2464,6 +2477,7 @@ export class SpSystemTrace extends BaseElement {
JsCpuProfilerStruct.hoverJsCpuProfilerStruct = undefined;
SnapshotStruct.hoverSnapshotStruct = undefined;
HiPerfCallChartStruct.hoverPerfCallCutStruct = undefined;
+ SampleStruct.hoverSampleStruct = undefined;
this.tipEL!.style.display = 'none';
}
@@ -2492,6 +2506,7 @@ export class SpSystemTrace extends BaseElement {
AllAppStartupStruct.selectStartupStruct = undefined;
LtpoStruct.selectLtpoStruct = undefined;
HitchTimeStruct.selectHitchTimeStruct = undefined;
+ SampleStruct.selectSampleStruct = undefined;
}
isWASDKeyPress() {
@@ -2682,6 +2697,7 @@ export class SpSystemTrace extends BaseElement {
() => SnapshotStruct.hoverSnapshotStruct !== null && SnapshotStruct.hoverSnapshotStruct !== undefined,
],
[TraceRow.ROW_TYPE_LOGS, () => LogStruct.hoverLogStruct !== null && LogStruct.hoverLogStruct !== undefined],
+ [TraceRow.ROW_TYPE_SAMPLE, () => SampleStruct.hoverSampleStruct !== null && SampleStruct.hoverSampleStruct !== undefined],
]);
onClickHandler(clickRowType: string, row?: TraceRow) {
@@ -3255,6 +3271,10 @@ export class SpSystemTrace extends BaseElement {
} else if (clickRowType === TraceRow.ROW_TYPE_GPU_RESOURCE_VMTRACKER && SnapshotStruct.hoverSnapshotStruct) {
SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct;
this.traceSheetEL?.displayGpuResourceVmTracker(SnapshotStruct.selectSnapshotStruct.startNs);
+ } else if (clickRowType === TraceRow.ROW_TYPE_SAMPLE && SampleStruct.hoverSampleStruct) {
+ SampleStruct.selectSampleStruct = SampleStruct.hoverSampleStruct;
+ this.traceSheetEL?.displaySampleData(SampleStruct.selectSampleStruct, SampleStruct.reqProperty);
+ this.timerShaftEL?.modifyFlagList(undefined);
} else {
if (!JankStruct.hoverJankStruct && JankStruct.delJankLineFlag) {
this.removeLinkLinesByBusinessType('janks');
@@ -4075,6 +4095,28 @@ export class SpSystemTrace extends BaseElement {
window.unsubscribe(window.SmartEvent.UI.SliceMark, this.sliceMarkEventHandler.bind(this));
}
+ loadSample = async (ev: File) => {
+ this.observerScrollHeightEnable = false;
+ await this.initSample(ev);
+ this.rowsEL?.querySelectorAll('trace-row').forEach((it: any) => this.observer.observe(it));
+ window.publish(window.SmartEvent.UI.MouseEventEnable, {
+ mouseEnable: true,
+ });
+ }
+
+ initSample = async (ev: File) => {
+ this.rowsPaneEL!.scroll({
+ top: 0,
+ left: 0,
+ });
+ this.chartManager?.initSample(ev).then(() => {
+ this.loadTraceCompleted = true;
+ this.rowsEL!.querySelectorAll>('trace-row').forEach((it) => {
+ this.intersectionObserver?.observe(it);
+ })
+ })
+ }
+
sliceMarkEventHandler(ev: any) {
SpSystemTrace.sliceRangeMark = ev;
let startNS = ev.timestamp - (window as any).recordStartNS;
@@ -4281,17 +4323,13 @@ export class SpSystemTrace extends BaseElement {
}
}
} else {
- if (currentIndex == -1) {
- findIndex = 0;
- } else {
- findIndex = structs.findIndex((it, idx) => {
- return (
- idx > currentIndex &&
- it.startTime! >= TraceRow.range!.startNS &&
- it.startTime! + it.dur! <= TraceRow.range!.endNS
- );
- });
- }
+ findIndex = structs.findIndex((it, idx) => {
+ return (
+ idx > currentIndex &&
+ it.startTime! >= TraceRow.range!.startNS &&
+ it.startTime! + it.dur! <= TraceRow.range!.endNS
+ );
+ });
}
let findEntry: any;
if (findIndex >= 0) {
@@ -4315,8 +4353,8 @@ export class SpSystemTrace extends BaseElement {
}
}
findEntry = structs[findIndex];
+ this.moveRangeToCenter(findEntry.startTime!, findEntry.dur!);
}
- this.moveRangeToCenter(findEntry.startTime!, findEntry.dur!);
this.queryAllTraceRow().forEach((item) => {
item.highlight = false;
});
diff --git a/ide/src/trace/component/SpThirdParty.ts b/ide/src/trace/component/SpThirdParty.ts
new file mode 100644
index 0000000000000000000000000000000000000000..ac645e564bf7927632c24085db17eb6314a0cf42
--- /dev/null
+++ b/ide/src/trace/component/SpThirdParty.ts
@@ -0,0 +1,99 @@
+/*
+ * 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 { LitMainMenu, MenuItem } from '../../base-ui/menu/LitMainMenu';
+import { SpApplication } from '../SpApplication';
+@element('sp-third-party')
+export class SpThirdParty extends BaseElement {
+ private bodyEl: HTMLElement | undefined | null;
+ private uploadEl: HTMLElement | undefined | null;
+ private inputEl: HTMLInputElement | undefined | null;
+ private sp: SpApplication | undefined;
+
+ initElements(): void {
+ let parentElement = this.parentNode as HTMLElement;
+ parentElement.style.overflow = 'hidden';
+ this.bodyEl = this.shadowRoot?.querySelector('.body');
+ this.uploadEl = this.shadowRoot?.querySelector('.upload-btn')?.shadowRoot?.querySelector('#custom-button');
+ this.inputEl = this.shadowRoot?.querySelector('#file');
+ this.uploadEl?.addEventListener('click', () => {
+ this.inputEl?.click();
+ })
+ this.inputEl!.addEventListener('change', () => {
+ let files = this.inputEl!.files;
+ if (files && files.length > 0) {
+ let main = this.parentNode!.parentNode!.querySelector('lit-main-menu') as LitMainMenu;
+ let children = main.menus!;
+ let child = children[0].children as Array