1fb726d48Sopenharmony_ci/*
2fb726d48Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd.
3fb726d48Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fb726d48Sopenharmony_ci * you may not use sp file except in compliance with the License.
5fb726d48Sopenharmony_ci * You may obtain a copy of the License at
6fb726d48Sopenharmony_ci *
7fb726d48Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fb726d48Sopenharmony_ci *
9fb726d48Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fb726d48Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fb726d48Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fb726d48Sopenharmony_ci * See the License for the specific language governing permissions and
13fb726d48Sopenharmony_ci * limitations under the License.
14fb726d48Sopenharmony_ci */
15fb726d48Sopenharmony_ci
16fb726d48Sopenharmony_ciimport { JankStruct } from '../database/ui-worker/ProcedureWorkerJank';
17fb726d48Sopenharmony_ciimport { SpSystemTrace } from './SpSystemTrace';
18fb726d48Sopenharmony_ciimport { TraceRow } from './trace/base/TraceRow';
19fb726d48Sopenharmony_ciimport { LineType, PairPoint, ns2xByTimeShaft } from '../database/ui-worker/ProcedureWorkerCommon';
20fb726d48Sopenharmony_ciimport { TabPaneTaskFrames } from './trace/sheet/task/TabPaneTaskFrames';
21fb726d48Sopenharmony_ciimport { FuncStruct } from '../database/ui-worker/ProcedureWorkerFunc';
22fb726d48Sopenharmony_ciimport { queryBySelectExecute } from '../database/sql/ProcessThread.sql';
23fb726d48Sopenharmony_ciimport { queryTaskPoolOtherRelationData, queryTaskPoolRelationData } from '../database/sql/Func.sql';
24fb726d48Sopenharmony_ciimport { queryBySelectAllocationOrReturn } from '../database/sql/SqlLite.sql';
25fb726d48Sopenharmony_ciimport { ThreadStruct } from '../database/ui-worker/ProcedureWorkerThread';
26fb726d48Sopenharmony_ciimport { Utils } from './trace/base/Utils';
27fb726d48Sopenharmony_ciimport { TraceMode } from '../SpApplicationPublicFunc';
28fb726d48Sopenharmony_ciimport { BaseStruct } from '../bean/BaseStruct';
29fb726d48Sopenharmony_ciimport { getTimeString } from './trace/sheet/TabPaneCurrentSelection';
30fb726d48Sopenharmony_ci
31fb726d48Sopenharmony_ci//@ts-ignore
32fb726d48Sopenharmony_cifunction collectionHasJank(jankRow: unknown, collectList: TraceRow<unknown>[]): boolean {
33fb726d48Sopenharmony_ci  for (let item of collectList!) {
34fb726d48Sopenharmony_ci    //@ts-ignore
35fb726d48Sopenharmony_ci    if (item.rowId === jankRow.rowId && item.rowType === jankRow.rowType) {
36fb726d48Sopenharmony_ci      return false;
37fb726d48Sopenharmony_ci    }
38fb726d48Sopenharmony_ci  }
39fb726d48Sopenharmony_ci  return true;
40fb726d48Sopenharmony_ci}
41fb726d48Sopenharmony_ci
42fb726d48Sopenharmony_cifunction setPoint(
43fb726d48Sopenharmony_ci  x: number,
44fb726d48Sopenharmony_ci  y: number,
45fb726d48Sopenharmony_ci  offsetY: number,
46fb726d48Sopenharmony_ci  ns: number,
47fb726d48Sopenharmony_ci  rowEL: unknown,
48fb726d48Sopenharmony_ci  isRight: boolean,
49fb726d48Sopenharmony_ci  business: string
50fb726d48Sopenharmony_ci): PairPoint {
51fb726d48Sopenharmony_ci  return {
52fb726d48Sopenharmony_ci    x: x,
53fb726d48Sopenharmony_ci    y: y,
54fb726d48Sopenharmony_ci    offsetY: offsetY,
55fb726d48Sopenharmony_ci    ns: ns,
56fb726d48Sopenharmony_ci    rowEL: rowEL!,
57fb726d48Sopenharmony_ci    isRight: isRight,
58fb726d48Sopenharmony_ci    business: business,
59fb726d48Sopenharmony_ci  } as PairPoint;
60fb726d48Sopenharmony_ci}
61fb726d48Sopenharmony_ci
62fb726d48Sopenharmony_cifunction addPointHandle(
63fb726d48Sopenharmony_ci  sp: SpSystemTrace,
64fb726d48Sopenharmony_ci  sourceData: FuncStruct,
65fb726d48Sopenharmony_ci  sourceThreadRow: TraceRow<BaseStruct>,
66fb726d48Sopenharmony_ci  targetData: FuncStruct,
67fb726d48Sopenharmony_ci  targetThreadRow: TraceRow<BaseStruct>,
68fb726d48Sopenharmony_ci  lineType?: string
69fb726d48Sopenharmony_ci): void {
70fb726d48Sopenharmony_ci  let sourceParentRow: TraceRow<BaseStruct> | null | undefined;
71fb726d48Sopenharmony_ci  let targetParentRow: TraceRow<BaseStruct> | null | undefined;
72fb726d48Sopenharmony_ci  if (Utils.currentTraceMode === TraceMode.DISTRIBUTED) {
73fb726d48Sopenharmony_ci    sourceParentRow = sp.shadowRoot?.querySelector<TraceRow<BaseStruct>>(
74fb726d48Sopenharmony_ci      `trace-row[row-id='${sourceData.pid}-${sourceData.traceId}'][row-type='process'][folder]`
75fb726d48Sopenharmony_ci    );
76fb726d48Sopenharmony_ci    targetParentRow = sp.shadowRoot?.querySelector<TraceRow<BaseStruct>>(
77fb726d48Sopenharmony_ci      `trace-row[row-id='${targetData.pid}-${targetData.traceId}'][row-type='process'][folder]`
78fb726d48Sopenharmony_ci    );
79fb726d48Sopenharmony_ci  } else {
80fb726d48Sopenharmony_ci    sourceParentRow = sp.shadowRoot?.querySelector<TraceRow<BaseStruct>>(
81fb726d48Sopenharmony_ci      `trace-row[row-id='${sourceData.pid}'][row-type='process'][folder]`
82fb726d48Sopenharmony_ci    );
83fb726d48Sopenharmony_ci    targetParentRow = sp.shadowRoot?.querySelector<TraceRow<BaseStruct>>(
84fb726d48Sopenharmony_ci      `trace-row[row-id='${targetData.pid}'][row-type='process'][folder]`
85fb726d48Sopenharmony_ci    );
86fb726d48Sopenharmony_ci  }
87fb726d48Sopenharmony_ci  let [startY, startOffSetY, startRowEl, isThreadRow] =
88fb726d48Sopenharmony_ci    getPointModel(sp, sourceThreadRow, sourceParentRow, sourceData, 0.9);
89fb726d48Sopenharmony_ci  let [endY, endOffSetY, endRowEl] =
90fb726d48Sopenharmony_ci    getPointModel(sp, targetThreadRow, targetParentRow, targetData, 0.1);
91fb726d48Sopenharmony_ci  let startX = Math.floor(ns2xByTimeShaft(sourceData.ts || sourceData.startTs || 0, sp.timerShaftEL!));
92fb726d48Sopenharmony_ci  let endX = Math.floor(ns2xByTimeShaft(targetData.ts! || targetData.startTs!, sp.timerShaftEL!));
93fb726d48Sopenharmony_ci  const startPoint = setPoint(startX, startY, startOffSetY, sourceData.ts || sourceData.startTs || 0, startRowEl, true, 'distributed');
94fb726d48Sopenharmony_ci  const endPoint = setPoint(endX, endY, endOffSetY, targetData.ts! || targetData.startTs!, endRowEl, true, 'distributed');
95fb726d48Sopenharmony_ci  startPoint.rangeTime = `${getTimeString((targetData.ts || targetData.startTs! || 0) - (sourceData.ts || sourceData.startTs || 0))}`;
96fb726d48Sopenharmony_ci  if (startPoint && endPoint) {
97fb726d48Sopenharmony_ci    startPoint.lineType = endPoint.lineType = LineType.brokenLine;
98fb726d48Sopenharmony_ci    startPoint.lineColor = endPoint.lineColor = '#ff0000';
99fb726d48Sopenharmony_ci    sp.addPointPair(startPoint, endPoint, lineType);
100fb726d48Sopenharmony_ci  }
101fb726d48Sopenharmony_ci}
102fb726d48Sopenharmony_ci
103fb726d48Sopenharmony_cifunction getPointModel(
104fb726d48Sopenharmony_ci  sp: SpSystemTrace,
105fb726d48Sopenharmony_ci  threadRow: TraceRow<BaseStruct> | null | undefined,
106fb726d48Sopenharmony_ci  parentRow: TraceRow<BaseStruct> | null | undefined,
107fb726d48Sopenharmony_ci  dataStruct: FuncStruct,
108fb726d48Sopenharmony_ci  pointYHeight: number,
109fb726d48Sopenharmony_ci): [number, number, TraceRow<BaseStruct>, boolean] {
110fb726d48Sopenharmony_ci  let pointY: number = 0;
111fb726d48Sopenharmony_ci  let isThreadRow = false;
112fb726d48Sopenharmony_ci  let pointRowEl: TraceRow<BaseStruct> | null | undefined;
113fb726d48Sopenharmony_ci  let pointOffSetY: number = 0;
114fb726d48Sopenharmony_ci  if (threadRow) {
115fb726d48Sopenharmony_ci    pointY = threadRow?.translateY + 20 * (dataStruct.depth! + pointYHeight);
116fb726d48Sopenharmony_ci    pointRowEl = threadRow;
117fb726d48Sopenharmony_ci    pointOffSetY = 20 * (dataStruct.depth! + pointYHeight);
118fb726d48Sopenharmony_ci    isThreadRow = true;
119fb726d48Sopenharmony_ci  } else if (parentRow) {
120fb726d48Sopenharmony_ci    if (!parentRow.expansion) {
121fb726d48Sopenharmony_ci      pointY = parentRow?.translateY! + 4 * (dataStruct.depth! + 0.5);
122fb726d48Sopenharmony_ci      pointRowEl = parentRow!;
123fb726d48Sopenharmony_ci      pointOffSetY = 4 * (dataStruct.depth! + 0.5);
124fb726d48Sopenharmony_ci    }
125fb726d48Sopenharmony_ci  } else {
126fb726d48Sopenharmony_ci    pointRowEl = sp.shadowRoot?.querySelector<TraceRow<BaseStruct>>(
127fb726d48Sopenharmony_ci      `trace-row[row-id='trace-${dataStruct.traceId}'][row-type='trace-${dataStruct.traceId}'][folder]`
128fb726d48Sopenharmony_ci    );
129fb726d48Sopenharmony_ci    pointY = pointRowEl?.translateY! + 4 * (dataStruct.depth! + 0.5);
130fb726d48Sopenharmony_ci    pointOffSetY = 4 * (dataStruct.depth! + 0.5);
131fb726d48Sopenharmony_ci  }
132fb726d48Sopenharmony_ci  return [pointY, pointOffSetY, pointRowEl!, isThreadRow];
133fb726d48Sopenharmony_ci}
134fb726d48Sopenharmony_ci
135fb726d48Sopenharmony_cifunction selectJankApp(
136fb726d48Sopenharmony_ci  endParentRow: unknown,
137fb726d48Sopenharmony_ci  sp: SpSystemTrace,
138fb726d48Sopenharmony_ci  data: unknown,
139fb726d48Sopenharmony_ci  startRow: unknown,
140fb726d48Sopenharmony_ci  selectJankStruct: JankStruct,
141fb726d48Sopenharmony_ci  endRowStruct: unknown
142fb726d48Sopenharmony_ci): void {
143fb726d48Sopenharmony_ci  let collectList = sp.favoriteChartListEL!.getAllCollectRows();
144fb726d48Sopenharmony_ci  //@ts-ignore
145fb726d48Sopenharmony_ci  let findJankEntry = endRowStruct!.dataListCache!.find(
146fb726d48Sopenharmony_ci    //@ts-ignore
147fb726d48Sopenharmony_ci    (dat: unknown) => `${dat.name}` === `${data.name}` && `${dat.pid}` === `${data.pid}`
148fb726d48Sopenharmony_ci  );
149fb726d48Sopenharmony_ci  let tts =
150fb726d48Sopenharmony_ci    findJankEntry.frameType === 'frameTime' ? selectJankStruct.ts! : selectJankStruct.ts! + selectJankStruct.dur!;
151fb726d48Sopenharmony_ci  let startParentRow: unknown;
152fb726d48Sopenharmony_ci  // startRow为子泳道,子泳道不存在,使用父泳道
153fb726d48Sopenharmony_ci  if (startRow) {
154fb726d48Sopenharmony_ci    startParentRow = sp.shadowRoot?.querySelector<TraceRow<JankStruct>>(
155fb726d48Sopenharmony_ci      //@ts-ignore
156fb726d48Sopenharmony_ci      `trace-row[row-type='process'][row-id='${startRow.rowParentId}'][folder]`
157fb726d48Sopenharmony_ci    );
158fb726d48Sopenharmony_ci  } else {
159fb726d48Sopenharmony_ci    startRow = sp.shadowRoot?.querySelector<TraceRow<JankStruct>>(
160fb726d48Sopenharmony_ci      `trace-row[row-type='process'][row-id='${selectJankStruct?.pid}'][folder]`
161fb726d48Sopenharmony_ci    );
162fb726d48Sopenharmony_ci  }
163fb726d48Sopenharmony_ci  //@ts-ignore
164fb726d48Sopenharmony_ci  let endY = endRowStruct!.translateY! + 20 * (findJankEntry!.depth! + 0.5);
165fb726d48Sopenharmony_ci  let endRowEl = endRowStruct;
166fb726d48Sopenharmony_ci  let endOffSetY = 20 * (findJankEntry!.depth! + 0.5);
167fb726d48Sopenharmony_ci  let expansionFlag = collectionHasJank(endRowStruct, collectList);
168fb726d48Sopenharmony_ci  //@ts-ignore
169fb726d48Sopenharmony_ci  if (!endParentRow.expansion && expansionFlag) {
170fb726d48Sopenharmony_ci    //@ts-ignore
171fb726d48Sopenharmony_ci    endY = endParentRow!.translateY! + 10 * (findJankEntry!.depth! + 0.5);
172fb726d48Sopenharmony_ci    endRowEl = endParentRow;
173fb726d48Sopenharmony_ci    endOffSetY = 10 * (findJankEntry!.depth! + 0.5);
174fb726d48Sopenharmony_ci  }
175fb726d48Sopenharmony_ci  //@ts-ignore
176fb726d48Sopenharmony_ci  let startY = startRow!.translateY! + 20 * (selectJankStruct!.depth! + 0.5);
177fb726d48Sopenharmony_ci  let startRowEl = startRow;
178fb726d48Sopenharmony_ci  let startOffSetY = 20 * (selectJankStruct!.depth! + 0.5);
179fb726d48Sopenharmony_ci  expansionFlag = collectionHasJank(startRow, collectList);
180fb726d48Sopenharmony_ci  //@ts-ignore
181fb726d48Sopenharmony_ci  if (startParentRow && !startParentRow.expansion && expansionFlag) {
182fb726d48Sopenharmony_ci    //@ts-ignore
183fb726d48Sopenharmony_ci    startY = startParentRow!.translateY! + 10 * (selectJankStruct!.depth! + 0.5);
184fb726d48Sopenharmony_ci    startRowEl = startParentRow;
185fb726d48Sopenharmony_ci    startOffSetY = 10 * (selectJankStruct!.depth! + 0.5);
186fb726d48Sopenharmony_ci  }
187fb726d48Sopenharmony_ci  let startX = ns2xByTimeShaft(tts, sp.timerShaftEL!);
188fb726d48Sopenharmony_ci  let endX = ns2xByTimeShaft(findJankEntry.ts!, sp.timerShaftEL!);
189fb726d48Sopenharmony_ci  const startPoint = setPoint(startX, startY, startOffSetY, tts, startRowEl, selectJankStruct.ts === tts, 'janks');
190fb726d48Sopenharmony_ci  const endPoint = setPoint(endX, endY, endOffSetY, findJankEntry.ts!, endRowEl, true, 'janks');
191fb726d48Sopenharmony_ci  //@ts-ignore
192fb726d48Sopenharmony_ci  sp.addPointPair(startPoint, endPoint);
193fb726d48Sopenharmony_ci}
194fb726d48Sopenharmony_ci
195fb726d48Sopenharmony_cifunction findJankApp(
196fb726d48Sopenharmony_ci  endParentRow: unknown,
197fb726d48Sopenharmony_ci  sp: SpSystemTrace,
198fb726d48Sopenharmony_ci  data: unknown,
199fb726d48Sopenharmony_ci  startRow: unknown,
200fb726d48Sopenharmony_ci  selectJankStruct: JankStruct,
201fb726d48Sopenharmony_ci  endRowStruct: unknown
202fb726d48Sopenharmony_ci): void {
203fb726d48Sopenharmony_ci  let collectList = sp.favoriteChartListEL!.getAllCollectRows();
204fb726d48Sopenharmony_ci  //@ts-ignore
205fb726d48Sopenharmony_ci  let findJankEntry = endRowStruct!.dataListCache!.find(
206fb726d48Sopenharmony_ci    //@ts-ignore
207fb726d48Sopenharmony_ci    (dat: unknown) => dat.name === data.name && dat.pid === data.pid
208fb726d48Sopenharmony_ci  );
209fb726d48Sopenharmony_ci  let tts = selectJankStruct.frameType === 'frameTime' ? findJankEntry.ts : findJankEntry.ts! + findJankEntry.dur!;
210fb726d48Sopenharmony_ci  //@ts-ignore
211fb726d48Sopenharmony_ci  let endY = endRowStruct!.translateY! + 20 * (findJankEntry!.depth! + 0.5);
212fb726d48Sopenharmony_ci  let endRowEl = endRowStruct;
213fb726d48Sopenharmony_ci  let endOffSetY = 20 * (findJankEntry!.depth! + 0.5);
214fb726d48Sopenharmony_ci  let expansionFlag = collectionHasJank(endRowStruct, collectList);
215fb726d48Sopenharmony_ci  //@ts-ignore
216fb726d48Sopenharmony_ci  if (!endParentRow.expansion && expansionFlag) {
217fb726d48Sopenharmony_ci    //@ts-ignore
218fb726d48Sopenharmony_ci    endY = endParentRow!.translateY! + 10 * (findJankEntry!.depth! + 0.5);
219fb726d48Sopenharmony_ci    endRowEl = endParentRow;
220fb726d48Sopenharmony_ci    endOffSetY = 10 * (findJankEntry!.depth! + 0.5);
221fb726d48Sopenharmony_ci  }
222fb726d48Sopenharmony_ci  //@ts-ignore
223fb726d48Sopenharmony_ci  let startY = startRow!.translateY! + 20 * (selectJankStruct!.depth! + 0.5);
224fb726d48Sopenharmony_ci  let startRowEl = startRow;
225fb726d48Sopenharmony_ci  expansionFlag = collectionHasJank(startRow, collectList);
226fb726d48Sopenharmony_ci  let startOffsetY = 20 * (selectJankStruct!.depth! + 0.5);
227fb726d48Sopenharmony_ci  let startParentRow = sp.shadowRoot?.querySelector<TraceRow<JankStruct>>(
228fb726d48Sopenharmony_ci    //@ts-ignore
229fb726d48Sopenharmony_ci    `trace-row[row-type='process'][row-id='${startRow.rowParentId}'][folder]`
230fb726d48Sopenharmony_ci  );
231fb726d48Sopenharmony_ci  if (startParentRow && !startParentRow.expansion && expansionFlag) {
232fb726d48Sopenharmony_ci    startY = startParentRow!.translateY! + 10 * (selectJankStruct!.depth! + 0.5);
233fb726d48Sopenharmony_ci    startRowEl = startParentRow;
234fb726d48Sopenharmony_ci    startOffsetY = 10 * (selectJankStruct!.depth! + 0.5);
235fb726d48Sopenharmony_ci  }
236fb726d48Sopenharmony_ci  let startX = ns2xByTimeShaft(selectJankStruct.ts!, sp.timerShaftEL!);
237fb726d48Sopenharmony_ci  let endX = ns2xByTimeShaft(tts, sp.timerShaftEL!);
238fb726d48Sopenharmony_ci  const startPoint = setPoint(startX, startY, startOffsetY, selectJankStruct.ts!, startRowEl, true, 'janks');
239fb726d48Sopenharmony_ci  const endPoint = setPoint(endX, endY, endOffSetY, tts, endRowEl, selectJankStruct.ts === tts, 'janks');
240fb726d48Sopenharmony_ci  //@ts-ignore
241fb726d48Sopenharmony_ci  sp.addPointPair(startPoint, endPoint);
242fb726d48Sopenharmony_ci}
243fb726d48Sopenharmony_ci
244fb726d48Sopenharmony_cifunction addPointLink(
245fb726d48Sopenharmony_ci  endParentRow: unknown,
246fb726d48Sopenharmony_ci  sp: SpSystemTrace,
247fb726d48Sopenharmony_ci  data: unknown,
248fb726d48Sopenharmony_ci  startRow: unknown,
249fb726d48Sopenharmony_ci  selectJankStruct: JankStruct,
250fb726d48Sopenharmony_ci  endRowStruct: unknown
251fb726d48Sopenharmony_ci): void {
252fb726d48Sopenharmony_ci  //@ts-ignore
253fb726d48Sopenharmony_ci  let findJankEntry = endRowStruct!.dataListCache!.find(
254fb726d48Sopenharmony_ci    //@ts-ignore
255fb726d48Sopenharmony_ci    (dat: unknown) => dat.name === data.name && dat.pid === data.pid
256fb726d48Sopenharmony_ci  );
257fb726d48Sopenharmony_ci  //连线规则:frametimeline的头----app的头,app的尾----renderservice的头
258fb726d48Sopenharmony_ci  let tts: number = 0;
259fb726d48Sopenharmony_ci  if (findJankEntry) {
260fb726d48Sopenharmony_ci    if (selectJankStruct.frameType === 'app') {
261fb726d48Sopenharmony_ci      selectJankApp(endParentRow, sp, data, startRow, selectJankStruct, endRowStruct);
262fb726d48Sopenharmony_ci    }
263fb726d48Sopenharmony_ci    if (findJankEntry.frameType === 'app') {
264fb726d48Sopenharmony_ci      //@ts-ignore
265fb726d48Sopenharmony_ci      findJankApp(endParentRow, sp, data, startRow, selectJankStruct, endRowStruct);
266fb726d48Sopenharmony_ci    }
267fb726d48Sopenharmony_ci    //@ts-ignore
268fb726d48Sopenharmony_ci    if (data.children.length >= 1) {
269fb726d48Sopenharmony_ci      let endP;
270fb726d48Sopenharmony_ci      //@ts-ignore
271fb726d48Sopenharmony_ci      if (data.children[0].frameType === 'frameTime') {
272fb726d48Sopenharmony_ci        //@ts-ignore
273fb726d48Sopenharmony_ci        endP = sp.shadowRoot?.querySelector<TraceRow<unknown>>(`trace-row[row-type='janks'][row-id='frameTime']`);
274fb726d48Sopenharmony_ci      } else {
275fb726d48Sopenharmony_ci        //@ts-ignore
276fb726d48Sopenharmony_ci        endP = sp.shadowRoot?.querySelector<TraceRow<unknown>>(
277fb726d48Sopenharmony_ci          //@ts-ignore
278fb726d48Sopenharmony_ci          `trace-row[row-type='process'][row-id='${data.children[0].pid}'][folder]`
279fb726d48Sopenharmony_ci        );
280fb726d48Sopenharmony_ci      }
281fb726d48Sopenharmony_ci      //@ts-ignore
282fb726d48Sopenharmony_ci      sp.drawJankLine(endP, findJankEntry, data.children[0]);
283fb726d48Sopenharmony_ci    }
284fb726d48Sopenharmony_ci  }
285fb726d48Sopenharmony_ci}
286fb726d48Sopenharmony_ci
287fb726d48Sopenharmony_cifunction getEndStruct(data: unknown, sp: SpSystemTrace): unknown {
288fb726d48Sopenharmony_ci  let endRowStruct: unknown;
289fb726d48Sopenharmony_ci  //@ts-ignore
290fb726d48Sopenharmony_ci  if (data.frameType === 'frameTime') {
291fb726d48Sopenharmony_ci    endRowStruct = sp.shadowRoot?.querySelector<TraceRow<JankStruct>>(
292fb726d48Sopenharmony_ci      "trace-row[row-id='actual frameTime'][row-type='janks']"
293fb726d48Sopenharmony_ci    );
294fb726d48Sopenharmony_ci  } else {
295fb726d48Sopenharmony_ci    endRowStruct = sp.shadowRoot?.querySelector<TraceRow<JankStruct>>(
296fb726d48Sopenharmony_ci      //@ts-ignore
297fb726d48Sopenharmony_ci      `trace-row[row-id='${data.type}-${data.pid}'][row-type='janks']`
298fb726d48Sopenharmony_ci    );
299fb726d48Sopenharmony_ci  }
300fb726d48Sopenharmony_ci  return endRowStruct;
301fb726d48Sopenharmony_ci}
302fb726d48Sopenharmony_ci
303fb726d48Sopenharmony_cifunction drawJankLineEndParent(
304fb726d48Sopenharmony_ci  endParentRow: unknown,
305fb726d48Sopenharmony_ci  sp: SpSystemTrace,
306fb726d48Sopenharmony_ci  data: unknown,
307fb726d48Sopenharmony_ci  startRow: unknown,
308fb726d48Sopenharmony_ci  selectJankStruct: JankStruct,
309fb726d48Sopenharmony_ci  isBinderClick: boolean = false
310fb726d48Sopenharmony_ci): void {
311fb726d48Sopenharmony_ci  if (isBinderClick) {
312fb726d48Sopenharmony_ci    //@ts-ignore
313fb726d48Sopenharmony_ci    endParentRow.expansion = true;
314fb726d48Sopenharmony_ci  }
315fb726d48Sopenharmony_ci  //终点的父泳道过滤出选中的Struct
316fb726d48Sopenharmony_ci  let endRowStruct = getEndStruct(data, sp);
317fb726d48Sopenharmony_ci  //泳道未展开的情况,查找endRowStruct
318fb726d48Sopenharmony_ci  if (!endRowStruct) {
319fb726d48Sopenharmony_ci    //@ts-ignore
320fb726d48Sopenharmony_ci    if (data.frameType === 'frameTime') {
321fb726d48Sopenharmony_ci      //@ts-ignore
322fb726d48Sopenharmony_ci      endParentRow.childrenList.forEach((item: TraceRow<JankStruct>) => {
323fb726d48Sopenharmony_ci        if (item.rowId === 'actual frameTime' && item.rowType === 'janks') {
324fb726d48Sopenharmony_ci          endRowStruct = item;
325fb726d48Sopenharmony_ci        }
326fb726d48Sopenharmony_ci      });
327fb726d48Sopenharmony_ci      //frameTime未展开
328fb726d48Sopenharmony_ci      if (!endRowStruct) {
329fb726d48Sopenharmony_ci        endParentRow = sp.shadowRoot?.querySelector<TraceRow<JankStruct>>("trace-row[row-id='frameTime'][folder]");
330fb726d48Sopenharmony_ci        //@ts-ignore
331fb726d48Sopenharmony_ci        endParentRow?.childrenList?.forEach((item: TraceRow<JankStruct>): void => {
332fb726d48Sopenharmony_ci          if (item.rowId === 'actual frameTime' && item.rowType === 'janks') {
333fb726d48Sopenharmony_ci            endRowStruct = item;
334fb726d48Sopenharmony_ci          }
335fb726d48Sopenharmony_ci        });
336fb726d48Sopenharmony_ci      }
337fb726d48Sopenharmony_ci    } else {
338fb726d48Sopenharmony_ci      //@ts-ignore
339fb726d48Sopenharmony_ci      endParentRow.childrenList.forEach((item: TraceRow<JankStruct>) => {
340fb726d48Sopenharmony_ci        if (item.name.startsWith('Actual Timeline') && item.rowType === 'janks') {
341fb726d48Sopenharmony_ci          endRowStruct = item;
342fb726d48Sopenharmony_ci        }
343fb726d48Sopenharmony_ci      });
344fb726d48Sopenharmony_ci    }
345fb726d48Sopenharmony_ci  }
346fb726d48Sopenharmony_ci  if (endRowStruct) {
347fb726d48Sopenharmony_ci    //@ts-ignore
348fb726d48Sopenharmony_ci    if (endRowStruct.isComplete) {
349fb726d48Sopenharmony_ci      addPointLink(endParentRow, sp, data, startRow, selectJankStruct, endRowStruct);
350fb726d48Sopenharmony_ci    } else {
351fb726d48Sopenharmony_ci      //@ts-ignore
352fb726d48Sopenharmony_ci      endRowStruct.supplierFrame!().then((res: unknown) => {
353fb726d48Sopenharmony_ci        //@ts-ignore
354fb726d48Sopenharmony_ci        endRowStruct.dataListCache = res;
355fb726d48Sopenharmony_ci        //@ts-ignore
356fb726d48Sopenharmony_ci        endRowStruct.loadingFrame = false;
357fb726d48Sopenharmony_ci        addPointLink(endParentRow, sp, data, startRow, selectJankStruct, endRowStruct);
358fb726d48Sopenharmony_ci      });
359fb726d48Sopenharmony_ci    }
360fb726d48Sopenharmony_ci  }
361fb726d48Sopenharmony_ci}
362fb726d48Sopenharmony_ci
363fb726d48Sopenharmony_ciexport function spSystemTraceDrawJankLine(
364fb726d48Sopenharmony_ci  sp: SpSystemTrace,
365fb726d48Sopenharmony_ci  endParentRow: unknown,
366fb726d48Sopenharmony_ci  selectJankStruct: JankStruct,
367fb726d48Sopenharmony_ci  data: unknown,
368fb726d48Sopenharmony_ci  isBinderClick: boolean = false
369fb726d48Sopenharmony_ci): void {
370fb726d48Sopenharmony_ci  let collectList = sp.favoriteChartListEL!.getAllCollectRows();
371fb726d48Sopenharmony_ci  let startRow: unknown;
372fb726d48Sopenharmony_ci  if (!selectJankStruct) {
373fb726d48Sopenharmony_ci    return;
374fb726d48Sopenharmony_ci  }
375fb726d48Sopenharmony_ci  let selectRowId = 'actual frameTime';
376fb726d48Sopenharmony_ci  if (selectJankStruct.frameType === 'frameTime') {
377fb726d48Sopenharmony_ci    startRow = sp.shadowRoot?.querySelector<TraceRow<JankStruct>>(
378fb726d48Sopenharmony_ci      `trace-row[row-id='${selectRowId}'][row-type='janks']`
379fb726d48Sopenharmony_ci    );
380fb726d48Sopenharmony_ci  } else {
381fb726d48Sopenharmony_ci    selectRowId = `${selectJankStruct.type}-${selectJankStruct.pid}`;
382fb726d48Sopenharmony_ci    startRow = sp.shadowRoot?.querySelector<TraceRow<JankStruct>>(
383fb726d48Sopenharmony_ci      `trace-row[row-id='${selectRowId}'][row-type='janks']`
384fb726d48Sopenharmony_ci    );
385fb726d48Sopenharmony_ci  }
386fb726d48Sopenharmony_ci  if (!startRow) {
387fb726d48Sopenharmony_ci    for (let collectChart of collectList) {
388fb726d48Sopenharmony_ci      if (collectChart.rowId === selectRowId && collectChart.rowType === 'janks') {
389fb726d48Sopenharmony_ci        startRow = collectChart;
390fb726d48Sopenharmony_ci        break;
391fb726d48Sopenharmony_ci      }
392fb726d48Sopenharmony_ci    }
393fb726d48Sopenharmony_ci  }
394fb726d48Sopenharmony_ci  if (endParentRow) {
395fb726d48Sopenharmony_ci    drawJankLineEndParent(endParentRow, sp, data, startRow, selectJankStruct, isBinderClick);
396fb726d48Sopenharmony_ci  }
397fb726d48Sopenharmony_ci}
398fb726d48Sopenharmony_ci
399fb726d48Sopenharmony_ciexport function spSystemTraceDrawDistributedLine(
400fb726d48Sopenharmony_ci  sp: SpSystemTrace,
401fb726d48Sopenharmony_ci  sourceData: FuncStruct,
402fb726d48Sopenharmony_ci  targetData: FuncStruct,
403fb726d48Sopenharmony_ci  selectFuncStruct: FuncStruct,
404fb726d48Sopenharmony_ci): void {
405fb726d48Sopenharmony_ci  let collectList = sp.favoriteChartListEL!.getAllCollectRows() as TraceRow<BaseStruct>[];
406fb726d48Sopenharmony_ci  if (!selectFuncStruct) {
407fb726d48Sopenharmony_ci    return;
408fb726d48Sopenharmony_ci  }
409fb726d48Sopenharmony_ci  let sourceThreadRow;
410fb726d48Sopenharmony_ci  let targetThreadRow;
411fb726d48Sopenharmony_ci  let sourceRowId;
412fb726d48Sopenharmony_ci  let targetRowId;
413fb726d48Sopenharmony_ci  if (Utils.currentTraceMode === TraceMode.DISTRIBUTED) {
414fb726d48Sopenharmony_ci    sourceRowId = `${sourceData.tid}-${sourceData.traceId}`;
415fb726d48Sopenharmony_ci    targetRowId = `${targetData.tid}-${targetData.traceId}`;
416fb726d48Sopenharmony_ci    sourceThreadRow = sp.shadowRoot?.querySelector(
417fb726d48Sopenharmony_ci      `trace-row[row-id='${sourceRowId}'][row-type='func']`
418fb726d48Sopenharmony_ci    ) as TraceRow<BaseStruct>;
419fb726d48Sopenharmony_ci    targetThreadRow = sp.shadowRoot?.querySelector(
420fb726d48Sopenharmony_ci      `trace-row[row-id='${targetRowId}'][row-type='func']`
421fb726d48Sopenharmony_ci    ) as TraceRow<BaseStruct>;
422fb726d48Sopenharmony_ci  } else {
423fb726d48Sopenharmony_ci    sourceRowId = `${sourceData.tid}`;
424fb726d48Sopenharmony_ci    targetRowId = `${targetData.tid}`;
425fb726d48Sopenharmony_ci    sourceThreadRow = sp.shadowRoot?.querySelector(
426fb726d48Sopenharmony_ci      `trace-row[row-id='${sourceData.tid}'][row-type='func']`
427fb726d48Sopenharmony_ci    ) as TraceRow<BaseStruct>;
428fb726d48Sopenharmony_ci    targetThreadRow = sp.shadowRoot?.querySelector(
429fb726d48Sopenharmony_ci      `trace-row[row-id='${targetData.tid}'][row-type='func']`
430fb726d48Sopenharmony_ci    ) as TraceRow<BaseStruct>;
431fb726d48Sopenharmony_ci  }
432fb726d48Sopenharmony_ci  if (!sourceThreadRow || !targetThreadRow) {
433fb726d48Sopenharmony_ci    for (let collectChart of collectList) {
434fb726d48Sopenharmony_ci      if (
435fb726d48Sopenharmony_ci        !sourceThreadRow &&
436fb726d48Sopenharmony_ci        (Utils.currentTraceMode !== TraceMode.DISTRIBUTED || collectChart.traceId === sourceData.traceId) &&
437fb726d48Sopenharmony_ci        collectChart.rowId === sourceRowId &&
438fb726d48Sopenharmony_ci        collectChart.rowType === 'func'
439fb726d48Sopenharmony_ci      ) {
440fb726d48Sopenharmony_ci        sourceThreadRow = collectChart;
441fb726d48Sopenharmony_ci      }
442fb726d48Sopenharmony_ci      if (
443fb726d48Sopenharmony_ci        !targetThreadRow &&
444fb726d48Sopenharmony_ci        (Utils.currentTraceMode !== TraceMode.DISTRIBUTED || collectChart.traceId === targetData.traceId) &&
445fb726d48Sopenharmony_ci        collectChart.rowId === targetRowId &&
446fb726d48Sopenharmony_ci        collectChart.rowType === 'func'
447fb726d48Sopenharmony_ci      ) {
448fb726d48Sopenharmony_ci        targetThreadRow = collectChart;
449fb726d48Sopenharmony_ci      }
450fb726d48Sopenharmony_ci    }
451fb726d48Sopenharmony_ci  }
452fb726d48Sopenharmony_ci  addPointHandle(sp, sourceData, sourceThreadRow, targetData, targetThreadRow, 'distributedLine');
453fb726d48Sopenharmony_ci}
454fb726d48Sopenharmony_ci
455fb726d48Sopenharmony_cifunction taskPoolOtherRelationData(
456fb726d48Sopenharmony_ci  selectRow: unknown,
457fb726d48Sopenharmony_ci  sp: SpSystemTrace,
458fb726d48Sopenharmony_ci  //@ts-ignore
459fb726d48Sopenharmony_ci  row: TraceRow<unknown>,
460fb726d48Sopenharmony_ci  relationDataList: FuncStruct[],
461fb726d48Sopenharmony_ci  res: unknown
462fb726d48Sopenharmony_ci): void {
463fb726d48Sopenharmony_ci  sp.clearPointPair();
464fb726d48Sopenharmony_ci  //@ts-ignore
465fb726d48Sopenharmony_ci  selectRow!.fixedList = relationDataList;
466fb726d48Sopenharmony_ci  if (FuncStruct.selectFuncStruct === undefined || FuncStruct.selectFuncStruct === null) {
467fb726d48Sopenharmony_ci    return;
468fb726d48Sopenharmony_ci  }
469fb726d48Sopenharmony_ci  relationDataList.forEach((value) => {
470fb726d48Sopenharmony_ci    TabPaneTaskFrames.TaskArray.push(value);
471fb726d48Sopenharmony_ci    // allocation to execute
472fb726d48Sopenharmony_ci    const selectY = (FuncStruct.selectFuncStruct!.depth! + 0.5) * 20;
473fb726d48Sopenharmony_ci    const offSetY = (value.depth! + 0.5) * 20;
474fb726d48Sopenharmony_ci    //@ts-ignore
475fb726d48Sopenharmony_ci    const selectRowY = selectRow?.translateY!;
476fb726d48Sopenharmony_ci    const selectStartTs = FuncStruct.selectFuncStruct!.startTs!;
477fb726d48Sopenharmony_ci    const selectDur = FuncStruct.selectFuncStruct!.dur!;
478fb726d48Sopenharmony_ci    //@ts-ignore
479fb726d48Sopenharmony_ci    if (value.id === res[0].allocation_task_row) {
480fb726d48Sopenharmony_ci      sp.addPointPair(
481fb726d48Sopenharmony_ci        sp.makePoint(value.startTs!, 0, selectRowY, selectRow, offSetY, 'task', LineType.bezierCurve, true),
482fb726d48Sopenharmony_ci        sp.makePoint(selectStartTs, 0, row?.translateY!, row, selectY, 'task', LineType.bezierCurve, true)
483fb726d48Sopenharmony_ci      );
484fb726d48Sopenharmony_ci    } else {
485fb726d48Sopenharmony_ci      sp.addPointPair(
486fb726d48Sopenharmony_ci        sp.makePoint(selectStartTs, selectDur, row?.translateY!, row, selectY, 'task', LineType.bezierCurve, false),
487fb726d48Sopenharmony_ci        sp.makePoint(value.startTs!, value.dur!, selectRowY, selectRow, offSetY, 'task', LineType.bezierCurve, false)
488fb726d48Sopenharmony_ci      );
489fb726d48Sopenharmony_ci    }
490fb726d48Sopenharmony_ci  });
491fb726d48Sopenharmony_ci  sp.refreshCanvas(true);
492fb726d48Sopenharmony_ci}
493fb726d48Sopenharmony_ci
494fb726d48Sopenharmony_cifunction taskPoolRelationDataAllocation(
495fb726d48Sopenharmony_ci  executeRow: TraceRow<FuncStruct> | null | undefined,
496fb726d48Sopenharmony_ci  sp: SpSystemTrace,
497fb726d48Sopenharmony_ci  //@ts-ignore
498fb726d48Sopenharmony_ci  row: TraceRow<unknown>,
499fb726d48Sopenharmony_ci  relationDataList: FuncStruct[],
500fb726d48Sopenharmony_ci  res: unknown
501fb726d48Sopenharmony_ci): void {
502fb726d48Sopenharmony_ci  sp.clearPointPair();
503fb726d48Sopenharmony_ci  if (FuncStruct.selectFuncStruct === undefined || FuncStruct.selectFuncStruct === null) {
504fb726d48Sopenharmony_ci    return;
505fb726d48Sopenharmony_ci  }
506fb726d48Sopenharmony_ci  //@ts-ignore
507fb726d48Sopenharmony_ci  let executeStruct = relationDataList.filter((item) => item.id === res[0].execute_task_row)[0];
508fb726d48Sopenharmony_ci  relationDataList.forEach((value) => {
509fb726d48Sopenharmony_ci    const selectY = (FuncStruct.selectFuncStruct!.depth! + 0.5) * 20;
510fb726d48Sopenharmony_ci    const offSetY = (value.depth! + 0.5) * 20;
511fb726d48Sopenharmony_ci    const executeRowY = executeRow?.translateY!;
512fb726d48Sopenharmony_ci    const selectStartTs = FuncStruct.selectFuncStruct!.startTs!;
513fb726d48Sopenharmony_ci    const executeY = (executeStruct.depth! + 0.5) * 20;
514fb726d48Sopenharmony_ci    TabPaneTaskFrames.TaskArray.push(value);
515fb726d48Sopenharmony_ci    //@ts-ignore
516fb726d48Sopenharmony_ci    if (value.id === res[0].execute_task_row) {
517fb726d48Sopenharmony_ci      sp.addPointPair(
518fb726d48Sopenharmony_ci        sp.makePoint(selectStartTs, 0, row?.translateY!, row, selectY, 'task', LineType.bezierCurve, true),
519fb726d48Sopenharmony_ci        sp.makePoint(value.startTs!, 0, executeRowY, executeRow, offSetY, 'task', LineType.bezierCurve, true)
520fb726d48Sopenharmony_ci      );
521fb726d48Sopenharmony_ci    } else {
522fb726d48Sopenharmony_ci      sp.addPointPair(
523fb726d48Sopenharmony_ci        sp.makePoint(
524fb726d48Sopenharmony_ci          executeStruct.startTs!,
525fb726d48Sopenharmony_ci          executeStruct.dur!,
526fb726d48Sopenharmony_ci          executeRowY,
527fb726d48Sopenharmony_ci          executeRow,
528fb726d48Sopenharmony_ci          executeY,
529fb726d48Sopenharmony_ci          'task',
530fb726d48Sopenharmony_ci          LineType.bezierCurve,
531fb726d48Sopenharmony_ci          false
532fb726d48Sopenharmony_ci        ),
533fb726d48Sopenharmony_ci        sp.makePoint(value.startTs!, value.dur!, row?.translateY!, row, offSetY, 'task', LineType.bezierCurve, false)
534fb726d48Sopenharmony_ci      );
535fb726d48Sopenharmony_ci    }
536fb726d48Sopenharmony_ci  });
537fb726d48Sopenharmony_ci}
538fb726d48Sopenharmony_ci
539fb726d48Sopenharmony_cifunction taskPoolRelationDataPerformTask(
540fb726d48Sopenharmony_ci  executeRow: TraceRow<FuncStruct> | null | undefined,
541fb726d48Sopenharmony_ci  sp: SpSystemTrace,
542fb726d48Sopenharmony_ci  //@ts-ignore
543fb726d48Sopenharmony_ci  row: TraceRow<unknown>,
544fb726d48Sopenharmony_ci  relationDataList: FuncStruct[],
545fb726d48Sopenharmony_ci  res: unknown
546fb726d48Sopenharmony_ci): void {
547fb726d48Sopenharmony_ci  sp.clearPointPair();
548fb726d48Sopenharmony_ci  if (FuncStruct.selectFuncStruct === undefined || FuncStruct.selectFuncStruct === null) {
549fb726d48Sopenharmony_ci    return;
550fb726d48Sopenharmony_ci  }
551fb726d48Sopenharmony_ci  //@ts-ignore
552fb726d48Sopenharmony_ci  let executeStruct = relationDataList.filter((item) => item.id === res[0].execute_task_row)[0];
553fb726d48Sopenharmony_ci  relationDataList.forEach((value) => {
554fb726d48Sopenharmony_ci    const executeRowY = executeRow?.translateY!;
555fb726d48Sopenharmony_ci    const selectStartTs = FuncStruct.selectFuncStruct!.startTs!;
556fb726d48Sopenharmony_ci    const executeY = (executeStruct.depth! + 0.5) * 20;
557fb726d48Sopenharmony_ci    const selectY = (FuncStruct.selectFuncStruct!.depth! + 0.5) * 20;
558fb726d48Sopenharmony_ci    const offSetY = (value.depth! + 0.5) * 20;
559fb726d48Sopenharmony_ci    TabPaneTaskFrames.TaskArray.push(value);
560fb726d48Sopenharmony_ci    //@ts-ignore
561fb726d48Sopenharmony_ci    if (value.id === res[0].execute_task_row) {
562fb726d48Sopenharmony_ci      sp.addPointPair(
563fb726d48Sopenharmony_ci        sp.makePoint(
564fb726d48Sopenharmony_ci          selectStartTs,
565fb726d48Sopenharmony_ci          FuncStruct.selectFuncStruct!.dur!,
566fb726d48Sopenharmony_ci          row?.translateY!,
567fb726d48Sopenharmony_ci          row,
568fb726d48Sopenharmony_ci          selectY,
569fb726d48Sopenharmony_ci          'task',
570fb726d48Sopenharmony_ci          LineType.bezierCurve,
571fb726d48Sopenharmony_ci          false
572fb726d48Sopenharmony_ci        ),
573fb726d48Sopenharmony_ci        sp.makePoint(value.startTs!, value.dur!, executeRowY, executeRow, offSetY, 'task', LineType.bezierCurve, false)
574fb726d48Sopenharmony_ci      );
575fb726d48Sopenharmony_ci    } else {
576fb726d48Sopenharmony_ci      sp.addPointPair(
577fb726d48Sopenharmony_ci        sp.makePoint(executeStruct.startTs!, 0, executeRowY, executeRow, executeY, 'task', LineType.bezierCurve, true),
578fb726d48Sopenharmony_ci        sp.makePoint(value.startTs!, 0, row?.translateY!, row, offSetY, 'task', LineType.bezierCurve, true)
579fb726d48Sopenharmony_ci      );
580fb726d48Sopenharmony_ci    }
581fb726d48Sopenharmony_ci  });
582fb726d48Sopenharmony_ci  sp.refreshCanvas(true);
583fb726d48Sopenharmony_ci}
584fb726d48Sopenharmony_ci
585fb726d48Sopenharmony_ci//@ts-ignore
586fb726d48Sopenharmony_cifunction taskAllocationOrPerformTask(sp: SpSystemTrace, row: TraceRow<unknown>, executeID: string): void {
587fb726d48Sopenharmony_ci  TabPaneTaskFrames.IsShowConcurrency = false;
588fb726d48Sopenharmony_ci  sp.clearPointPair();
589fb726d48Sopenharmony_ci  queryBySelectAllocationOrReturn(executeID, FuncStruct.selectFuncStruct!.itid!).then((res) => {
590fb726d48Sopenharmony_ci    if (!FuncStruct.selectFuncStruct) {
591fb726d48Sopenharmony_ci      return;
592fb726d48Sopenharmony_ci    }
593fb726d48Sopenharmony_ci    if (FuncStruct.selectFuncStruct!.funName!.indexOf('H:Task Allocation:') >= 0 && res.length > 0) {
594fb726d48Sopenharmony_ci      let executeRow = sp.shadowRoot?.querySelector<TraceRow<FuncStruct>>(
595fb726d48Sopenharmony_ci        `trace-row[row-id='${res[0].tid}'][row-type='func']`
596fb726d48Sopenharmony_ci      );
597fb726d48Sopenharmony_ci      if (!executeRow) {
598fb726d48Sopenharmony_ci        return;
599fb726d48Sopenharmony_ci      }
600fb726d48Sopenharmony_ci      let idList: number[] = [];
601fb726d48Sopenharmony_ci      let tidList: number[] = [];
602fb726d48Sopenharmony_ci      if (res[0].execute_task_row) {
603fb726d48Sopenharmony_ci        idList.push(res[0].execute_task_row);
604fb726d48Sopenharmony_ci        tidList.push(Number(res[0].tid));
605fb726d48Sopenharmony_ci      }
606fb726d48Sopenharmony_ci      if (res[0].return_task_row) {
607fb726d48Sopenharmony_ci        idList.push(res[0].return_task_row);
608fb726d48Sopenharmony_ci        tidList.push(Number(row.rowId));
609fb726d48Sopenharmony_ci      }
610fb726d48Sopenharmony_ci      queryTaskPoolRelationData(idList, tidList).then((relationDataList) => {
611fb726d48Sopenharmony_ci        taskPoolRelationDataAllocation(executeRow, sp, row, relationDataList, res);
612fb726d48Sopenharmony_ci      });
613fb726d48Sopenharmony_ci    } else if (FuncStruct.selectFuncStruct!.funName!.indexOf('H:Task PerformTask End:') >= 0) {
614fb726d48Sopenharmony_ci      let executeRow = sp.shadowRoot?.querySelector<TraceRow<FuncStruct>>(
615fb726d48Sopenharmony_ci        `trace-row[row-id='${res[0].tid}'][row-type='func']`
616fb726d48Sopenharmony_ci      );
617fb726d48Sopenharmony_ci      TabPaneTaskFrames.TaskArray.push(FuncStruct.selectFuncStruct!);
618fb726d48Sopenharmony_ci      let idList: number[] = [];
619fb726d48Sopenharmony_ci      let tidList: number[] = [];
620fb726d48Sopenharmony_ci      if (res[0].execute_task_row) {
621fb726d48Sopenharmony_ci        idList.push(res[0].execute_task_row);
622fb726d48Sopenharmony_ci        tidList.push(Number(res[0].tid));
623fb726d48Sopenharmony_ci      }
624fb726d48Sopenharmony_ci      if (res[0].allocation_task_row) {
625fb726d48Sopenharmony_ci        idList.push(res[0].allocation_task_row);
626fb726d48Sopenharmony_ci        tidList.push(Number(row.rowId));
627fb726d48Sopenharmony_ci      }
628fb726d48Sopenharmony_ci      queryTaskPoolRelationData(idList, tidList).then((relationDataList) => {
629fb726d48Sopenharmony_ci        taskPoolRelationDataPerformTask(executeRow, sp, row, relationDataList, res);
630fb726d48Sopenharmony_ci      });
631fb726d48Sopenharmony_ci    }
632fb726d48Sopenharmony_ci  });
633fb726d48Sopenharmony_ci}
634fb726d48Sopenharmony_ci
635fb726d48Sopenharmony_ci//@ts-ignore
636fb726d48Sopenharmony_ciexport function spSystemTraceDrawTaskPollLine(sp: SpSystemTrace, row?: TraceRow<unknown>): void {
637fb726d48Sopenharmony_ci  if (FuncStruct.selectFuncStruct === undefined || FuncStruct.selectFuncStruct === null) {
638fb726d48Sopenharmony_ci    return;
639fb726d48Sopenharmony_ci  }
640fb726d48Sopenharmony_ci  let relationId = TabPaneTaskFrames.getRelationId(FuncStruct.selectFuncStruct!.funName!);
641fb726d48Sopenharmony_ci  TabPaneTaskFrames.TaskArray.push(FuncStruct.selectFuncStruct!);
642fb726d48Sopenharmony_ci  if (!row) {
643fb726d48Sopenharmony_ci    return;
644fb726d48Sopenharmony_ci  }
645fb726d48Sopenharmony_ci  if (FuncStruct.selectFuncStruct!.funName!.indexOf('H:Task Perform:') >= 0) {
646fb726d48Sopenharmony_ci    TabPaneTaskFrames.IsShowConcurrency = true;
647fb726d48Sopenharmony_ci    queryBySelectExecute(relationId, FuncStruct.selectFuncStruct!.itid!).then((res) => {
648fb726d48Sopenharmony_ci      if (res.length === 1) {
649fb726d48Sopenharmony_ci        let allocationRowId = res[0].tid;
650fb726d48Sopenharmony_ci        let selectRow = sp.shadowRoot?.querySelector<TraceRow<FuncStruct>>(
651fb726d48Sopenharmony_ci          `trace-row[row-id='${allocationRowId}'][row-type='func']`
652fb726d48Sopenharmony_ci        );
653fb726d48Sopenharmony_ci        if (!selectRow) {
654fb726d48Sopenharmony_ci          let collectList = sp.favoriteChartListEL!.getAllCollectRows();
655fb726d48Sopenharmony_ci          for (let selectCollectRow of collectList) {
656fb726d48Sopenharmony_ci            if (selectCollectRow.rowId === allocationRowId.toString() && selectCollectRow.rowType === 'func') {
657fb726d48Sopenharmony_ci              // @ts-ignore
658fb726d48Sopenharmony_ci              selectRow = selectCollectRow;
659fb726d48Sopenharmony_ci              break;
660fb726d48Sopenharmony_ci            }
661fb726d48Sopenharmony_ci          }
662fb726d48Sopenharmony_ci        }
663fb726d48Sopenharmony_ci        let idList: number[] = [];
664fb726d48Sopenharmony_ci        if (res[0].allocation_task_row) {
665fb726d48Sopenharmony_ci          idList.push(res[0].allocation_task_row);
666fb726d48Sopenharmony_ci        }
667fb726d48Sopenharmony_ci        if (res[0].return_task_row) {
668fb726d48Sopenharmony_ci          idList.push(res[0].return_task_row);
669fb726d48Sopenharmony_ci        }
670fb726d48Sopenharmony_ci        queryTaskPoolOtherRelationData(idList, allocationRowId).then((relationDataList) => {
671fb726d48Sopenharmony_ci          taskPoolOtherRelationData(selectRow, sp, row, relationDataList, res);
672fb726d48Sopenharmony_ci        });
673fb726d48Sopenharmony_ci      }
674fb726d48Sopenharmony_ci    });
675fb726d48Sopenharmony_ci  } else {
676fb726d48Sopenharmony_ci    taskAllocationOrPerformTask(sp, row, relationId);
677fb726d48Sopenharmony_ci  }
678fb726d48Sopenharmony_ci}
679fb726d48Sopenharmony_ci
680fb726d48Sopenharmony_cifunction jankPoint(
681fb726d48Sopenharmony_ci  endRowStruct: unknown,
682fb726d48Sopenharmony_ci  selectThreadStruct: ThreadStruct,
683fb726d48Sopenharmony_ci  startRow: unknown,
684fb726d48Sopenharmony_ci  endParentRow: unknown,
685fb726d48Sopenharmony_ci  sp: SpSystemTrace
686fb726d48Sopenharmony_ci): void {
687fb726d48Sopenharmony_ci  //@ts-ignore
688fb726d48Sopenharmony_ci  let findJankEntry = endRowStruct!.fixedList[0];
689fb726d48Sopenharmony_ci  let ts: number = 0;
690fb726d48Sopenharmony_ci  if (findJankEntry) {
691fb726d48Sopenharmony_ci    ts = selectThreadStruct.startTime! + selectThreadStruct.dur! / 2;
692fb726d48Sopenharmony_ci    const [startY, startRowEl, startOffSetY] = sp.calculateStartY(startRow, selectThreadStruct.pid);
693fb726d48Sopenharmony_ci    const [endY, endRowEl, endOffSetY] = sp.calculateEndY(endParentRow, endRowStruct);
694fb726d48Sopenharmony_ci    sp.addPointPair(
695fb726d48Sopenharmony_ci      sp.makePoint(
696fb726d48Sopenharmony_ci        ns2xByTimeShaft(ts, sp.timerShaftEL!),
697fb726d48Sopenharmony_ci        ts,
698fb726d48Sopenharmony_ci        startY,
699fb726d48Sopenharmony_ci        startRowEl!,
700fb726d48Sopenharmony_ci        startOffSetY,
701fb726d48Sopenharmony_ci        'thread',
702fb726d48Sopenharmony_ci        LineType.straightLine,
703fb726d48Sopenharmony_ci        selectThreadStruct.startTime === ts
704fb726d48Sopenharmony_ci      ),
705fb726d48Sopenharmony_ci      sp.makePoint(
706fb726d48Sopenharmony_ci        ns2xByTimeShaft(findJankEntry.startTime!, sp.timerShaftEL!),
707fb726d48Sopenharmony_ci        findJankEntry.startTime!,
708fb726d48Sopenharmony_ci        endY,
709fb726d48Sopenharmony_ci        endRowEl,
710fb726d48Sopenharmony_ci        endOffSetY,
711fb726d48Sopenharmony_ci        'thread',
712fb726d48Sopenharmony_ci        LineType.straightLine,
713fb726d48Sopenharmony_ci        true
714fb726d48Sopenharmony_ci      )
715fb726d48Sopenharmony_ci    );
716fb726d48Sopenharmony_ci  }
717fb726d48Sopenharmony_ci}
718fb726d48Sopenharmony_ci
719fb726d48Sopenharmony_cifunction junkBinder(
720fb726d48Sopenharmony_ci  endRowStruct: unknown,
721fb726d48Sopenharmony_ci  selectFuncStruct: FuncStruct,
722fb726d48Sopenharmony_ci  startRow: unknown,
723fb726d48Sopenharmony_ci  endParentRow: unknown,
724fb726d48Sopenharmony_ci  sp: SpSystemTrace,
725fb726d48Sopenharmony_ci  data: unknown
726fb726d48Sopenharmony_ci): void {
727fb726d48Sopenharmony_ci  // @ts-ignore
728fb726d48Sopenharmony_ci  let findJankEntry = endRowStruct!.fixedList[0];
729fb726d48Sopenharmony_ci  let ts: number = 0;
730fb726d48Sopenharmony_ci  if (findJankEntry) {
731fb726d48Sopenharmony_ci    ts = selectFuncStruct.startTs! + selectFuncStruct.dur! / 2;
732fb726d48Sopenharmony_ci    const [startY, startRowEl, startOffSetY] = sp.calculateStartY(startRow, selectFuncStruct.pid, selectFuncStruct);
733fb726d48Sopenharmony_ci    const [endY, endRowEl, endOffSetY] = sp.calculateEndY(endParentRow, endRowStruct, data);
734fb726d48Sopenharmony_ci    sp.addPointPair(
735fb726d48Sopenharmony_ci      sp.makePoint(
736fb726d48Sopenharmony_ci        ns2xByTimeShaft(ts, sp.timerShaftEL!),
737fb726d48Sopenharmony_ci        ts,
738fb726d48Sopenharmony_ci        startY,
739fb726d48Sopenharmony_ci        startRowEl!,
740fb726d48Sopenharmony_ci        startOffSetY,
741fb726d48Sopenharmony_ci        'func',
742fb726d48Sopenharmony_ci        LineType.straightLine,
743fb726d48Sopenharmony_ci        selectFuncStruct.startTs === ts
744fb726d48Sopenharmony_ci      ),
745fb726d48Sopenharmony_ci      sp.makePoint(
746fb726d48Sopenharmony_ci        ns2xByTimeShaft(findJankEntry.startTs!, sp.timerShaftEL!),
747fb726d48Sopenharmony_ci        findJankEntry.startTs!,
748fb726d48Sopenharmony_ci        endY,
749fb726d48Sopenharmony_ci        endRowEl,
750fb726d48Sopenharmony_ci        endOffSetY,
751fb726d48Sopenharmony_ci        'func',
752fb726d48Sopenharmony_ci        LineType.straightLine,
753fb726d48Sopenharmony_ci        true
754fb726d48Sopenharmony_ci      )
755fb726d48Sopenharmony_ci    );
756fb726d48Sopenharmony_ci  }
757fb726d48Sopenharmony_ci}
758fb726d48Sopenharmony_ci
759fb726d48Sopenharmony_ciexport function spSystemTraceDrawThreadLine(
760fb726d48Sopenharmony_ci  sp: SpSystemTrace,
761fb726d48Sopenharmony_ci  endParentRow: unknown,
762fb726d48Sopenharmony_ci  selectThreadStruct: ThreadStruct | undefined,
763fb726d48Sopenharmony_ci  data: unknown
764fb726d48Sopenharmony_ci): void {
765fb726d48Sopenharmony_ci  let collectList = sp.favoriteChartListEL!.getCollectRows();
766fb726d48Sopenharmony_ci  if (!selectThreadStruct) {
767fb726d48Sopenharmony_ci    return;
768fb726d48Sopenharmony_ci  }
769fb726d48Sopenharmony_ci  let selectRowId = selectThreadStruct.tid;
770fb726d48Sopenharmony_ci  let startRow = sp.getStartRow(selectRowId, collectList);
771fb726d48Sopenharmony_ci
772fb726d48Sopenharmony_ci  if (endParentRow) {
773fb726d48Sopenharmony_ci    //@ts-ignore
774fb726d48Sopenharmony_ci    endParentRow.expansion = true;
775fb726d48Sopenharmony_ci    let endRowStruct: unknown = sp.shadowRoot?.querySelector<TraceRow<ThreadStruct>>(
776fb726d48Sopenharmony_ci      //@ts-ignore
777fb726d48Sopenharmony_ci      `trace-row[row-id='${data.tid}'][row-type='thread']`
778fb726d48Sopenharmony_ci    );
779fb726d48Sopenharmony_ci    if (!endRowStruct) {
780fb726d48Sopenharmony_ci      //@ts-ignore
781fb726d48Sopenharmony_ci      endRowStruct = endParentRow.childrenList.find((item: TraceRow<ThreadStruct>) => {
782fb726d48Sopenharmony_ci        //@ts-ignore
783fb726d48Sopenharmony_ci        return item.rowId === `${data.tid}` && item.rowType === 'thread';
784fb726d48Sopenharmony_ci      });
785fb726d48Sopenharmony_ci    }
786fb726d48Sopenharmony_ci    if (endRowStruct) {
787fb726d48Sopenharmony_ci      //@ts-ignore
788fb726d48Sopenharmony_ci      if (endRowStruct.isComplete) {
789fb726d48Sopenharmony_ci        jankPoint(endRowStruct, selectThreadStruct, startRow, endParentRow, sp);
790fb726d48Sopenharmony_ci      }
791fb726d48Sopenharmony_ci    }
792fb726d48Sopenharmony_ci  }
793fb726d48Sopenharmony_ci}
794fb726d48Sopenharmony_ci
795fb726d48Sopenharmony_ciexport function spSystemTraceDrawFuncLine(
796fb726d48Sopenharmony_ci  sp: SpSystemTrace,
797fb726d48Sopenharmony_ci  endParentRow: unknown,
798fb726d48Sopenharmony_ci  selectFuncStruct: FuncStruct | undefined,
799fb726d48Sopenharmony_ci  data: unknown,
800fb726d48Sopenharmony_ci  binderTid: Number
801fb726d48Sopenharmony_ci): void {
802fb726d48Sopenharmony_ci  let collectList = sp.favoriteChartListEL!.getCollectRows();
803fb726d48Sopenharmony_ci  if (selectFuncStruct === undefined || selectFuncStruct === null) {
804fb726d48Sopenharmony_ci    return;
805fb726d48Sopenharmony_ci  }
806fb726d48Sopenharmony_ci  let selectRowId = selectFuncStruct?.tid ? selectFuncStruct?.tid : binderTid.toString();
807fb726d48Sopenharmony_ci  let startRow = sp.shadowRoot?.querySelector<TraceRow<FuncStruct>>(`trace-row[row-id='${selectRowId}'][row-type='func']`);
808fb726d48Sopenharmony_ci  if (!startRow) {
809fb726d48Sopenharmony_ci    for (let collectChart of collectList) {
810fb726d48Sopenharmony_ci      if (collectChart.rowId === selectRowId.toString() && collectChart.rowType === 'func') {
811fb726d48Sopenharmony_ci        startRow = collectChart as TraceRow<FuncStruct>;
812fb726d48Sopenharmony_ci        break;
813fb726d48Sopenharmony_ci      }
814fb726d48Sopenharmony_ci    }
815fb726d48Sopenharmony_ci  }
816fb726d48Sopenharmony_ci  if (endParentRow) {
817fb726d48Sopenharmony_ci    // @ts-ignore
818fb726d48Sopenharmony_ci    endParentRow.expansion = true;
819fb726d48Sopenharmony_ci    let endRowStruct: unknown = sp.shadowRoot?.querySelector<TraceRow<FuncStruct>>(
820fb726d48Sopenharmony_ci      // @ts-ignore
821fb726d48Sopenharmony_ci      `trace-row[row-id='${data.tid}'][row-type='func']`
822fb726d48Sopenharmony_ci    );
823fb726d48Sopenharmony_ci    if (!endRowStruct) {
824fb726d48Sopenharmony_ci      // @ts-ignore
825fb726d48Sopenharmony_ci      endRowStruct = endParentRow.childrenList.find((item: TraceRow<FuncStruct>) => {
826fb726d48Sopenharmony_ci        // @ts-ignore
827fb726d48Sopenharmony_ci        return item.rowId === `${data.tid}` && item.rowType === 'func';
828fb726d48Sopenharmony_ci      });
829fb726d48Sopenharmony_ci    }
830fb726d48Sopenharmony_ci    if (endRowStruct) {
831fb726d48Sopenharmony_ci      junkBinder(endRowStruct, selectFuncStruct, startRow, endParentRow, sp, data);
832fb726d48Sopenharmony_ci    }
833fb726d48Sopenharmony_ci  }
834fb726d48Sopenharmony_ci}
835