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

[MM-61919] Wrap potential crash in try/catch for thumbnails, fall back to createFromPath #3224

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

devinbinnie
Copy link
Member

Summary

There seems to be a Windows-only crash case where calling createThumbnailFromPath would throw an error failing to get the thumbnail from a local cache (see https://github.com/electron/electron/blob/main/shell/common/api/electron_api_native_image_win.cc#L69). I'm not certain but I'm guessing it has something to do with files that do not have thumbnails pre-generated by the OS, and Electron expects that they are always there. This causes a hard crash since that method throws an error.

This PR simply adds an error boundary to fallback to createFromPath in those situations where a thumbnail cannot be retrieved, to avoid having the app crash hard.

Ticket Link

https://mattermost.atlassian.net/browse/MM-61919
Closes #3140

Fixed an issue where the app could crash loading a thumbnail on Windows

@devinbinnie devinbinnie added the 2: Dev Review Requires review by a core committer label Nov 25, 2024
@devinbinnie devinbinnie requested review from a team and hanzei and removed request for a team November 25, 2024 15:04
@devinbinnie devinbinnie requested a review from larkox November 25, 2024 15:04
// This has been known to fail on Windows, see: https://github.com/mattermost/desktop/issues/3140
try {
thumbnailData = (await nativeImage.createThumbnailFromPath(overridePath ?? item.getSavePath(), {height: 32, width: 32})).toDataURL();
} catch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it is worth it to have some log here, just so it is not completely silent. 0/5

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't know when this happens, or what to do with the log when we see it it's probably fine to leave as is.

Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT 👍

@devinbinnie devinbinnie merged commit 057572e into master Nov 26, 2024
8 of 10 checks passed
@devinbinnie devinbinnie deleted the MM-61919 branch November 26, 2024 13:12
@amyblais amyblais added this to the v5.11.0 milestone Nov 26, 2024
@hanzei hanzei added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Downloading an SVG leads to error "Failed to get thumbnail from local thumbnail cache reference"
5 participants