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

fix(app): throw error popup when close window #1144

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

BlackHole1
Copy link
Contributor

Description

Once the window is destroyed, none of the window's methods can be used (except for destroy and isDestroyed).

Linked Issues

Fix: #1127 #1092

Additional context

The reason that destroy can be called multiple times is that Electron performs a check: https://github.com/electron/electron/blob/57920e7747f09627f99ed5c27457339aa7c3fe57/shell/common/gin_helper/destroyable.cc#L28

The ability to call isDestroyed is because no window methods are used during the implementation process: https://github.com/electron/electron/blob/57920e7747f09627f99ed5c27457339aa7c3fe57/shell/common/gin_helper/destroyable.cc#L48-L49

Once the window is destroyed, none of the window's methods can be used (except for `destroy` and `isDestroyed`).

The reason that destroy can be called multiple times is that Electron performs a check: https://github.com/electron/electron/blob/57920e7747f09627f99ed5c27457339aa7c3fe57/shell/common/gin_helper/destroyable.cc#L28

The ability to call isDestroyed is because no window methods are used during the implementation process: https://github.com/electron/electron/blob/57920e7747f09627f99ed5c27457339aa7c3fe57/shell/common/gin_helper/destroyable.cc#L48-L49

Signed-off-by: Kevin Cui <bh@bugs.cc>
Copy link

vercel bot commented Oct 25, 2024

@BlackHole1 is attempting to deploy a commit to the RSS3 Team on Vercel.

A member of the Team first needs to authorize it.

@BlackHole1 BlackHole1 changed the title fix(windows): throw error popup when update app fix(app): throw error popup when close window Oct 25, 2024
@BlackHole1
Copy link
Contributor Author

This issue occurs intermittently, and the fundamental reason for this problem is that there are other places that are destroying the window. The code is as follows:

export const quitAndInstall = () => {
const mainWindow = getMainWindow()
destroyMainWindow()

app.on("before-quit", () => {
const windows = BrowserWindow.getAllWindows()
windows.forEach((window) => window.destroy())
})

Both pieces of code could trigger this issue, but the first one is more likely to do so. The second one is less frequent because it also listens to the before-quit event. In Electron, emitting before-quit is sequential (though it doesn't wait for the previous one to complete before executing the next, the code here is very simple, so it's almost never encountered, but it does exist objectively).

The first one triggers very frequently because it completely does not rely on any Electron events when destroying the window, leading to a scenario of "true concurrent execution."

@hyoban
Copy link
Member

hyoban commented Oct 25, 2024

Thank you so much for your help!!!

@hyoban hyoban merged commit 2ade4ae into RSSNext:dev Oct 25, 2024
4 of 6 checks passed
@Innei Innei mentioned this pull request Oct 25, 2024
4 tasks
@BlackHole1 BlackHole1 deleted the fix-windows-update-failed branch October 25, 2024 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

能够更新,但每次更新会有下面的弹出提示。
2 participants