Skip to content

Commit 39c3482

Browse files
committed
cherry-pick(#21839): chore: sort tracing actions by wall time
1 parent 0646773 commit 39c3482

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

packages/playwright-core/src/server/dispatchers/dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export class DispatcherConnection {
246246
const sdkObject = dispatcher._object instanceof SdkObject ? dispatcher._object : undefined;
247247
const callMetadata: CallMetadata = {
248248
id: `call@${id}`,
249-
wallTime: validMetadata.wallTime,
249+
wallTime: validMetadata.wallTime || Date.now(),
250250
location: validMetadata.location,
251251
apiName: validMetadata.apiName,
252252
internal: validMetadata.internal,

packages/playwright-core/src/server/instrumentation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export function serverSideCallMetadata(): CallMetadata {
108108
id: '',
109109
startTime: 0,
110110
endTime: 0,
111+
wallTime: Date.now(),
111112
type: 'Internal',
112113
method: '',
113114
params: {},

packages/playwright-core/src/server/recorder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ class ContextRecorder extends EventEmitter {
574574
frameId: frame.guid,
575575
startTime: monotonicTime(),
576576
endTime: 0,
577+
wallTime: Date.now(),
577578
type: 'Frame',
578579
method: action,
579580
params,

packages/playwright-core/src/server/trace/recorder/tracing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ function createBeforeActionTraceEvent(metadata: CallMetadata): trace.BeforeActio
489489
class: metadata.type,
490490
method: metadata.method,
491491
params: metadata.params,
492-
wallTime: metadata.wallTime || Date.now(),
492+
wallTime: metadata.wallTime,
493493
pageId: metadata.pageId,
494494
};
495495
}

packages/playwright-test/src/worker/testInfo.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ export class TestInfoImpl implements TestInfo {
249249
stepId,
250250
...data,
251251
location,
252-
wallTime: Date.now(),
253252
};
254253
this._onStepBegin(payload);
255254
return step;

packages/protocol/src/callMetadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type CallMetadata = {
3333
// through the dispatcher, so is always excluded from inspector / tracing.
3434
isServerSide?: boolean;
3535
// Client wall time.
36-
wallTime?: number;
36+
wallTime: number;
3737
location?: { file: string, line?: number, column?: number };
3838
log: string[];
3939
error?: SerializedError;

packages/trace-viewer/src/ui/modelUtil.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ export class MultiTraceModel {
6666
this.events = ([] as EventTraceEvent[]).concat(...contexts.map(c => c.events));
6767
this.hasSource = contexts.some(c => c.hasSource);
6868

69-
this.actions.sort((a1, a2) => (a1.startTime - a2.startTime) || (a1.endTime - a2.endTime));
7069
this.events.sort((a1, a2) => a1.time - a2.time);
71-
this.actions = dedupeActions(this.actions);
70+
this.actions = dedupeAndSortActions(this.actions);
7271
this.sources = collectSources(this.actions);
7372
}
7473
}
@@ -85,7 +84,7 @@ function indexModel(context: ContextEntry) {
8584
(event as any)[contextSymbol] = context;
8685
}
8786

88-
function dedupeActions(actions: ActionTraceEvent[]) {
87+
function dedupeAndSortActions(actions: ActionTraceEvent[]) {
8988
const callActions = actions.filter(a => a.callId.startsWith('call@'));
9089
const expectActions = actions.filter(a => a.callId.startsWith('expect@'));
9190

@@ -115,7 +114,7 @@ function dedupeActions(actions: ActionTraceEvent[]) {
115114
result.push(expectAction);
116115
}
117116

118-
result.sort((a1, a2) => a1.startTime - a2.startTime);
117+
result.sort((a1, a2) => (a1.wallTime - a2.wallTime));
119118
for (let i = 1; i < result.length; ++i)
120119
(result[i] as any)[prevInListSymbol] = result[i - 1];
121120
return result;

packages/trace-viewer/src/ui/watchMode.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ const TestList: React.FC<{
413413
render={treeItem => {
414414
return <div className='hbox watch-mode-list-item'>
415415
<div className='watch-mode-list-item-title'>{treeItem.title}</div>
416-
{!!treeItem.duration && <div className='watch-mode-list-item-time'>{msToString(treeItem.duration)}</div>}
416+
{!!treeItem.duration && treeItem.status !== 'skipped' && <div className='watch-mode-list-item-time'>{msToString(treeItem.duration)}</div>}
417417
<Toolbar noMinHeight={true} noShadow={true}>
418418
<ToolbarButton icon='play' title='Run' onClick={() => runTreeItem(treeItem)} disabled={!!runningState}></ToolbarButton>
419419
<ToolbarButton icon='go-to-file' title='Open in VS Code' onClick={() => sendMessageNoReply('open', { location: locationToOpen(treeItem) })}></ToolbarButton>

0 commit comments

Comments
 (0)