5

After upgrading to 20.04, I cannot open big svg files. I get:

XML parse error: cannot load more than 200000 XML elements

Problem occurs in Image Viewer and Gimp, while ImageMagick display, inkscape, libreoffice --draw stall, showing nothing.

Firefox and Chrome open the file, but Firefox's zoom is poor and Chrome is very slow and tends to stall.

svg packages: apt list --installed | grep svg

gir1.2-rsvg-2.0/focal-updates,now 2.48.9-1ubuntu0.20.04.1 amd64 [installed,automatic]
libimage-librsvg-perl/focal,now 0.07-8build5 amd64 [installed]
libqt5svg5/focal,now 5.12.8-0ubuntu1 amd64 [installed,automatic]
librsvg2-2/focal-updates,now 2.48.9-1ubuntu0.20.04.1 amd64 [installed,automatic]
librsvg2-2/focal-updates,now 2.48.9-1ubuntu0.20.04.1 i386 [installed]
librsvg2-common/focal-updates,now 2.48.9-1ubuntu0.20.04.1 amd64 [installed,automatic]
librsvg2-common/focal-updates,now 2.48.9-1ubuntu0.20.04.1 i386 [installed,automatic]
librsvg2-dev/focal-updates,now 2.48.9-1ubuntu0.20.04.1 amd64 [installed]
Ferroao
  • 745
  • 1
  • 7
  • 22
  • 1
    With what application? Inkscape? – HuHa Feb 18 '21 at 00:15
  • 2
    I believe that this is a limitation of librsvg. Do you have one of the failing svg files that you can post online for experimentation? – andrew.46 Feb 18 '21 at 04:18
  • The xml can be pruned by had btw: https://dev.to/adammckenna/how-and-why-to-clean-svg-markup-49i – andrew.46 Feb 18 '21 at 04:28
  • Does Inkscape also exhibit this? – Levente Feb 18 '21 at 16:56
  • Please add output of `grep ^deb -r /etc/apt/ --include=*.list` to the question or to pastebin. – N0rbert Feb 19 '21 at 14:12
  • https://pastebin.com/TqZ1xwxk – Ferroao Feb 19 '21 at 14:14
  • You are missing necessary repository components. Add the `deb http://archive.ubuntu.com/ubuntu/ focal main restricted`, `deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted` and `deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted` to your `/etc/apt/sources.list` and retry. – N0rbert Feb 19 '21 at 18:24

1 Answers1

5

This is a bug in librsvg package. They have 200000 items hardcoded for versions prior 2.49.5.

I can confirm the bug on Ubuntu 20.04 LTS. So I have reported it to LaunchPad as bug 1916055. Popular affected apps:

  • Eye of GNOME
  • Eye of MATE, Atril
  • GIMP

There are apps using different libraries and fail - Karbon, Krita, Cenon.

Possible workarounds are:

  • recompile the library locally with patch to have 1000000 XML node limit.

    At first enable Source Code repositories from software-properties-gtk and the run commands below to get build-dependencies and for patching with successful compilation:

    sudo apt-add-repository main
    sudo apt-add-repository universe
    sudo apt-add-repository multiverse
    sudo apt-add-repository restricted
    
    sudo apt-get update
    sudo apt-get dist-upgrade
    
    sudo apt-get build-dep librsvg2-dev
    sudo apt-get install devscripts
    
    cd ~/Downloads
    apt-get source librsvg2-dev
    cd librsvg-2.48.9
    
    # change 200000 to 1000000
    sed -i "s/200_000/1_000_000/" rsvg_internals/src/limits.rs
    dpkg-buildpackage -b -uc -us
    
    sudo apt-get install ../*svg*.deb
    

    Then pin package versions with single long command:

    cat <<EOF | sudo tee /etc/apt/preferences.d/pin-librsvg2
    Package: gir1.2-rsvg-2.0
    Pin: release a=now
    Pin-Priority: 1337
    
    Package: librsvg2-2
    Pin: release a=now
    Pin-Priority: 1337
    
    Package: librsvg2-bin
    Pin: release a=now
    Pin-Priority: 1337
    
    Package: librsvg2-dev
    Pin: release a=now
    Pin-Priority: 1337
    
    Package: librsvg2-common
    Pin: release a=now
    Pin-Priority: 1337
    
    Package: librsvg2-doc
    Pin: release a=now
    Pin-Priority: 1337
    EOF
    

    And enjoy:

    EoM with patched librsvg2

  • use viewers and editors with different back-end library:

    • web browsers like Firefox, Chromium, Konqueror
    • LibreOffice Draw
    • Inkscape (needs >14 Gb of RAM)
N0rbert
  • 97,162
  • 34
  • 239
  • 423
  • You have to fix your repositories. Then run `sudo apt dist-upgrade` to get newest dependencies. I ran this method on fresh Ubuntu 20.04 LTS without problems. – N0rbert Feb 19 '21 at 07:57
  • after removing conflicting files: sudo rm /usr/share/doc/librsvg2-2/changelog.Debian.gz sudo rm /usr/share/doc/librsvg2-common/changelog.Debian.gz I think is fine now. thx – Ferroao Feb 19 '21 at 20:49
  • I hit what it seems is the same issue with the output of `systemd-analyze dot | dot -Tsvg > systemd.svg`, but only have 20k lines. On browsers works fine – Pablo Bianchi Jul 30 '22 at 05:22