mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-12 00:49:14 +08:00
feat: enhance unresponsive renderer handling and crash reporting (#6995)
* feat: enhance unresponsive renderer handling and crash reporting * Added support for collecting JavaScript call stacks from unresponsive renderers. * Updated the Document Policy in the HTML to include JS call stacks in crash reports. * Removed legacy unresponsive logging from WindowService. * feat: improve unresponsive renderer handling and update crash reporting * Added session web request handling to include Document-Policy for JS call stacks in crash reports. * Removed legacy Document-Policy meta tag from HTML. * Enhanced logging for unresponsive renderer call stacks. * fix: remove unused session import in index.ts --------- Co-authored-by: beyondkmp <beyondkmkp@gmail.com>
This commit is contained in:
parent
ac7d4cb4fa
commit
b951d89c6a
@ -34,6 +34,26 @@ if (isWin) {
|
|||||||
app.commandLine.appendSwitch('wm-window-animations-disabled')
|
app.commandLine.appendSwitch('wm-window-animations-disabled')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable features for unresponsive renderer js call stacks
|
||||||
|
app.commandLine.appendSwitch('enable-features', 'DocumentPolicyIncludeJSCallStacksInCrashReports')
|
||||||
|
app.on('web-contents-created', (_, webContents) => {
|
||||||
|
webContents.session.webRequest.onHeadersReceived((details, callback) => {
|
||||||
|
callback({
|
||||||
|
responseHeaders: {
|
||||||
|
...details.responseHeaders,
|
||||||
|
'Document-Policy': ['include-js-call-stacks-in-crash-reports']
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
webContents.on('unresponsive', async () => {
|
||||||
|
// Interrupt execution and collect call stack from unresponsive renderer
|
||||||
|
Logger.error('Renderer unresponsive start')
|
||||||
|
const callStack = await webContents.mainFrame.collectJavaScriptCallStack()
|
||||||
|
Logger.error('Renderer unresponsive js call stack\n', callStack)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// in production mode, handle uncaught exception and unhandled rejection globally
|
// in production mode, handle uncaught exception and unhandled rejection globally
|
||||||
if (!isDev) {
|
if (!isDev) {
|
||||||
// handle uncaught exception
|
// handle uncaught exception
|
||||||
|
|||||||
@ -116,12 +116,6 @@ export class WindowService {
|
|||||||
app.exit(1)
|
app.exit(1)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mainWindow.webContents.on('unresponsive', () => {
|
|
||||||
// 在升级到electron 34后,可以获取具体js stack trace,目前只打个日志监控下
|
|
||||||
// https://www.electronjs.org/blog/electron-34-0#unresponsive-renderer-javascript-call-stacks
|
|
||||||
Logger.error('Renderer process unresponsive')
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupMaximize(mainWindow: BrowserWindow, isMaximized: boolean) {
|
private setupMaximize(mainWindow: BrowserWindow, isMaximized: boolean) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user