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

Mac only: app becomes unresponsive for a period after downloading the zip file, and the mouse shows a loading icon. #8622

Closed
DamonYu6 opened this issue Oct 23, 2024 · 1 comment · Fixed by #8623

Comments

@DamonYu6
Copy link
Contributor

  • Electron-Builder Version: 23.3.0
  • Electron Version: 27.2.0
  • Electron Type (current, beta, nightly): current
  • Electron-Updater Version: 6.3.4
  • Target: Mac (Apple Silicon / Intel)

Issue: After enabling delta updates for macOS in electron-updater, we observed that once the app downloads the zip file in the background, it becomes unresponsive for a period, and the mouse shows a loading icon. Additionally, our Sentry has captured main process ANR (Application Not Responding) events reported by the app.

Analysis: Upon reviewing the code, I found that in order to implement delta updates, the MacUpdater calls the synchronous copyFileSync Node API to cache the file after the zip file is downloaded locally. This synchronous API blocks the Electron main process, especially when the zip file is large, causing the app to freeze for longer periods (our zip file is around 400MB).

done: event => {
if (!downloadUpdateOptions.disableDifferentialDownload) {
try {
const cachedUpdateFilePath = path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_MAC_APP_ZIP_FILE_NAME)
copyFileSync(event.downloadedFile, cachedUpdateFilePath)
} catch (error: any) {
this._logger.warn(`Unable to copy file for caching for future differential downloads: ${error.message}`)
}
}
return this.updateDownloaded(zipFileInfo, event)

Solution: Replace copyFileSync with an asynchronous API, such as the copyFile method provided by the fs-extra module for file copying.

@DamonYu6
Copy link
Contributor Author

@beyondkmp could you help to check this PR

mmaietta pushed a commit that referenced this issue Oct 23, 2024
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 a pull request may close this issue.

1 participant