Page MenuHomePhabricator

Thumbnails of certain SVG files fail to render
Closed, ResolvedPublic

Description

Hi, some of our users have complained that thumbnails of SVGs created in inkscape are failing to render on the file page (if they click the link to view the image on our static domain it works.

For example this image https://altverse.miraheze.org/wiki/File:Coat_of_arms_of_Morocco_(Altverse).svg

I've tried to follow https://commons.wikimedia.org/wiki/Help:Inkscape#From_invalid_to_valid_SVG:_Inkscape_files but that didn't help (didn't fix the problem). So im thinking this bug is in mediawiki/core.

I see "(Invalid SVG file: Expected <svg> tag, got in NS )"

Details

Related Changes in Gerrit:

Event Timeline

I don't see any SVG failing to render here, just PNG thumbnails of an SVG file that don't get rendered?

(Why are all these people subscribed to this task???)

"(Invalid SVG file: Expected <svg> tag, got in NS )" looks wrong as the SVG file itself starts with the line <svg xmlns="http://www.w3.org/2000/svg" width="695.757" height="518.598">.
The first version of that file also worked as expected I guess as only the newer versions state "Dimensions: 0 × 0".

Aklapper renamed this task from SVG's created in inkscape fail to render to Thumbnail of a specific SVG fails to render.Jul 18 2018, 9:08 AM
Aklapper updated the task description. (Show Details)

I am the original user who filed the initial complaint of this issue on Miraheze's Phabricator. The original report is here alongside several other files that encountered the issues (PNG thumbnails of SVG files failing to render). Here is the list of all files presented from that report:

File:Coat of arms of Cancun.svg (Altverse Miraheze - File page with the error)
File:Coat of arms of Cancun.svg (Altverse Miraheze - Static version showing no error)
File:Coat of arms of Cancun.svg (Wikia version for comparison -- uploaded after original file was put on Miraheze)
https://altverse.miraheze.org/wiki/File:Coat_of_arms_of_Morocco_(Altverse).svg (The file being used as an example in this report)
https://altverse.miraheze.org/wiki/File:Altverse.svg (This file has previous versions where there were no issues until the most recent upload)
https://altverse.miraheze.org/wiki/File:Personal_Coat_of_Arms_of_Travis_(Goldentrash).svg (This image was created over 3 years ago)
https://altverse.miraheze.org/wiki/File:Coat_of_arms_of_Jordan_(Altverse).svg
https://altverse.miraheze.org/wiki/File:Coat_of_Arms_of_Helvore.svg
https://altverse.miraheze.org/wiki/File:Helvore_in_the_EU.svg
https://altverse.miraheze.org/wiki/File:PSE.svg (This is the oldest image on the wiki which encounters this problem--uploaded on June 17, the same day Miraheze updated with the latest version of MediaWiki [1.31])

Centrist16 renamed this task from Thumbnail of a specific SVG fails to render to Thumbnails of certain SVG files fail to render.Jul 28 2018, 5:51 PM

Change 449915 had a related patch set uploaded (by saper; owner: saper):
[mediawiki/core@master] SVGMetaDataExtractorTest: Additional test cases

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

@Paladox can you try to apply https://gerrit.wikimedia.org/r/449915 and run phpunit on your MW instance:

env LC_MESSAGES=C LANG=C LC_TIME=C  php tests/phpunit/phpunit.php \
--configuration tests/phpunit/suite.xml \
--exclude-group Broken,Stub,Dump,ParserFuzz --log-junit /tmp/log.xml \
  tests/phpunit/includes/media/SVGMetadataExtractorTest.php

and see if it passes? It seems to work for me with git master as of 49dda2dc7c87f8acf09541803d8f581b7f8b70c7

I get this error:

[99acb0f0404380e43c1e3e73] [no req] MWException from line 476 of /srv/mediawiki/w/includes/cache/localisation/LocalisationCache.php: No localisation cache found for English. Please run maintenance/rebuildLocalisationCache.php.
Backtrace:

Yet i have run that.

@saper did you test that against stretch?

@Paladox no, only some oldish Gentoo for now.

I think i found the problem. It is because of wgSVGMetadataCutoff.

When i set that higher the problem goes away.

Okay, but why? Do we need to read a whole SVG as XML to figure it out? In this case this option is useless. On the other hand, I cannot reproduce this with a unit test.

Change 449915 abandoned by saper:
SVGMetaDataExtractorTest: Additional test cases

Reason:
does not bring us to a better solution, it was just a test to possibly reproduce the issue and it failed

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

Restricted Application added a subscriber: RhinosF1. · View Herald Transcript

@Paladox we found the same problem and increased the wgSVGMetadataCutoff to really big values without success. But interestingly we get a new error instead:

Fehler beim Erstellen des Vorschaubildes: convert-im6.q16: unable to extend cache `/tmp/magick-27336L8gD-vUBKan8': File too large @ error/cache.c/OpenPixelCache/3966. convert-im6.q16: no images defined `PNG:/tmp/transform_6fc9d5887c36.png' @ error/convert.c/ConvertImageCommand/3258.

Maybe this gives some insights where the problem comes from.

This affects the DrawioEditor extension badly.

https://www.mediawiki.org/wiki/Topic:Vrjw9ucehezwct95

Though in this specific extension it may be possible to workaround it, as the thumbnail data ought not really be neccessary...

https://github.com/mgeb/mediawiki-drawio-editor/issues/22

It's also possible to render PNGs browser-side when saving a Drawio drawing which might also avoid the problem - thought would of course balloon file size (as I think the SVG is embedded in the PNG!)

Increase $wgSVGMetadataCutoff and afterwards, run refreshImageMetadata.php from maintenance directory should solve the problem.

TheDJ claimed this task.
TheDJ subscribed.

This likely was T213501 and resolved back then. The draw.io issue likely is T138783.

I'm closing this, and new tickets can be raised for newer more specific issues when encountered.