https://bugs.documentfoundation.org/show_bug.cgi?id=159287

            Bug ID: 159287
           Summary: Strip whitespace from .ui files, or compress them
           Product: LibreOffice
           Version: 7.6.4.1 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: LibreOffice
          Assignee: [email protected]
          Reporter: [email protected]

The Flathub build of LibreOffice is 764 MB, which I found surprising. Of that,
33 MB is taken up by .ui files describing the user interface. For example
files/libreoffice/share/config/soffice.cfg/modules/simpress/ui/notebookbar.ui
alone is 1,122,131 bytes. The .deb packages available from
https://www.libreoffice.org/download/download-libreoffice/ also contain these
.ui files.

GtkBuilder XML is a very verbose format. But I noticed that these files are
shipped with their whitespace intact. I carried out a quick test of running all
these files through `xmllint --nonet --noblanks` to strip
semantically-meaningless whitespace. The resulting files total 21 MB, which
means the remaining 12 MB is whitespace. With whitespace removed
files/libreoffice/share/config/soffice.cfg/modules/simpress/ui/notebookbar.ui
is 586,432 bytes: 52% of the original size. Of course whitespace compresses
well in transit, but it would be nice to not have to transmit or store it!

GNOME applications typically embed their .ui files into the executable, using
`glib-compile-resources` to generate a C source file that is linked to the
application, then the GResource API
<https://docs.gtk.org/gio/struct.Resource.html> to access those resources. The
definition of a GResource can specify `preprocess="xml-stripblanks"` which runs
the file through `xmllint --nonet --noblanks` as above before embedding it.
While writing this comment I learned that there is also a built-in way to
compress resources with zlib.

I don't believe LibreOffice uses GResource, and I presume (perhaps
incorrectly!) that it doesn't use Gtk to parse the .ui files at runtime on
non-GTK platforms. So just using GResource is probably not so easy. But I
suggest that it would be useful to strip whitespace during the build process.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to