-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
ANR Detection Improvements Needed for Modal Dialog Handling #1016
Comments
https://www.electronjs.org/docs/latest/api/dialog#dialogshowsavedialogwindow-options this is the electron API, i do not have anymore concrete examples of modals yet |
You could create a helper function that disables ANR while the callback is being called. It would look something like this: export async function disableAnrIntegration<T>(doWork: () => Promise<T>): Promise<T> {
const integration = getClient()?.getIntegrationByName('Anr') as ReturnType<typeof nodeAnrIntegration> | undefined;
try {
integration?.stopWorker();
return await doWork();
} finally {
integration?.startWorker();
}
} This would then be used like this: const result = await disableAnrIntegration(() => dialog.showSaveDialog()); I'll get something like this added to the SDK so it's easier to use. We could automatically wrap everything in the Electron |
Hey @timfish I'm the original engineer at Sentry that proposed this feedback from a client. So it looks like the above draft would expose methods to manually pause/resume ANR detection? Would this also implement automatic detection of when system modal dialogs appear? For further context, this feedback was provided to Sentry in response to how we handle the showSaveDialog modal. The application in-question presents a save dialogue box to open/save data, which invokes an intentional UI blockage, but the Electron SDK currently flags that as an app freeze. As a result, false positives are captured. |
I've proposed adding this to the Node SDK (where the ANR feature originates) getsentry/sentry-javascript#14359 Once that is merged I can automatically wrap the Electron dialog code in this SDK which should fix the issue. |
@timfish how would wrapping the Electron dialog code automatically affect end users who'd still prefer to wrap modals manually? Perhaps this could be built as an integration or flag to accommodate? |
I think initially it will be left up to users to wrap these manually and we will consider wrapping automatically optionally later? |
- Ref getsentry/sentry-electron#1016 ```ts disableAnrDetectionForCallback(() => dialog.openSaveDialog()); ``` Maybe this should just go in the Electron SDK? I added it for Node because it may be useful outside of Electron and at least here it has access to some private variables and types.
Problem Statement
Summary
The current ANR (Application Not Responding) detection in the Electron SDK generates false positives when modal dialogs are shown, particularly on Windows. This leads to misleading non-responsiveness reports for intentional UI pauses.
Problem Description
When using modal dialogs (e.g.,
dialog.showSaveDialog
) in Electron applications, the UI thread is intentionally blocked while waiting for user input. However, the ANR detection system interprets this as an application freeze and generates false positive reports.Current Behavior
Expected Behavior
The ANR detection should:
Solution Brainstorm
Automatic Detection:
API Improvements:
Enhanced Context:
Impact
Related Documentation
Notes
powerMonitor
events exist but aren't officially supported/documentedThe text was updated successfully, but these errors were encountered: