Giter Club home page Giter Club logo

Comments (5)

afbora avatar afbora commented on August 15, 2024

I've done few tests but I couldn't reproduce the issue. May be race condition? I think, it could be reproducible with multiple concurrent same requests.

from kirby.

nilshoerrmann avatar nilshoerrmann commented on August 15, 2024

I've noticed this on different servers (production and localhost) and with different image sizes (small and large). We have this custom code to generate small image thumbs we use as placeholders:

    public function previewUri()
    {
        try {
            [$width, $height] = $this->dimensions();
            $height = round((65 / $width) * $height);
            $width = 65;

            if ($this->crop) {
                $options = null;

                if ($this->crop !== 'focus') {
                    $options = [
                        'crop' => $this->crop
                    ];
                }

                $thumb = $this->file->crop($width, $height, $options);
            } else {
                $thumb = $this->file->thumb([
                    'width' => $width,
                    'height' => $height
                ]);
            }

            if (!$thumb->exists()) {
                $thumb->save();
            }

            return F::uri($thumb->root());
        } catch (Exception $e) {
            return '';
        }
    }

Not sure if this might be a source of this issue, too. Still, the persistent job files do not only affect these thumbs but other images as well.

from kirby.

nilshoerrmann avatar nilshoerrmann commented on August 15, 2024

I also noticed that sometimes there are just unchanged copies of the original image in the media folder (same file size, same dimensions):

grafik

We are also seeing high CPU usage and failures. Although we are using GD for image creation, this might be related to #5328.

from kirby.

afbora avatar afbora commented on August 15, 2024

I also noticed that sometimes there are just unchanged copies of the original image in the media folder (same file size, same dimensions):

I'm pretty sure that you already know this, but I think you may have overlooked it. This behavior is possible if the original image is used in the content or a original url is provided for the lightbox (as in the example below). Of course, I'm making an assumption since I don't know your case. In the example below, the original image is not copied to the media folder unless the lightbox is running to enlarge the image.

<a href="<?= $cover->url() ?>" data-lightbox class="img">
  <img src="<?= $cover->crop(1200, 600)->url() ?>" alt="<?= $cover->alt()->esc() ?>">
</a>

from kirby.

nilshoerrmann avatar nilshoerrmann commented on August 15, 2024

@afbora You are right about the directly linked sources (and you are totally right, that I overlooked that, too). So this is just fine 👍

We are still left with the persisting job files. My guess is something did not work as expected while generating thumbs. Let this either be a memory or CPU limit or some kind of other fault on the server. So do coexisting job and thumb files imply that something is wrong with the generated thumb? Let's say the thumb is only partly rendered. This is an important question because if this is the case, the thumb should be regenerated on next call, discarding the existing thumb. But this could cause more trouble if the server was already at its limits forcing recursive image generations. If – on the other hand – an existing thumb predicates that the image generation finished correctly (because it was only moved from tmp to the media folder after generation, I don't know), then the persisting job file could savely be removed on second call.

The question is which is right and which is wrong: the existing job or image files?

from kirby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.