Canonical has begun addressing performance issues with the Firefox snap package, which was set as the default in Ubuntu 22.04 instead of the usual deb package. User complaints are primarily centered around the extremely slow startup of Firefox. For instance, on a Dell XPS 13 laptop, the first launch of Firefox after installation takes 7.6 seconds, on a Thinkpad X240 — 15 seconds, and on a Raspberry Pi 400 board — 38 seconds. Subsequent launches take only 0.86, 1.39, and 8.11 seconds respectively.
During the analysis of the issue, four main reasons for the slow startup were identified, which will be the focus of the resolution:
- High overhead from searching for files within the compressed squashfs image, which is particularly noticeable on low-spec systems. The plan is to address this by grouping content to minimize movement operations within the image during startup.
- On Raspberry Pi and systems with AMD GPUs, significant delays were linked to failures in detecting the graphics driver and reverting to using software rendering with very slow shader compilation. A patch to resolve this issue has already been added to snapd.
- A lot of time was wasted copying the built-in add-ons to the user directory. The snap package included 98 language packs, all of which were copied, regardless of the selected language.
- Delays also arose from determining all available fonts, themes, icons, and font configurations.
When launching Firefox from snap, separate performance issues were also observed during operation, but Ubuntu developers have already prepared fixes to improve performance. For example, starting from Firefox 100.0, optimizations at the linking stage (LTO) and based on profile-guided optimizations (PGO) are included in the build. A new XDG Desktop Portal has been prepared to address messaging issues between Firefox and external subsystems, and support for it is currently under review for inclusion in Firefox.
The reasons for promoting the snap format for browsers include the desire to simplify maintenance and unify development for different versions of Ubuntu — the deb package requires separate maintenance for all supported branches of Ubuntu and, accordingly, builds and tests considering different versions of system components, while the snap package can be created once for all branches of Ubuntu. Moreover, the proposed snap package for Firefox in Ubuntu is maintained by Mozilla staff, meaning it is created directly without intermediaries. Delivering it in snap format has also accelerated getting new versions of the browser to Ubuntu users and allowed Firefox to run in an isolated environment created using the AppArmor mechanism for additional protection of the rest of the system from vulnerabilities exploited in the browser.
Source: opennet.ru
