Skip to content

chore: log js stacks from unresponsive window #241390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 24, 2025

Conversation

deepak1556
Copy link
Collaborator

@deepak1556 deepak1556 commented Feb 20, 2025

Fixes #240178

Logs look as follows in a simulated unresponsiveness,

5:22)) color: blue color:  color: grey", source: vscode-file://vscode-app/Users/demohan/github/vscode/out/vs/base/common/console.js (98)
[main 2025-03-17T17:10:38.215Z] CodeWindow: detected unresponsive
[main 2025-03-17T17:10:53.220Z] CodeWindow unresponsive samples:
<14> 
    at AuxiliaryEditorPart.create (vscode-file://vscode-app/Users/demohan/github/vscode/out/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js:86:9)
    at EditorParts.createAuxiliaryEditorPart (vscode-file://vscode-app/Users/demohan/github/vscode/out/vs/workbench/browser/parts/editor/editorParts.js:111:135)
    at MoveEditorToNewWindowAction.run (vscode-file://vscode-app/Users/demohan/github/vscode/out/vs/workbench/browser/parts/editor/editorActions.js:2106:63)
    at handler (vscode-file://vscode-app/Users/demohan/github/vscode/out/vs/platform/actions/common/actions.js:429:48)
    at InstantiationService.invokeFunction (vscode-file://vscode-app/Users/demohan/github/vscode/out/vs/platform/instantiation/common/instantiationService.js:84:20)
    at CommandService._tryExecuteCommand (vscode-file://vscode-app/Users/demohan/github/vscode/out/vs/workbench/services/commands/common/commandService.js:85:55)
    at CommandService.executeCommand (vscode-file://vscode-app/Users/demohan/github/vscode/out/vs/workbench/services/commands/common/commandService.js:54:29)
    at MenuItemAction.run (vscode-file://vscode-app/Users/demohan/github/vscode/out/vs/platform/actions/common/actions.js:406:37)
    at NativeContextMenuService.runAction (vscode-file://vscode-app/Users/demohan/github/vscode/out/vs/workbench/services/contextmenu/electron-sandbox/contextmenuService.js:230:35)
    at Object.click (vscode-file://vscode-app/Users/demohan/github/vscode/out/vs/workbench/services/contextmenu/electron-sandbox/contextmenuService.js:201:26)
Total Samples: 14

@deepak1556 deepak1556 added this to the February 2025 milestone Feb 20, 2025
@deepak1556 deepak1556 requested a review from bpasero February 20, 2025 20:12
@deepak1556 deepak1556 self-assigned this Feb 20, 2025
Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why we need to collect the stack every second, maybe we just start with collecting it once in the beginning and a second time after 5 seconds?

@jrieken
Copy link
Member

jrieken commented Feb 21, 2025

also let's remove src/vs/workbench/contrib/performance/electron-sandbox/rendererAutoProfiler.ts when this is done

@aeschli aeschli modified the milestones: February 2025, March 2025 Feb 25, 2025
@deepak1556 deepak1556 force-pushed the robo/add_stack_collector_unresponsive_renderer branch from 5a615f1 to e4bbec3 Compare March 17, 2025 17:15
@deepak1556 deepak1556 requested a review from bpasero March 17, 2025 17:16
@deepak1556 deepak1556 force-pushed the robo/add_stack_collector_unresponsive_renderer branch from e4bbec3 to f4c5f95 Compare March 18, 2025 04:15
@deepak1556 deepak1556 force-pushed the robo/add_stack_collector_unresponsive_renderer branch from f4c5f95 to 4c5d6c8 Compare March 18, 2025 05:43
@deepak1556 deepak1556 requested a review from bpasero March 18, 2025 05:55
bpasero
bpasero previously approved these changes Mar 18, 2025
@deepak1556 deepak1556 marked this pull request as draft March 24, 2025 09:07
@deepak1556 deepak1556 force-pushed the robo/add_stack_collector_unresponsive_renderer branch from ea95872 to ff1bc9b Compare March 24, 2025 11:05
samples += count;
// If the stack appears more than 20 percent of the time, log it
// to the error telemetry as UnresponsiveSampleError.
if (Math.round((count * 100) / this.jsCallStackEffectiveSampleCount) > 20) {
Copy link
Collaborator Author

@deepak1556 deepak1556 Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken inspiration from renderer auto profiler but unlike the auto profiler we don't have individual frame timings, given the samples are sorted by their effective appearance over the sample period, I feel this should cover the interesting bits to error telemetry as UnresponsiveSampleError

Adding the window id and process id to the error message so that we can aggregate them. Let me know if there are better markers to add.

@deepak1556 deepak1556 requested a review from jrieken March 24, 2025 11:09
@deepak1556 deepak1556 requested a review from bpasero March 24, 2025 11:09
@deepak1556 deepak1556 marked this pull request as ready for review March 24, 2025 11:09
@deepak1556 deepak1556 merged commit 395bdde into main Mar 24, 2025
8 checks passed
@deepak1556 deepak1556 deleted the robo/add_stack_collector_unresponsive_renderer branch March 24, 2025 13:25
}

this.jsCallStackMap = new Map<string, number>();
this.jsCallStackEffectiveSampleCount = Math.round(sampleInterval / samplePeriod);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this be zero, and then cause div-by-zero below?

> parseInt('1000') / parseInt('15000')
0.06666666666666667
> Math.round(parseInt('1000') / parseInt('15000'))
0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepak1556 can you check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, good catch. It should have been the other way.

this.jsCallStackEffectiveSampleCount = Math.round(samplePeriod / sampleInterval);

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adopt webFrameMain.collectJavaScriptCallStack
5 participants