Skip to content
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 Events not correct when cover the screen #1035

Open
3 tasks done
l3ve opened this issue Dec 16, 2024 · 4 comments · Fixed by #1036 · May be fixed by #1083
Open
3 tasks done

ANR Events not correct when cover the screen #1035

l3ve opened this issue Dec 16, 2024 · 4 comments · Fixed by #1036 · May be fixed by #1083
Assignees

Comments

@l3ve
Copy link

l3ve commented Dec 16, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Electron SDK Version

5.8.0

Electron Version

31.2.1

What platform are you using?

MacOS

Link to Sentry event

No response

Steps to Reproduce

  1. Test in Electron Fiddle

//  main.js
const { app, BrowserWindow, powerMonitor } = require('electron')
const path = require('node:path')

function createWindow() {
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js')
    }
  })
  mainWindow.loadFile('index.html')
  mainWindow.webContents.openDevTools()
}
app.whenReady().then(() => {
  createWindow()
  powerMonitor.on('lock-screen', () => {
    console.log('lock-screen', new Date().toLocaleString("chinese", {
      hour12: false,
      timeZone: "Asia/Shanghai"
    }))
  })

  powerMonitor.on('unlock-screen', () => {
    console.log('unlock-screen', new Date().toLocaleString("chinese", {
      hour12: false,
      timeZone: "Asia/Shanghai"
    }))
  })
  app.on('activate', function () {
    if (BrowserWindow.getAllWindows().length === 0) createWindow()
  })
})
app.on('window-all-closed', function () {
  if (process.platform !== 'darwin') app.quit()
})
// renderer.js
document.addEventListener('visibilitychange', () => {
    console.log('document.visibilityState:', document.visibilityState, new Date().toLocaleString("chinese", {
      hour12: false,
      timeZone: "Asia/Shanghai"
    }))
});
  1. cover the screen, over 20s
  2. open the screen
  3. it will emit the anr event, becouse the visibilitychange event isn't emit in time
  4. the powerMonitor event is correct
  • visibilitychange(hidden) emit when open the screen(lock)
  • visibilitychange(visible) emit when open the screen(unlock)
Image

Expected Result

ignore anr events when cover the screen

Actual Result

ANR Events emited when cover the screen

@Lms24
Copy link
Member

Lms24 commented Dec 16, 2024

Hey, thanks for writing in! @timfish when you get a chance, would you mind taking a look? thanks!

@timfish
Copy link
Collaborator

timfish commented Dec 16, 2024

Yep just looking at this. We already disable ANR between suspend and resume events and it looks like we need to do the same for lock-screen and unlock-screen too.

@l3ve
Copy link
Author

l3ve commented Feb 12, 2025

After upgrading to the new version, another ANR was triggered, which seems to be the timing of the visibilitychange event is not convenient.

"@sentry/electron": "5.11.0"

Image

@l3ve
Copy link
Author

l3ve commented Feb 12, 2025

@timfish @Lms24 Please take a look. thx~

@timfish timfish reopened this Feb 12, 2025
@timfish timfish linked a pull request Feb 14, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
3 participants