FS#75667 - [code][electron{18,19,20}] unable to read electron18,19,20}-flags.conf

Attached to Project: Community Packages
Opened by bacteriostat (bacteriostat) - Monday, 22 August 2022, 08:16 GMT
Last edited by Massimiliano Torromeo (mtorromeo) - Tuesday, 14 March 2023, 21:27 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Massimiliano Torromeo (mtorromeo)
Bruno Pagani (ArchangeGabriel)
Filipe Laíns (FFY00)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 14
Private No

Details

Description:
Package electron18 should read flags from electron18-flags.conf but it fails to do so in version 18.3.9 and shows the below error:

> /usr/lib/electron18/electron: bad option: --ozone-platform-hint=auto

This happens with any flag and results in application not launching at all. Removing all flags from the file fixes it.

This works fine on 18.3.6

Additional info:
* package version(s): 18.3.9
* https://github.com/electron/electron/issues/35398

Steps to reproduce:
1) Upgrade electron18 to version 18.3.9
2) Set some flags in ~/.config/electron18-flags.conf file. Example: --ozone-platform-hint=auto
3) Launch a program that makes use of electron18, for example: "code" from the repos.
This task depends upon

Closed by  Massimiliano Torromeo (mtorromeo)
Tuesday, 14 March 2023, 21:27 GMT
Reason for closing:  Fixed
Additional comments about closing:  code-1.76.1-2
Comment by Bruno Pagani (ArchangeGabriel) - Monday, 22 August 2022, 15:14 GMT
It does not seems to be any electron user, but actually code. I could not reproduce with the packages I have.

In any case this has very likely been introduced by the change for  FS#74034 . I bet that if you reverse https://github.com/archlinux/svntogit-community/commit/f1bc01d61ed2f713efdc6d33104600e0f79ada10#diff-a9d028136db20390534ea297df670ab599022de8dcb57c1b71fd4913d7a1f7d7 in /usr/bin/electron18, it should work again.

I’m not sure what the best path here. Maybe the code launcher behaviour should be investigated and improved.
Comment by bacteriostat (bacteriostat) - Monday, 22 August 2022, 18:07 GMT
Can confirm, it works by reversing the /usr/bin/electron18 file.
Comment by Uģis Ģērmanis (ugjka) - Tuesday, 23 August 2022, 05:18 GMT
By reverting the patch it launches but Electron/Code still complains: Warning: 'ozone-platform-hint' is not in the list of known options, but still passed to Electron/Chromium.
Comment by bacteriostat (bacteriostat) - Tuesday, 23 August 2022, 05:19 GMT
That happened before as well, I think that is emitted by code.
Comment by Uģis Ģērmanis (ugjka) - Tuesday, 23 August 2022, 05:32 GMT
Ok, it works
Comment by bacteriostat (bacteriostat) - Friday, 02 September 2022, 04:17 GMT
Code now depends on electron19 which also has the same issue.
Comment by Toolybird (Toolybird) - Sunday, 04 September 2022, 00:58 GMT
Including code PM's to also take a look.

Dupe  FS#75783 
Comment by Massimiliano Torromeo (mtorromeo) - Monday, 05 September 2022, 09:13 GMT
The issue is ELECTRON_RUN_AS_NODE=1 in the /usr/bin/code script. The flags get probably processed in a different code path that rejects --ozone-platform-hint=auto as invalid.

I don't even know why that variable was set in the script, and I am leaning towards just removing it but does anyone know more about why it might be needed?
Comment by Sergei Gureev (bemyak) - Tuesday, 06 September 2022, 10:49 GMT
This env var makes all flags be passed straight to Node.js, bypassing Electron. To me, it seems fine to remove it; I also don't see why it is needed.
Comment by bacteriostat (bacteriostat) - Tuesday, 06 September 2022, 22:49 GMT
Looks like the fix prevents the crash of code but now code doesn't read the flag at all.

I used --ozone-platform-hint=auto in electron19-flags.conf file. It didn't work. But directly passing it via shell works.
Comment by Massimiliano Torromeo (mtorromeo) - Wednesday, 07 September 2022, 12:14 GMT
Passing the flag on the command line instead of in the electron19-flags.conf file only changes the order of the arguments.

`code --ozone-platform-hint=auto` executes `exec /usr/lib/electron19/electron /usr/lib/code/out/cli.js /usr/lib/code/code.js --ozone-platform-hint=auto`

`code` with `--ozone-platform-hint=auto` in the config file executes `exec /usr/lib/electron19/electron --ozone-platform-hint=auto /usr/lib/code/out/cli.js /usr/lib/code/code.js`

The order of the arguments configured in the flags file is controlled by the electron script and there is nothing I can change in code to fix that. You can use `~/.config/code-flags.conf` though and it should put the flags at the end of the command.

Putting the flag at the end causes this `Warning: 'ozone-platform-hint' is not in the list of known options, but still passed to Electron/Chromium.` so it seems to me like it would actually be correct to put it in electron19-flags.conf rather than in code-flags.conf
Comment by Sergei Gureev (bemyak) - Wednesday, 07 September 2022, 12:27 GMT
I can confirm that putting flags in `code-flags.conf` works (producing a warning, though) while in `electron19-flags.conf` does not. Seems like the latter file is ignored by vscode.
Comment by Massimiliano Torromeo (mtorromeo) - Wednesday, 07 September 2022, 12:30 GMT
It is not ignored, the command executed is exactly the one I mentioned over here.

You can test this is the case by changing `/usr/bin/electron19` so that the first line is `#!/usr/bin/bash -x`
Comment by bacteriostat (bacteriostat) - Wednesday, 07 September 2022, 13:59 GMT
I would really want the flag in electron19-flags.conf so that all electron applications can use the same flag.

Why is that code does not pick up the flag but bitwarden picks the flag?
Comment by Ivan Oleynikov (ph14nix) - Monday, 19 September 2022, 13:20 GMT
I get the same behavior with Electron 20. Please add it to the title as well.
Comment by Toolybird (Toolybird) - Tuesday, 08 November 2022, 20:01 GMT
Another dupe  FS#76483  (or at least closely related)
Comment by Martin Rys (C0rn3j) - Tuesday, 08 November 2022, 20:13 GMT
> I don't even know why that variable was set in the script, and I am leaning towards just removing it but does anyone know more about why it might be needed?

CLI commands, as per the above linked issue, they are currently broken.
Comment by Martin Rys (C0rn3j) - Monday, 13 March 2023, 22:51 GMT
@mtorromeo

Could the ELECTRON_RUN_AS_NODE=1 variable be added back for the time being?

It is necessary as per upstream (see linked issue) and it breaks my Ansible deployment playbooks when it is missing.

Loading...