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/trivials #163

Merged
merged 2 commits into from
Nov 10, 2023
Merged

Fix/trivials #163

merged 2 commits into from
Nov 10, 2023

Conversation

choigawoon
Copy link

fix trivials

1
Ensure asynchronous execution of window creation
2
Refactor initialization sequence for clarity

Summary

This PR reorders the initialization sequence in the createMainWindow function, moving the IPC Communication initialization block to execute before the environment-specific main window loading logic.

Changes

  • IPC Communication initialization is now performed immediately after the main window creation and basic setup, but before the loading of URL or files based on the environment.

Rationale

The adjustment ensures that the IPC handlers are set up in a consistent state before any content loading begins, which is essential for handling events that might occur early in the application lifecycle, particularly in a production environment.

Impact

No immediate impact on existing functionality is expected. However, this change can prevent potential race conditions or initialization issues that may arise during the application scaling or further development.

Summary

This PR fixes potential race conditions in the app's lifecycle events by ensuring that createMainWindow is awaited, thus fully initializing the mainWindow before usage.

Changes

  • Added await keyword to the createMainWindow function calls within the 'ready' and 'activate' event handlers.

Rationale

Previously, createMainWindow was called without await, leading to scenarios where mainWindow could potentially be interacted with before being fully initialized. This was particularly problematic during the 'activate' event, which may fire when the app is reactivated from the dock or taskbar.

Impact

The addition of await ensures that the application's main window is ready before it is shown or interacted with, preventing errors that may occur due to uninitialized state. This change is critical for maintaining a stable application lifecycle, especially when dealing with asynchronous operations in Electron's main process.

by chatgptplus

choigawoon added 2 commits November 8, 2023 16:32
Add `await` keyword to `createMainWindow` calls within app's 'ready' and 'activate' events to ensure the mainWindow is fully initialized before proceeding. This fix addresses potential race conditions where mainWindow could be used before being properly set up.
Move the IPC Communication initialization block before the condition checking the development environment. This change ensures that IPCs are initialized before the main window starts loading its content, which may be crucial for ensuring that all IPC handlers are set up properly regardless of the environment.
@jooy2
Copy link
Owner

jooy2 commented Nov 10, 2023

Hello, Thank you for your contribution to the project.

I agree with your intentions and changes, and appreciate the detailed explanation.
I will merge your code.

Thank you!

@jooy2 jooy2 added the enhancement New feature or request label Nov 10, 2023
@jooy2 jooy2 merged commit e9e9f87 into jooy2:master Nov 10, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants