-
Notifications
You must be signed in to change notification settings - Fork 812
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-60232] Fix a crash in Linux when trying to create a thumbnail from an image #3147
Conversation
// Linux doesn't support the thumbnail creation so we have to use the base function | ||
if (process.platform === 'linux') { | ||
// We also will cap this at 1MB so as to not inflate the memory usage of the downloads dropdown | ||
if (item.getReceivedBytes() < 1000000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please clarify
to not inflate the memory usage of the downloads
Does it mean if image size is greater than 1mb we wont show the preview in the download dropdown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. This is a bit of pre-emptive safety, but I did notice that if you do have a really large image stored in the JSON (like I had before) it will slow down the app significantly, so I want to avoid that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is for images only dont we have access to preview url of the image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not anymore, we can't use the file:///
protocol which would facilitate that. And we don't want to open up mattermost-desktop:
to arbitrary files, or else security becomes a concern.
I'd be up for trying to figure out a better solution in the future, but this works for now.
/cherry-pick release-5.9 |
Cherry pick is scheduled. |
…m an image (#3147) (#3149) * [MM-60232] Fix a crash in Linux when trying to create a thumbnail from an image * Fix lint * Cap at 1MB * Fix crash again (cherry picked from commit b4eeabb) Co-authored-by: Devin Binnie <[email protected]>
Summary
When we made the fix to disallow the
file:
protocol, we started usingcreateThumbnailFromPath
to process images. Unfortunately, this function is simply not defined on Linux, causing a crash.This PR falls back to using the
createFromPath
function for Linux only, which creates a full version of the image. I've capped the image size to use at 1MB so that we don't inflate the memory usage of the downloads dropdown too much.Ticket Link
https://mattermost.atlassian.net/browse/MM-60232
Closes #3129