[MM-61919] Wrap potential crash in try/catch for thumbnails, fall back to createFromPath
#3224
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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