7

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
  • 959

1 Answers1

6

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
  • 103,263