As some of you might already know, LibreOffice has had the ability to use Mozilla Themes (Personas) for some time (Tools > Options > Personalization); but it kept breaking all the time, and never had an acceptable UX. Also tons of errors/warnings, and very slow search and apply processes almost brought it to the point of being killed for good.
But I couldn’t let it die, started looking into the related code and the bug reports. These might be some of the possible reasons why I couldn’t let it die:
- It was a tiny silly feature, which brings some colour/fun to the UI
- It might add to the level of emotional adoption by users
- There were user requests
- I already touched the code before
First thing to do was to fix the search functionality to make it operational again. It was broken because of some small changes in the source code of the persona pages on the Mozilla side.
Then I started fixing some small issues, and looking into ways to improve the under-the-hood part of the Personas dialog. It turned out that the dialog was fetching many web pages and parsing them to find the useful pieces on every search; and there was no caching. And the fetcher code, based on Neon, was also buggy, and was causing a lot of issues on its own.
After some web debugging and searching on the web and inside our own code-base, I have found the new API of Mozilla, which was returning JSON data, consisting of all of the useful info about each theme; and realized that we could simply use curl to fetch the data we need. (It seemed, to me, faster and simpler than Neon.)
Here is a summary of what has been done so far:
- Make the search functional again
- Fix some crashers
- Refactor to improve performance, readability, stability, and to make the code future-proof
- Modernize under-the-hood part
- Reveal & polish the buried sub-features like preinstalled/bundled themes
- Some other small bug fixes and improvements
From all, the under-the-hood patch had a major positive impact on the dialog, fixing multiple bugs at the same time, and preventing some more. After this commit:
- The initial search time went down from ~40 seconds to ~6 seconds
- The subsequent searches for the same term went down to ~3 seconds from ~40 seconds
- So the search process became much much faster and more stable
And this is the commit message:
Modernize personas under-the-hood - The search
* Upgrade the used mozilla API from v1.5 to v3
* Ditch Neon for curl
* Get rid of the get-HTML-then-search-within craziness
It is much faster and smarter now:
* Fetches the search results at once in JSON format,
instead of repetitively making http calls for each persona,
and relying on an ever-changing HTML design
* Doesn't redownload and overwrite files each time, so it is
much faster for the second time of the same search query
This patch handles the search part. A follow-up patch will
handle the apply part.
This is how the Personalization dialog looks like with a set of 6 preinstalled/bundled themes:
This is how the Select Firefox Theme dialog (search screen) looks like after selecting the Nature category:
And here is a list of related commits on Personas:
- tdf#118881: Fix HTML parsing for personas
- Do not crash when there are more default personas than intended
- Use slug instead of name to store Personas
- Make use of the already defined constants for personas
- tdf#60543: Remember the URL of the currently applied persona
- Ensure settings consistency for default personas
- Separate persona download thread
- Modernize personas under-the-hood - The search
- tdf#101629: Handle invalid urls and search strings for Personas
- tdf#99776: Preload a persona category initially
- tdf#120506: Get rid of unnecessary accentcolor parsing for personas
- Use curl while getting the actual persona
- Increase number of default personas to 6