flathub / com.vscodium.codium

https://flathub.org/apps/details/com.vscodium.codium
94 stars 19 forks source link

Fail to run under openSUSE Tumbleweed, KDE Plasma 6 and Wayland, with default settings #321

Closed rc-zb closed 2 months ago

rc-zb commented 3 months ago

Bug

As the title shows.

Reproduction

  1. flatpak --user install com.vscodium.codium

  2. flatpak --user run com.vscodium.codium --verbose, or without --verbose, or from the link in Application Dashboard.

  3. It fails.

  4. Now with --ozone-platform=wayland --enable-wayland-ime instead, the program runs correctly.

Log

During step 3:

codium-wrapper: Setting up NPM packages
codium-wrapper: Setting up Cargo packages
codium-wrapper: Setting up Python packages
codium-wrapper: Setting up Ruby packages
Warning: 'ozone-platform' is not in the list of known options, but still passed to Electron/Chromium.
[19 zypak-helper] Using spawn strategy test 1 as set by environment
[19:0316/201021.149916:ERROR:ozone_platform_x11.cc(240)] Missing X server or $DISPLAY
[19:0316/201021.149949:ERROR:env.cc(255)] The platform failed to initialize.  Exiting.

Version

Peter Squicciarini - Telemetry-less code editing

          ID: com.vscodium.codium
         Ref: app/com.vscodium.codium/x86_64/stable
        Arch: x86_64
      Branch: stable
     Version: 1.87.2.24072
     License: MIT
      Origin: flathub
  Collection: org.flathub.Stable
Installation: user
   Installed: 363.6 MB
     Runtime: org.freedesktop.Sdk/x86_64/23.08
         Sdk: org.freedesktop.Sdk/x86_64/23.08

      Commit: 810d4e6bff09ab46da0d32b52887dbb266c4316789a4bb788e9d844380af1247
      Parent: bf2ae40bc46610c6c25591aaff5e9a2b1a34bc865cecc26c44fe9914cdd49f8a
     Subject: :tada: Update VSCodium (969e285a)
        Date: 2024-03-12 23:05:40 +0000

System Information

Operating System: openSUSE Tumbleweed 20240314
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.7.9-1-default (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 7840H with Radeon 780M Graphics
Memory: 27.1 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: LENOVO
Product Name: 21J2
System Version: ThinkBook 16 G5+ APO
noonsleeper commented 3 months ago

@rc-zb maybe do you need to follow https://github.com/flathub/com.vscodium.codium?tab=readme-ov-file#wayland-vs-x11 also run the permission-reset command?

maxkapur commented 2 months ago

Confirming the same issue after upgrading from Fedora Kinoite 39 to 40 (and therefore to KDE 6.0), even after resetting permissions:

max@fedora /v/h/max> flatpak permission-reset com.vscodium.codium 
max@fedora /v/h/max> flatpak run com.vscodium.codium
codium-wrapper: Setting up NPM packages
codium-wrapper: Setting up Cargo packages
codium-wrapper: Setting up Python packages
codium-wrapper: Setting up Ruby packages
[2 zypak-helper] Wait found events, but sd-event found none
Warning: 'ozone-platform' is not in the list of known options, but still passed to Electron/Chromium.

just bumps me back to my shell.

This is under Wayland, so I'm not sure the Wayland vs X11 FAQ (which gives instructions for running on X11) applies.

Confirming also that adding --ozone-platform=wayland --enable-wayland-ime enables VSCodium to start without issue.

matteopaolucci commented 2 months ago

I'm having the same issue on Fedora 40 KDE spin (Wayland), even after trying to reset the permissions:

matteo@fedora:~$ flatpak permission-reset com.vscodium.codium
matteo@fedora:~$ flatpak run com.vscodium.codium 
codium-wrapper: Setting up NPM packages
codium-wrapper: Setting up Cargo packages
codium-wrapper: Setting up Python packages
codium-wrapper: Setting up Ruby packages
Warning: 'ozone-platform' is not in the list of known options, but still passed to Electron/Chromium.

I confirm, too, that using the options --ozone-platform=wayland --enable-wayland-ime the program start normally.

noonsleeper commented 2 months ago

Hi @maxkapur and @matteopaolucci, maybe the update on your flatpak setup is not changed to the new defaults, can you run

flatpak override --user --nosocket=x11 --socket=wayland com.vscodium.codium

and then try to run

flatpak run com.vscodium.codium --verbose 2>&1 | grep -i wayland
RaduAvramescu commented 2 months ago

Hello @noonsleeper,

On KDE Plasma 6 with Wayland, I have the same issue (crash on startup).

I ran both commands, one after the other. Unfortunately, the crash still persists.

There is no interesting output from what I can tell, using the second command. However, removing the grep part produces this output:

codium-wrapper: Setting up NPM packages
codium-wrapper: Setting up Cargo packages
codium-wrapper: Setting up Python packages
codium-wrapper: Setting up Ruby packages
Warning: 'ozone-platform' is not in the list of known options, but still passed to Electron/Chromium.
[19 zypak-helper] Using spawn strategy test 1 as set by environment
[19:0502/114129.508763:ERROR:ozone_platform_x11.cc(240)] Missing X server or $DISPLAY
[19:0502/114129.508785:ERROR:env.cc(255)] The platform failed to initialize.  Exiting.

That said, I'd like to mention that the app launched successfully using this command (both before and after running the flatpak override command):

flatpak run com.vscodium.codium --ozone-platform=wayland
noonsleeper commented 2 months ago

@RaduAvramescu, you are right about command output is not being redirected to stdout. (I fixed that) Your log says that something is forcing codium to start on X11 instead of Wayland then try to disable at all X11 (for reference https://github.com/noonsleeper/ide-flatpak-wrapper/blob/3c0635635e4d056a6d18d79c10f66db67de98a93/editor.sh#L10 this is the function that handle the selection between wayland or X11

flatpak override --user --socket=wayland --nosocket=x11 --nosocket=fallback-x11 com.vscodium.codium \
&& flatpak run com.vscodium.codium --verbose

Also you can check if the environment variables are spawning inside of the container

flatpak run --command=bash com.vscodium.codium

then

echo "${XDG_SESSION_TYPE}"
echo "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY}"
RaduAvramescu commented 2 months ago

@noonsleeper No go either, I still have the same errors even with those commands.

To be clear, the output of echo $XDG_SESSION_TYPE is:

wayland

And the output of echo $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:

/run/user/1000/wayland-0

I assume these are as they should be.

RaduAvramescu commented 2 months ago

@noonsleeper Sorry, what I posted above was in response to what you wrote prior to your edit.

In the container, here are the values:

  1. For echo $XDG_SESSION_TYPE: wayland
  2. For echo $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY: /run/user/1000//run/flatpak/wayland-0
noonsleeper commented 2 months ago

I will test if replacing --ozone-platform-hint=auto (that is the recommendation for electron apps) with --ozone-platform=wayland I'll hope doesn't break things on another DE.

@RaduAvramescu thanks for debugging and logs.

RaduAvramescu commented 2 months ago

@noonsleeper Perhaps --ozone-platform-hint=auto isn't being passed? When running with the --ozone-platform=wayland argument, I get this output:

Option 'ozone-platform' is defined more than once. Using value 'wayland'.

But, when I run flatpak run com.vscodium.codium --ozone-platform-hint=auto, I do not get a warning like the output above... So, it looks to me like when it in fact does the Wayland checks in https://github.com/noonsleeper/ide-flatpak-wrapper/blob/3c0635635e4d056a6d18d79c10f66db67de98a93/editor.sh#L10 it may hit the else statement.

Perhaps the reason why --ozone-platform=wayland as an argument works is because it's overriding the one set in the code (I'm assuming the argument from the terminal has higher priority). If you instead do what you said above, it may lead to the same issue...

This is just a theory and I have no idea if I'm even close to right, feel free to correct me if I'm wrong of course.

RaduAvramescu commented 2 months ago

As an update, manually running flatpak run com.vscodium.codium --ozone-platform-hint=auto --enable-wayland-ime --enable-features=WaylandWindowDecorations (which, from what I could tell, would be close-ish to the normal arguments), produces the same errors.

I'm assuming that despite doing this, the internal code is somehow setting --ozone-platform=x11 which is overriding the arguments I used above.

RaduAvramescu commented 2 months ago

After digging a little bit into it, I think my suspicions were correct.

After running flatpak run com.vscodium.codium --verbose the application refuses to start, as has happened so far.

Right after that, running coredumpctl info produces, among other output, this line:

Command Line: $'/app/share/codium/codium --extensions-dir --ozone-platform=x11 --verbose /home/Radu/.var/app/com.vscodium.codium/data/codium/extensions'

It looks like --verbose was successfully passed, but indeed --ozone-platform=x11 is present, which leads me to believe that the else statement from https://github.com/noonsleeper/ide-flatpak-wrapper/blob/3c0635635e4d056a6d18d79c10f66db67de98a93/editor.sh#L10 was run instead of the Wayland one.

PS: Apologies for the comment spam, I thought it made more sense to do it this way rather than continuing to edit a single comment, as I discovered things after each comment and I'm not sure if a single big comment would be easier to read.

daiyam commented 2 months ago

So basically, the test fails because $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY doesn't exists.

From your debug: echo $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY: /run/user/1000//run/flatpak/wayland-0

Seems like a conflict...

From https://gaultier.github.io/blog/wayland_from_scratch.html, I found those steps to open the socket to wayland which can be replicated to detect it:

@noonsleeper What do you think?

RaduAvramescu commented 2 months ago

@daiyam Yeah, that seems to be the case. For the record, here is additional information, from Hyprland (installed alongside KDE Plasma), where it works by default, but I just wanted to grab the values for comparison's sake:

  1. echo $XDG_RUNTIME_DIR output: /run/user/1000
  2. echo $WAYLAND_DISPLAY output: wayland-1
  3. echo $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY output: /run/user/1000/wayland-1

So, basically, it appears that the difference between KDE Plasma and Hyprland lies in the $WAYLAND_DISPLAY environment variable.

noonsleeper commented 2 months ago
  • If $WAYLAND_DISPLAY is set, attempt to connect to $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY

  • Otherwise, attempt to connect to $XDG_RUNTIME_DIR/wayland-0

  • Otherwise, fail

@daiyam Thanks for the link and the rational! I will add $XDG_RUNTIME_DIR/wayland-0 to the loop of checks =)

noonsleeper commented 2 months ago

@RaduAvramescu, @matteopaolucci, @maxkapur, @rc-zb Can check this build?

flatpak install --user https://dl.flathub.org/build-repo/101976/com.vscodium.codium.flatpakref

It's only available for 24hs

noonsleeper commented 2 months ago

Since I have confirmation that 2 KDE users that #331 fix the problem, I will merge this ASAP.

RaduAvramescu commented 2 months ago

Thanks for the fix @noonsleeper!

Sorry, I couldn't help test because I don't have a KDE install anymore (though it's temporary).