[go: up one dir, main page]

Page MenuHomePhabricator

Incorrect text positioning in SVG with tspan element and text-anchor attribute
Closed, ResolvedPublic

Description

LibRsvg seems not apply the text-anchor attribute (middle, end) if a tspan child-element, except of the last one, has an absolute dimension (x/y) value.
This case seems very rare, if not a program like ChemDraw 12 would produce such code.
(As mentioned at https://commons.wikimedia.org/wiki/Commons:Graphics_village_pump#Problem_rendering_chemical_structures)

Upstream ticket: https://gitlab.gnome.org/GNOME/librsvg/-/issues/651

Related Objects

Event Timeline

Perhelion raised the priority of this task from to Lowest.
Perhelion updated the task description. (Show Details)
Perhelion updated the task description. (Show Details)
Perhelion set Security to None.

I'm not sure about to handle this bug, because librsvg is used for speed. This seems more a bad and rare code from ChemDraw (anyway there could be more). As we can see LibRsvg pass all the W3C text-anchor test (with except of text on path and vertical, more than Chrome 42 which don't pass one test):

ChemDraw workaround (posted by Leyo): "I get the best results, if I first save the structure as .eps. I then convert the .eps to .svg using Scribus."

That's still an issue with librsvg 2.40.16, it renders the attached SVG like this: https://people.wikimedia.org/~jmm/svg/alanin.png

I mean now this is a bug of ChemDraw, because the text-tag needs x/y values (after W3C specifikation). (As this issue was newly reported on the German SVG-Projekt. https://de.wikipedia.org/wiki/Wikipedia_Diskussion:WikiProjekt_SVG#Chemdraw_Dateien) The browser and editor interpretation seems only fallback fault tolerance calculating.
@MartinK has created an JS-tool to fix such files: http://tools.martinkraft.com/fixChemdrawSvg.html.

AntiCompositeNumber raised the priority of this task from Lowest to Needs Triage.Oct 14 2020, 4:29 PM
AntiCompositeNumber added a project: Thumbor.

This issue still occurs in librsvg 2.44.10:

Alanin2_cleaned.svg.png (1×2 px, 36 KB)

The file has even more problems in librsvg 2.50.1:
Alanin2_cleaned.svg1.png (1×2 px, 37 KB)

I could not find an upstream bug report for this

JoKalliauer changed the task status from Open to Stalled.Jun 30 2021, 3:01 PM
JoKalliauer moved this task from Backlog to update librsvg on the Wikimedia-SVG-rendering board.

The problem is computing the width of an SVG "text chunk". If the text chunk consists of multiple XML nodes, then librsvg is using the width of the last node as the width of the entire text chunk. (librsvg is correctly tossing out the initial and final whitespace for the text element.)

Another test file:

This issue was fixed in the 2.40 C-version of librsvg.

The recent upgrade of Debian introduced the 2.44.10 Rust librsvg that still had this issue.

Consequently, many files that previously worked now show this bug.

See

Another file is displayed incorrectly.

T344564 shows another librsvg 2.40 to librsvg 2.44 regression issue.

Glrx triaged this task as High priority.Oct 12 2023, 12:41 AM

@Glrx: I don't think this task has high priority as it entirely depends on upgrading librsvg to version >=2.50.2, which means upgrading machines to Debian Bullseye, which makes this task depend on T265549?

I see fixing this issue as a high priority. It is confusing many users and probably affects thousands of files. Librsvg does not follow the fundamental rules about painting text.

I raised the priority of T265549 to high (it was low). Librsvg should be upgraded to fix SVG issues independently of upgrading to Bullseye.

When will WMF use Bullseye? IIRC, Buster was promised for July 2022 but was not released until April 2023.

Even if WMF uses Bullseye, WMF should be using more recent versions of librsvg.

I see fixing this issue as a high priority. It is confusing many users and probably affects thousands of files. Librsvg does not follow the fundamental rules about painting text.

I raised the priority of T265549 to high (it was low). Librsvg should be upgraded to fix SVG issues independently of upgrading to Bullseye.

When will WMF use Bullseye? IIRC, Buster was promised for July 2022 but was not released until April 2023.

Work on migrating to buster didn't even start until July 2022 so wherever stated that was very incorrect.

Support for Thumbor is in the process of being moved between teams, upgrading librsvg versions will be addressed as soon as we can.

I see fixing this issue as a high priority. It is confusing many users and probably affects thousands of files. Librsvg does not follow the fundamental rules about painting text.

I raised the priority of T265549 to high (it was low). Librsvg should be upgraded to fix SVG issues independently of upgrading to Bullseye.

When will WMF use Bullseye? IIRC, Buster was promised for July 2022 but was not released until April 2023.

Work on migrating to buster didn't even start until July 2022 so wherever stated that was very incorrect.

Support for Thumbor is in the process of being moved between teams, upgrading librsvg versions will be addressed as soon as we can.

In late May 2022, @WDoranWMF sent emails that stated

Currently, we're working on migrating Thumbor to the latest versions of Python, Thumbor and Debian. Alexandros Kosiaris(akosiaris) pointed me toward you. I wanted to ask for help in validating the new version of Thumbor.

We're ~60% of the way through the migration of the code base, though it is not necessarily a linear path and we may yet encounter blockers. Our current target is to have the new version of Thumbor running on our production kubernetes cluster toward the start of July. The service would not be receiving traffic yet but it would capable of doing so.

Right now we're starting to build our rollout plan that we will undertake from July to September. That will involve testing and validation of the new service to ensure that it performs at the expected level and that there are no regressions.

Another user has complained about this regression:

Thumbor is busted. This bug is not stalled on librsvg; versions from a year ago do not have this bug.

Glrx changed the task status from Stalled to Open.Oct 22 2023, 6:04 PM

I've described some workarounds on

http://en.wikipedia.org/wiki/Wikipedia:SVG_help#Misaligned_text

Feel free to add or amend any. Cheers, ~~~~

We don't need to list every file with this issue in the ticket. It's known that this is broken for a considerable subset of files.

Yet another file hit by this bug: https://commons.wikimedia.org/wiki/File:Quadratic_function_graph_key_values.svg

Everybody knows that it's pointless to list more files here. Spamming this task is an expression of our frustration.

Yet another file hit by this bug: https://commons.wikimedia.org/wiki/File:Quadratic_function_graph_key_values.svg

Everybody knows that it's pointless to list more files here. Spamming this task is an expression of our frustration.

In that case, your time will be better spend learning how to make Debian packages and writing Gerrit patches, or running for the Wikimedia board.

I think my time is better spent doing what I know, which is editing articles about quantum mechanics on Wikipedia. And if you point out an issue there, I'm not going to suggest that you have to learn quantum mechanics yourself or otherwise pound sand.

I see that you're a volunteer, so I can't really ask you to do such boring maintenance work as installing a bugfix that was released four years ago. I can, however, ask you to refrain from insulting contributors.

Look. The people on this task are the people who are annoyed by it already. Complaining more here won't get you anywhere. Complain to WMF management, who are the people who can allocate resources to this.

Since upgrading to 2.50.3 and doing some purges, I am seeing *some* improvement in the errors in this ticket but not in all cases.

For existing images that have rendering issues, how does one kick-off rerendering existing images that had issues after this upgrade?

For existing images that have rendering issues, how does one kick-off rerendering existing images that had issues after this upgrade?

https://en.wikipedia.org/wiki/Help:Purge#Purge_request_to_server - tldr add ?action=purge when viewing the File:myfile.svg page.

Be sure to force refresh your browser after doing it to be sure changes have rendered.

For existing images that have rendering issues, how does one kick-off rerendering existing images that had issues after this upgrade?

https://en.wikipedia.org/wiki/Help:Purge#Purge_request_to_server - tldr add ?action=purge when viewing the File:myfile.svg page.

Be sure to force refresh your browser after doing it to be sure changes have rendered.

Thank you. Gave that a shot and sadly do not see an improvement in the example I previously shared. (yes cleared browser cache and even tried another browser that hasn't previously pulled this page up before).
(Also does Wikipedia have a CDN? perhaps that's also caching it somehow/somewhere?)

For existing images that have rendering issues, how does one kick-off rerendering existing images that had issues after this upgrade?

https://en.wikipedia.org/wiki/Help:Purge#Purge_request_to_server - tldr add ?action=purge when viewing the File:myfile.svg page.

Be sure to force refresh your browser after doing it to be sure changes have rendered.

Thank you. Gave that a shot and sadly do not see an improvement in the example I previously shared. (yes cleared browser cache and even tried another browser that hasn't previously pulled this page up before).
(Also does Wikipedia have a CDN? perhaps that's also caching it somehow/somewhere?)

I had actually already run a purge for your image, which improved some but not all of the text alignment. This must be another issue outstanding in our current version of librsvg, but I don't know enough to point to which specific issue unfortunately. In coming weeks we'll be upgrading to 2.54.7 which will offer further improvements.

That looks like the dy attribute became "sticky": each child text node descends by dy.

Also visible at https://commons.wikimedia.org/wiki/File:SVG_Text_Chunk.svg at lower right.

For existing images that have rendering issues, how does one kick-off rerendering existing images that had issues after this upgrade?

https://en.wikipedia.org/wiki/Help:Purge#Purge_request_to_server - tldr add ?action=purge when viewing the File:myfile.svg page.

Be sure to force refresh your browser after doing it to be sure changes have rendered.

Thank you. Gave that a shot and sadly do not see an improvement in the example I previously shared. (yes cleared browser cache and even tried another browser that hasn't previously pulled this page up before).
(Also does Wikipedia have a CDN? perhaps that's also caching it somehow/somewhere?)

I had actually already run a purge for your image, which improved some but not all of the text alignment. This must be another issue outstanding in our current version of librsvg, but I don't know enough to point to which specific issue unfortunately. In coming weeks we'll be upgrading to 2.54.7 which will offer further improvements.

This image now renders correctly using librsvg 2.54.7

hnowlan claimed this task.

Considering this resolved as part of T355020. Please reopen if that's incorrect