Bug 159287 - Strip whitespace from .ui files, or compress them
Summary: Strip whitespace from .ui files, or compress them
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.6.4.1 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: QA:needsComment
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-19 13:11 UTC by Will Thompson
Modified: 2024-02-03 03:15 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Will Thompson 2024-01-19 13:11:10 UTC
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.