FS#73382 - [signal-desktop] use system electron instead of bundling it yourself

Attached to Project: Community Packages
Opened by Mynacol (mynacol) - Monday, 17 January 2022, 00:29 GMT
Last edited by Buggy McBugFace (bugbot) - Saturday, 25 November 2023, 20:08 GMT
Task Type Feature Request
Category Packages
Status Closed
Assigned To Levente Polyak (anthraxx)
kpcyrd (kpcyrd)
Santiago Torres (sangy)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 8
Private No

Details

Description:
Although signal-desktop is an electron application, it does not depend on electron. Instead, it bundles its own version.
To improve reusage of programs and libraries, signal-desktop should depend on the fitting system electron version, currently 16, therefore `electron16`.

As a side note, I noticed that the file tree of this package contains `app.asar` and `app.asar.unpacked/` (under `/usr/lib/signal-desktop/resources/`), hinting at duplicate data. And I believe `resources.pak` is not needed either.

After a short visit, I would kindly ask the maintainer of this package to review the package guidelines for electron applications again, https://wiki.archlinux.org/title/Electron_package_guidelines

With these changes I believe we can easily reduce the package size from ~320MB to ~120MB.

Additional info:
* package version: signal-desktop 5-28.0-1

Maybe see the `Required-By` tag on the arch package website for electron to get some ideas how other maintainers package their electron applications.
This task depends upon

Closed by  Buggy McBugFace (bugbot)
Saturday, 25 November 2023, 20:08 GMT
Reason for closing:  Moved
Additional comments about closing:  https://gitlab.archlinux.org/archlinux/p ackaging/packages/signal-desktop/issues/ 3
Comment by Mynacol (mynacol) - Saturday, 29 January 2022, 15:00 GMT
Hey, I created a PoC-type PKGBUILD. I attached the diff.

I am not quite happy with the result, maybe you can improve upon it.

The main idea is that we only package the `app.asar`, but then `preload.js` is missing. That file has to be essentially `preload.bundle.js`, else other JS dependencies are missing. So I just symlinked that file after extraction of the asar (after electron-builder just packaged it...).

The next problem is the configuration. The default build process seems to include the development config which connects to the staging servers. So I include the production config in the "default" one (just using `production.json` is missing some parameters, namely `enableCI`). Then I disable automatic updates.

The build is running since some days on my computer. The client unfortunately has some other issues, which were partly fixed with version 5.29.1.
Comment by Alexandre Bouvier (doskoi) - Friday, 10 June 2022, 10:22 GMT Comment by Bruno Pagani (ArchangeGabriel) - Saturday, 20 August 2022, 17:16 GMT
@kpcyrd Do you remember why that switch?
Comment by kpcyrd (kpcyrd) - Sunday, 21 August 2022, 22:57 GMT
Yes, the signal-desktop package frequently broke up until that commit because signal-desktop needed to be rebuilt when the system electron was changed (not just with semver major upgrades, but also for minor upgrades, basically every electron update that wasn't a patch release broke the signal-desktop package).

There was also a very obscure bug reported upstream that turned out to be Arch Linux specific, caused by me changing the electron version used: https://github.com/signalapp/Signal-Desktop/issues/2117
Comment by kpcyrd (kpcyrd) - Sunday, 21 August 2022, 23:12 GMT Comment by Mynacol (mynacol) - Tuesday, 04 October 2022, 19:59 GMT
Thanks for the extensive list. I started using signal only after the switch.

The experience for me was a bit the contrary. If I don't use the system electron, signal won't use native wayland (through the `.config/electron-flags.conf` mechanism) and would fail to open firefox if I click on a link in a message.

I can't remember any major issue with my patches, especially in connection with electron version updates, and especially in the last months. So if you are willing to test this once more, I attached the current patch (avoiding the config patching by setting `NODE_ENV=production`, I wish I would've found that earlier).
   diff (0.9 KiB)
Comment by kpcyrd (kpcyrd) - Thursday, 06 October 2022, 10:34 GMT
I don't know much about wayland, but since signal-desktop officially supports ubuntu and ubuntu now ships with wayland, can you verify the official release has the same issue there? Maybe we're just missing a makedepends=.
Comment by Mynacol (mynacol) - Thursday, 06 October 2022, 12:26 GMT
I just tested without my `electron-flags.conf`. As expected, Signal uses XWayland. But the link opening issue is resolved.
I assume electron applications are running with XWayland by default for now, until Chromium enables it by default.

The case for electron cmdline flags in a standard configuration file remains, making it easy for me to e.g. enforce wayland usage or disable GPU acceleration. And it saves storage space, as outlined above.
Comment by Martin Rodriguez Reboredo (yakoyakoyokuyoku) - Saturday, 18 February 2023, 13:07 GMT
To use system Electron with Signal you need to patch the `electron` package with this https://github.com/electron/electron/pull/36114 (direct link to patch https://github.com/electron/electron/pull/36114.patch) and launch it with the following.

```
$ electron --resources-path=/usr/lib/signal-desktop/resources /usr/lib/signal-desktop/resources/app.asar
```
Comment by Martin Rodriguez Reboredo (yakoyakoyokuyoku) - Saturday, 18 February 2023, 23:44 GMT

Loading...