-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Timeout not applying to encoding? #4257
Comments
Almost all libvips operations support timeout, however the HEIF writer does not as the API of the underlying libheif library exposes a "one shot" encoder. There is a brand new feature in the latest libheif v0.19.x that exposes HEIF's |
FWIW, the comment at kleisauke/wasm-vips#78 (comment) provides more details on why this occurs with the HEIF saver (or any saver that doesn't support streaming/chunk-wise encoding). |
For what it's worth, in the repo I linked I am seeing the same behavior as AVIF (heif) when encoding PNGs and GIFs, eg if I set the timeout to 2 seconds:
I am completely unfamiliar with the internals of libvips and how it uses threads, but would it be possible to forcefully "kill"/abort an ongoing encoding operation? |
To improve things for PNG writing, I think we'd need to add a call to (Could probably limit this check to every N iterations of the loop.) |
Question about an existing feature
The
.timeout()
method seems to only apply to certain operations, not the actual encoding of the image - is that right? Is there a way one could abort an ongoing transform/encode operation? If so, would it be possible to make the timeout apply to this step as well?What are you trying to achieve?
I'd like to "give up" on processing/encoding images if they take longer than a given threshold. Without having been able to reproduce this consistently, it seems processing sometimes gets "stuck" on an image for a very long time, and I'd love to be able to simply drop the operation entirely - eg prevent it from using any more resources, and explicitly fail.
While I can set a timeout in user-land code and proceed as if it timed out, I cannot abort the actual encoding process, so it will continue taking CPU time until it eventually finishes/errors.
Additionally, it would be nice to be able to abort transformations, eg:
When you searched for similar issues, what did you find that might be related?
timeout()
being added, but also calls out that there is no way to cancel/abort an ongoing processPlease provide a minimal, standalone code sample, without other dependencies, that demonstrates this question
Repository that illustrates the problem: https://github.com/rexxars/sharp-timeout-issue
Please provide sample image(s) that help explain this question
See repo above, but any sufficiently large image will do
The text was updated successfully, but these errors were encountered: