clients icon indicating copy to clipboard operation
clients copied to clipboard

Enable LZO compression for snap package

Open pachulo opened this issue 4 years ago • 6 comments

Describe the Bug

Snap packages are known for having a very long first startup time. That's mainly because snaps are compressed squashfs images using XZ algorithm. Recently Canonical made it possible to use LZO algorithm instead of XZ, which significantly improves startup time. I'd like to ask to enable LZO compression for Bitwarden desktop snap.

Expected Result

According to Canonical, the use of the LZO compression offers 40-74% cold startup improvements over the XZ compression. https://forum.snapcraft.io/t/how-to-switch-your-snap-to-use-lzo-compression/21714 https://snapcraft.io/blog/snap-speed-improvements-with-new-compression-algorithm

Actual Result

It can take up to 4-5 seconds on my fairly modern desktop PC with SSD to launch Bitwarden snap for the first time. The subsequent launches are fast, but the first one is annoyingly slow. Using LZO algorithm should fix this issue (it did fix it in case of Chromium for me).

Environment

  • Operating system: Ubuntu 20.04
  • Installation method: Snap
  • Build Version (go to "Settings" → "About"): 1.25.1

pachulo avatar May 10 '21 10:05 pachulo

Hi @pachulo, thank you for opening this request.

I've done a little research and here's what I've found:

Bitwarden currently does not build snaps directly via snapcraft, but instead leverages electron-builder. The only part of snapcraft that is used, is to upload the package to the snap store.

From the electron-builder docs here, I currently can't find a way to pass on the "compression" option.

As a refactoring of the snap build process (use snapcraft), would be very time intensive I suggest opening an issue/request with the electron-devs and also link to this issue.

Hopefully they'll be able to implement it in a future version, and we'd just need to update the dependency and pass in the desired compression option.

One thing that definitely needs to be considered by the Bitwarden team, is the increase package size using the LZO compression over XZ.

djsmith85 avatar May 11 '21 16:05 djsmith85

Hi @pachulo, We're cleaning up our repositories in preparation for a major reorganization. Issues from last year will be marked as stale and closed after two weeks. If you still need help, comment to let us know and we'll look into it. Thanks!

bitwarden-bot avatar Apr 12 '22 19:04 bitwarden-bot

Hi! This will be solved once a stable version of electron-builder v23.x is released, as using the LZO algorithm will be the default then. Well, and when bitwarden desktop upgrades it's dependency to use it.

pachulo avatar Apr 15 '22 07:04 pachulo

OK, there's now a stable version of electron-builder v23: https://github.com/electron-userland/electron-builder/releases/tag/v23.2.0 Updating Bitwarden to use that one would allow to configure the compression as lzo, as you can see in the updated documentation.

pachulo avatar Jun 19 '22 13:06 pachulo

Has this change been released yet? I'm running Bitwarden version 2022.9.0 and the cold launch speed is still rather slow.

If the change hasn't been released yet, when can we expect for it to be available?

evanmohr avatar Sep 13 '22 19:09 evanmohr

@thatLeaflet: We haven't updated electron-builder yet, as we ran into some issues with building/signing our Mac builds. Once these are fixed, we will be upgrading to atleast v23 and as @pachulo mentioned this will include the new compression.

No info on an ETA at this time.

djsmith85 avatar Sep 14 '22 09:09 djsmith85

This is the issue that needs to be solved: https://github.com/electron-userland/electron-builder/issues/6621

pachulo avatar Oct 18 '22 21:10 pachulo

Has the underlying issue been fixed? I can see that #6621 is still open, but it seems that electron-userland/electron-builder#7040 is reporting the same issue and has been fixed, but I could be misunderstanding it.

evanmohr avatar Jan 30 '23 23:01 evanmohr

Very good question @thatLeaflet , I guess is up to bitwarden developers (ping @djsmith85 ) to test it, but the thing is that versions of electron-builder > than 23.3.3 are still marked as pre-release on GitHub, like the one that first included the fix v23.5.0.

pachulo avatar Feb 10 '23 22:02 pachulo

OK, it should be safe to use electron-builder 23.6.0 now, which should have this solved.

pachulo avatar Feb 14 '23 22:02 pachulo

The snap client is the only official one for Linux so this issue is affecting a lot of Linux Bitwarden users. With the electron-builder fixed, a fix for this issue seems like a very low hanging fruit, probably just change the "compression" property and test. I'd argue that the increased package size that @djsmith85 mentioned is a non-issue compared to the abysmal start times.

sebastian-brandt avatar Apr 04 '23 11:04 sebastian-brandt

@pachulo, @sebastian-brandt The bump to electron-builder 23.6.0 is currently in the works with https://github.com/bitwarden/clients/pull/5038.

djsmith85 avatar Apr 04 '23 11:04 djsmith85

@djsmith85 now that https://github.com/bitwarden/clients/pull/5038 is merged, what else is left to do?

pachulo avatar May 26 '23 22:05 pachulo

It's been a few months since the last reply, so I'm bumping this. Hoping to see the better compression taken advantage of in the Bitwarden Snap!

Constancies avatar Aug 28 '23 01:08 Constancies

As of today, snap is still using the xz algorithm:

$ snap download bitwarden                                                                                                                                                                                        
Fetching snap "bitwarden"                                                                                                                                                                                                           
Fetching assertions for "bitwarden"                                                                                                                                                                                                 
Install the snap with:                                                                                                                                                                                                              
   snap ack bitwarden_92.assert                                                                                                                                                                                                     
   snap install bitwarden_92.snap   
$ unsquashfs -s bitwarden_92.snap | awk '/^Compression/{print $2}'
xz

But I'm not really sure why, to be honest... :thinking:

pachulo avatar Aug 28 '23 21:08 pachulo