feat: WebFrameMain.collectJavaScriptCallStack() (#44937)
* feat: WebFrameMain.unresponsiveDocumentJSCallStack Co-authored-by: Samuel Maddock <smaddock@slack-corp.com> * Revert "feat: WebFrameMain.unresponsiveDocumentJSCallStack" This reverts commit e0612bc1a00a5282cba5df97da3c9c90e96ef244. Co-authored-by: Samuel Maddock <smaddock@slack-corp.com> * feat: frame.collectJavaScriptCallStack() Co-authored-by: Samuel Maddock <smaddock@slack-corp.com> * feat: frame.collectJavaScriptCallStack() Co-authored-by: Samuel Maddock <smaddock@slack-corp.com> * Update web-frame-main.md Co-authored-by: Sam Maddock <smaddock@slack-corp.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
This commit is contained in:
parent
7d2d5240bd
commit
e1d9df224c
5 changed files with 131 additions and 1 deletions
|
@ -142,6 +142,29 @@ ipcRenderer.on('port', (e, msg) => {
|
|||
})
|
||||
```
|
||||
|
||||
#### `frame.collectJavaScriptCallStack()` _Experimental_
|
||||
|
||||
Returns `Promise<string> | Promise<void>` - A promise that resolves with the currently running JavaScript call
|
||||
stack. If no JavaScript runs in the frame, the promise will never resolve. In cases where the call stack is
|
||||
otherwise unable to be collected, it will return `undefined`.
|
||||
|
||||
This can be useful to determine why the frame is unresponsive in cases where there's long-running JavaScript.
|
||||
For more information, see the [proposed Crash Reporting API.](https://wicg.github.io/crash-reporting/)
|
||||
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
app.commandLine.appendSwitch('enable-features', 'DocumentPolicyIncludeJSCallStacksInCrashReports')
|
||||
|
||||
app.on('web-contents-created', (_, webContents) => {
|
||||
webContents.on('unresponsive', async () => {
|
||||
// Interrupt execution and collect call stack from unresponsive renderer
|
||||
const callStack = await webContents.mainFrame.collectJavaScriptCallStack()
|
||||
console.log('Renderer unresponsive\n', callStack)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
### Instance Properties
|
||||
|
||||
#### `frame.ipc` _Readonly_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue