-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Jpeg use imagick #16158
Jpeg use imagick #16158
Conversation
Signed-off-by: nachoparker <nacho@ownyourbits.com>
Signed-off-by: nachoparker <nacho@ownyourbits.com>
} | ||
} | ||
|
||
// TODO move to a new file |
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.
👍 There is a script to update the autoloaders: https://github.com/nextcloud/server/blob/master/build/autoloaderchecker.sh
Signed-off-by: nachoparker <nacho@ownyourbits.com>
Thank you for your research 👍 🚀 |
@rullzer your input needed for the security side of it, I suppose... |
Hi,
In the end, I guess we need:
|
I'm not a big fan of enabling imagick so widely with user input. I have been playing (but time... you know) of making the preview backend more replacable and plugin capable. So you could for example use some 3rdparty service for preview generation. Or have more modular in general to also allow generation of more modern types (for browsers that support it etc). So I'm not against chaing the preview system. But then we should have it more pluggable so this doesn't have to all be fixed in the server. |
We basically are saying similar things. I don't care what we use but this needs to be improved. User experience is very bad and one of the most popular things people want to use NC for is for their photo collection, then they get instantly turned off. It works awfully. I wrote down a bunch of ideas while I was looking around this issue. Off the top of my head things that could be done:
About using a different library... I am fine with that. I do not particularly advocate for imagick but wanted to test out multithreading to see if it would help. I think that a library that can do multithread and a config option would be handy. I am not inside the project that much to say what needs to be done, but I wanted to start this conversation since the current situation makes NC look pretty bad to users. Then there is the problem of the NC architecture, which is highly inefficient for the gallery since it has to spawn a thread and load everything including apps for every request, but that would be a separate issue. See #14953 |
@rullzer we do encourage imagick though, as this is needed for proper avatar generation too :) |
The security concerns with imagick can be solved, by placing it in a seccomp mode, with only a whitelist of system calls allowed, perhaps even seccomp mode 2 would be enough. |
So. I have been playing with this as well a bit. So again. I do not like imagick. My approach has been playing with https://github.com/h2non/imaginary which is insanely fast. And nicely sandboxed in docker. (yay!). The issue right now is that we can use that for the initial preview but for the scaling as pointed out here GD is still used. What I would suggest we do
Does that sound somewhat sane? |
Yes 👍 I guess the structural changes will take some time. Adding a way to use imagick for preview generation sounds good to me in the meantime. With some code cleanup I would accept this pr. As long as there is a way to opt out. |
$image = new OCPImage(); | ||
public function getImage($maxPreview) { | ||
$mimeType = $maxPreview->getMimeType(); | ||
$imagick_mode = (bool)$this->config->getSystemValue('preview_use_imagick', false); |
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.
$imagick_mode = (bool)$this->config->getSystemValue('preview_use_imagick', false); | |
$imagick_mode = $this->config->getSystemValueBool('preview_use_imagick', false) && extension_loaded('imagick'); |
@nachoparker is the PR applying cleanly on 19.0.3? Waiting for current previewgenerator to only use a small percent of 1 of 8 cpus is not a pleasant experience. I tried to apply your PR like this: went to Commit tab of this PR, right click on each one commit, copy link. went to shell, wget copied_url and append ".patch", like this
then cd /var/www/nextcloud; patch --dry-run -p1 < /root/20ac35e01351cb79b2c00545c444c8d7c94c6ab6.patch but it fails like this:
|
This comment has been minimized.
This comment has been minimized.
Any update on this? |
Hello, I'm discovering this thread while I was looking for a solution about the very slowly loading thumbnails on my server/NC clients (I'm already using APCu). Is the work done by @nachoparker has been integrated into NC ? I'm running NC 20 and previewgenerator is still using 1 CPU but I wonder if NC does use more CPU's when it generates preview on the fly. |
Quoting myself from #13099 (comment):
There is a |
This might be related to #15075 |
It seems like a popular approach nowadays is to run the preview generator inside a separate docker with software based on libvips e.g. https://github.com/h2non/imaginary or https://github.com/cshum/imagor If we move the preview generation to a separate process this might also help a bit with the performances... libvips is part of OSS Fuzz and is contently fuzzed for potential new vulnerabilities so this should hopefully reduce the risks a bit with additionally running it in a docker image. |
This would break the concept of user key encryption. |
we have work in progress to generate previews faster using imaginary: #24166 |
As there is no feedback since a while I will close this ticket. @nachoparker thanks for the work put into Nextcloud (this PR might not be in, but many of others from you are 🤗) |
See nachoparker#1
My main intention is to try to improve performance by using a native method and explore multithreaded native approaches.
I am not necessarily advocating for Imagick, since I know there are security concerns around it, but I wanted to start the conversation since the performance is really bad and throws people off.
This is a PoC, but we could do something like this with some native library that is not GD to start working towards that direction. All being said I was impressed to find out that GD was not that much slower in equal conditions (single threaded and so on), which probably doesn't say much about Imagick.
It would be interesting to try out other libraries too.