Page MenuHomePhabricator

Thumbnail rendering for specific size ranges fails
Closed, ResolvedPublic

Description

I bet this this related to thumbnail chaining (T69525)

How to reproduce:

  • Upload a JPEG file (1,024 × 768 pixels) to Wikimedia Commons
  • Try to get a 500px thumbnail (e.g. writing [[File:<name>|500px]] on a random page and hitting "preview")

When attempting to view this thumbnail, you'll get an error message similar to the following

Error generating thumbnail
Error creating thumbnail: convert: Empty input file `/tmp/transform_e680fcd173fa-1.jpg' @ error/jpeg.c/EmitMessage/242.
convert: missing an image filename `/tmp/transform_4d401c5ab2ee-1.jpg' @ error/convert.c/ConvertImageCommand/3011.
Error code: 1

I have already reproduced this with a test image. A couple of other images that are affected:

All thumbnail sizes up to 479px for File:Transit-lune-sat--22-mai-01.jpg appear to render; at 480px I receive said error.

Event Timeline

Rillke created this task.Dec 9 2014, 12:57 AM
Rillke raised the priority of this task from to Unbreak Now!.
Rillke updated the task description. (Show Details)
Rillke changed Security from none to None.
Rillke added a subscriber: Rillke.
Rillke updated the task description. (Show Details)Dec 9 2014, 1:04 AM
Rillke added subscribers: Tgr, Gilles.
Rillke added a comment.Dec 9 2014, 1:23 AM

Uploaded another one (this time 512px in with). It is thumbnailed from 480px to 511px and from 1px to 223px. From 224px to 479px, I receive the above quoted error message.

Tgr added a comment.Dec 9 2014, 1:43 AM

This happens when the file size equals a bucket size (certain powers of two) and the thumbnail size is between filesize-32 and filesize/2-32 (which is the condition for using filesize as the bucket size for the thumbnailing). I guess what happens is that MediaWiki refuses to generate a thumbnail that has the same size as the original, somehow an empty file gets created, and that file is then used as the source for thumbnails in the affected range.

Change 178406 had a related patch set uploaded (by Gergő Tisza):
Fix for broken thumbnails when the file width is in $wgThumbnailBucket

https://gerrit.wikimedia.org/r/178406

Patch-For-Review

Tgr renamed this task from [REGRESSION]: Thumbnail rendering for specific size ranges fails to Thumbnail rendering for specific size ranges fails.Dec 9 2014, 2:04 AM
Tgr added a project: Regression.
Tgr added a comment.Dec 9 2014, 2:17 AM

The other half of the bug is that File::generateBucketsIfNeeded() creates a temporary file for the thumbnail but does not delete it on error. I'm not sure if that's a bad thing; it causes the thumbnail request to error out, whereas otherwise the code would fall back to using the original file as a source for the thumbnail. The issues caused by that would be much more minor, but much, much harder to track down.

When testing locally, a purge was needed to fix the thumbnails after applying the fix. Not sure why that's the case; looking at the code, it shouldn't be.

Tgr lowered the priority of this task from Unbreak Now! to High.Dec 9 2014, 2:18 AM
Gilles moved this task from Untriaged to Next up on the Multimedia board.Dec 9 2014, 10:29 AM
Gilles moved this task from Next up to Needs code review on the Multimedia board.

Change 178406 merged by jenkins-bot:
Fix for broken thumbnails when the file width is in $wgThumbnailBucket

https://gerrit.wikimedia.org/r/178406

Change 178529 had a related patch set uploaded (by Gilles):
Fix for broken thumbnails when the file width is in $wgThumbnailBucket

https://gerrit.wikimedia.org/r/178529

Patch-For-Review

Change 178531 had a related patch set uploaded (by Gilles):
Fix for broken thumbnails when the file width is in $wgThumbnailBucket

https://gerrit.wikimedia.org/r/178531

Patch-For-Review

Change 178531 merged by jenkins-bot:
Fix for broken thumbnails when the file width is in $wgThumbnailBucket

https://gerrit.wikimedia.org/r/178531

Change 178529 merged by jenkins-bot:
Fix for broken thumbnails when the file width is in $wgThumbnailBucket

https://gerrit.wikimedia.org/r/178529

Gilles moved this task from Ready for testing to Doing on the Multimedia board.Dec 9 2014, 4:31 PM
Gilles closed this task as Resolved.Dec 10 2014, 10:19 PM
Gilles claimed this task.
Gilles moved this task from Doing to Done on the Multimedia board.