The webp file get regenerated each time it was requested. It's a performance issue. Patch coming (initially on #3143491: Private images support).

Issue fork webp-3177103

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GaëlG created an issue. See original summary.

GaëlG’s picture

Assigned: GaëlG » Unassigned
Status: Needs work » Needs review
FileSize
5.36 KB

StryKaizer’s picture

Priority: Normal » Major
FileSize
5.33 KB

Reroll attached.

Moving this to major.
This brought our high-traffic site down multiple times before detecting the issue.

StryKaizer’s picture

FileSize
5.79 KB
Anas_maw’s picture

Status: Needs review » Reviewed & tested by the community

Very important patch, thank you
Works as expected

mhawwari’s picture

+1 Patch #5 is working for me

Luke.Leber’s picture

Status: Reviewed & tested by the community » Needs work

re #5 - we may want to provide a shorter lock acquisition period. According to the docs, it defaults to 30 seconds.

float $timeout: (optional) Lock lifetime in seconds. Defaults to 30.0.

In the event that disk access is slow (mounted filesystem, perhaps?), this could introduce a denial of service vector.

Since the Retry-After timing is set to 3 seconds, would it also make sense to reduce the lock acquisition time to 3 seconds as well?

leopathu’s picture

Status: Needs work » Needs review
FileSize
5.76 KB

we can fix it with simply check with file_exists. Not sure.. why do we need with lock solutions here?

This patch would fix it.

GaëlG’s picture

The lock system is copied from web/core/modules/image/src/Controller/ImageStyleDownloadController.php

Luke.Leber’s picture

re #9: I think the purpose of the lock is to prevent broken images on the frontend while an image is generating. Retry-After wasn't widely supported last I knew. Locking for N seconds is a pretty good workaround in the short term. Otherwise, sites could still have image derivatives generated more than once if a lot of requests hit the page at the same time.

I'd imagine that this could be an issue for high volume traffic sites in particular.

jedihe made their first commit to this issue’s fork.

jedihe’s picture

This is the patch for the current MR. Uploading to have a stable patch for my build.

alexmoreno’s picture

could you have a look at this @jedihe so we can merge ?

Merge blocked: fast-forward merge is not possible. To merge this request, first rebase locally.

https://git.drupalcode.org/project/webp/-/merge_requests/3

alexmoreno’s picture

  1. +++ b/src/Webp.php
    @@ -81,7 +94,38 @@ class Webp {
    +    $success = file_exists($destination) || $this->createWebCopy($uri, $destination, $quality);
    

    Better not to rename this method, as it's called as well from FileDownloadController

  2. +++ b/src/Webp.php
    @@ -81,7 +94,38 @@ class Webp {
    +  protected function createWebCopy($uri, $destination, $quality = NULL) {
    

    Needs a docblock.

alexmoreno’s picture

Status: Needs review » Needs work

dk-massive made their first commit to this issue’s fork.

dk-massive’s picture

Rebased and updated branch with requested edits.
Here is a rerolled patch as well.

dk-massive’s picture

Status: Needs work » Needs review
Lukas von Blarer’s picture

Status: Needs review » Needs work

The MR and the patch don't apply anymore. At least composer complains about it.

dennis_meuwissen’s picture

Attached is an updated patch for the current 1.x-dev version, based on the MR.

kalabro’s picture

Status: Needs work » Needs review
FileSize
6.81 KB
681 bytes

Attached is patch from #21 + #3256454-2: Error "Could not generate image resource from URI" on non-image formats because we need both on our project.

The maintainers most likely will want to review #21.

xrvalencia’s picture

Rerolling #21 to work with RC1 release.

beloglazov91’s picture

Rerolling #22 to work with RC1 release.

Peacog’s picture

This issue is related to #3435835: Webp derivatives not refreshed when files stored in sub-directory. When that other issue is merged, the code in the new getWebpCopy() method provided by this patch will need to be updated to
$destination = $this->getWebpDestination($uri, '@directory/@filename.webp');

mandclu’s picture

Can someone provide steps to reproduce? Does this only occur when using Webp with private files?

I tried adding debugging code to the generation method, and it fires when the image is first uploaded, but not when the image is requested again.

Peacog’s picture

I'm not able to reproduce the problem in #3435835: Webp derivatives not refreshed when files stored in sub-directory any more. Maybe there was a particular combination of versions and patches I was using that caused it. I've struck through my comment above so it doesn't cause confusion