Skip to content

HiDPI support on Wayland on RStudio electron #11962

Closed

Description

@ozankiratli

Currently, RStudio electron works without workarounds on Wayland; however, it doesn't support HiDPI monitors and renders them blurry. From my understanding, electron apps may support "--enable-features=UseOzonePlatform—-ozone-platform=wayland" flags to render them natively on Wayland and support HiDPI monitors. I believe it is not currently implemented, but it would be fantastic going forward.

I tried this on Ubuntu 22.04 + swaywm, using the electron build of rstudio (rstudio-2022.07.2+576).

> ./rstudio --enable-features=UseOzonePlatform --ozone-platform=wayland

And got an error message.

[1197763:0916/102513.715337:ERROR:gl_factory.cc(128)] Requested GL implementation (gl=desktop-gl,angle=none) not found in allowed implementations: [(gl=egl-gles2,angle=none),(gl=egl-angle,angle=swiftshader)].
[1197763:0916/102513.719958:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization

Edit: June 14, 2024

Update with RStudio version: 2024.04.2+764

In my previous solutions, I disabled the GPU to run RStudio without errors. I found a workaround for the gles error, and enabled hardware acceleration. If you want to use hardware acceleration on Wayland, you need to set --gl=angle; the other implementations of gl fall back to software rendering. Currently, there is no need to enable the Ozone Platform feature anymore, I believe it is enabled by default. And instead of setting the platform directly to Wayland, you can add --ozone-platform-hint=auto. If you have vaapi installed correctly, you can also enable that with --enable-features=VaapiVideoEncoder. Currently, I have the following line as a workaround, and it works without errors.

rstudio --ozone-platform=wayland --use-gl=angle --enable-features=VaapiVideoEncoder   

Checking the GPU diagnostics, I get:

Graphics Feature Status
=======================
*   Canvas: Hardware accelerated
*   Canvas out-of-process rasterization: Disabled
*   Direct Rendering Display Compositor: Disabled
*   Compositing: Hardware accelerated
*   Multiple Raster Threads: Enabled
*   OpenGL: Enabled
*   Rasterization: Hardware accelerated
*   Raw Draw: Disabled
*   Skia Graphite: Disabled
*   Video Decode: Hardware accelerated
*   Video Encode: Hardware accelerated
*   Vulkan: Disabled
*   WebGL: Hardware accelerated
*   WebGL2: Hardware accelerated
*   WebGPU: Disabled

Addition 5 mins later: Just realized in Chrome 123 the flag --use-gl is replaced with --gl. Once RStudio starts using corresponding Chrome version, the flag will need to be updated.

Activity

  1. added
    new
    on Sep 16, 2022
  2. ronblum commented on Sep 16, 2022

    @ronblum
    Contributor

    @evolozzy Thank you for raising this and the info!

    1. Does changing to software rendering makes a difference?
    2. Is the non-Electron version working correctly in this environment?
  3. removed
    new
    on Sep 16, 2022
  4. ozankiratli commented on Sep 16, 2022

    @ozankiratli
    Author

    @ronblum

    1. Changing the software rendering setting doesn't have an effect on the rendering issue.
    2. non-Electron version is not expected to work on wayland environment correctly, as it utilizes xwayland. I also use a workaround to get it to work: export QT_QPA_PLATFORM=xcb && rstudio . For electron version I don't need to use this workaround.

    As a note, this has been a common problem when switching from X11 to wayland for many apps. From the previous discussions here, I believe the development for wayland compositors was planned under electron version, that's why I wanted to raise this issue.

  5. ronblum commented on Sep 16, 2022

    @ronblum
    Contributor

    @evolozzy Thank you for the reminder regarding the Qt version and Wayland—especially considering that I filed the "support Wayland" issue #5333! 😄

  6. ozankiratli commented on Dec 24, 2022

    @ozankiratli
    Author

    Update rstudio-2022.12.0+353 :

    1. I succeeded to run rstudio natively on Wayland. I used the following command. Without any errors so far.
    > rstudio --disable-gpu --enable-features=UseOzonePlatform --ozone-platform=wayland
    

    If I run Sys.getenv() during this session I can see that GDK_BACKEND is set to wayland.
    I believe this can be implemented natively, even though I don't know how.

    1. Without disabling gpu, enabling wayland crashes rstudio with following errors.
    > rstudio --enable-features=UseOzonePlatform --ozone-platform=wayland
    [935649:1223/221012.311267:ERROR:gl_factory.cc(128)] Requested GL implementation (gl=desktop-gl,angle=none) not found in allowed implementations: [(gl=egl-gles2,angle=none),(gl=egl-angle,angle=swiftshader)].
    [935649:1223/221012.312656:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization
    [935685:1223/221012.346907:ERROR:command_buffer_proxy_impl.cc(126)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.
    [935724:1223/221012.349610:ERROR:command_buffer_proxy_impl.cc(126)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.
    
    1. When I run rstudio without disabling gpu and without ozone platform flags, I get several errors on the console, however, it opens and functions without any problems. If I run Sys.getenv() during this session I can see that GDK_BACKEND is set to x11.
    > rstudio
    libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
    [8203:1223/221805.986664:ERROR:gpu_init.cc(481)] Passthrough is not supported, GL is desktop, ANGLE is
    [8203:1223/221808.164407:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
    [8203:1223/221808.271192:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 2 times!
    [8203:1223/221809.462062:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 3 times!
    
    1. For these errors, if I set LIBVA_DRIVER_NAME manually and, the first line of error disappears. For the rest of the errors I need to disable gpu. The code below successfully opens rstudio without any errors. If I run Sys.getenv() during this session I can see that GDK_BACKEND is set to x11.
    > LIBVA_DRIVER_NAME=intel rstudio --disable-gpu  
    

    I need to set LIBVA_DRIVER_NAME to successfully run rstudio with x11 backend (See 4.), but I don't need to set it to run with wayland backend. (See 1.)

    I hope this helps.

  7. arcruz0 commented on Jan 29, 2023

    @arcruz0

    Thanks, @evolozzy! Results are night and day for me (Ozone on the left):

    rstudio_comparison

    After running rstudio --disable-gpu --enable-features=UseOzonePlatform --ozone-platform=wayland, two things do not work for me on Ubuntu 22.04 (LTS):

    1. The cursor is white, while my system cursor is black. I found a fix in a Reddit comment:
      mkdir ~/.icons && cp -r /usr/share/icons/Yaru ~/.icons/default

    2. RStudio loses its titlebar. I tried adding the WaylandWindowDecorations feature:
      rstudio --disable-gpu --enable-features=UseOzonePlatform,WaylandWindowDecorations --ozone-platform=wayland
      While this adds a titlebar, the titlebar does not follow the system's. See below compared to gedit and Libreoffice:
      rstudio_titlebars_comp

    I also do not know how to set RStudio to always open with these changes. I can modify its desktop entry and make a Bash alias, but new windows called from within RStudio will not open with the Ozone layer (e.g., opening projects from the top-right menu opens a new window without Wayland support).

    Hopefully this testing is useful to someone! Thanks everyone.

  8. github-actions commented on Sep 1, 2023

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

  9. added
    stale
    on Sep 1, 2023
  10. ozankiratli commented on Sep 1, 2023

    @ozankiratli
    Author

    I believe this is still an issue on RStudio 2023.06.2 Build 561.

    Without the workaround, RStudio opens as an xwayland application.

  11. removed
    stale
    on Sep 2, 2023
  12. GerryT11 commented on Mar 7, 2024

    @GerryT11

    As it seems the current RStudio 2023.12.1 Build 402 on Ubuntu/.deb still does not support/enable Wayland out of the box. I noticed that RStudio is not running on Wayland, but rather XWayland. Are there any blocker issues to enable Wayland by default?

    System: Ubuntu 23.04 running with Wayland.
    RStudio 2023.12.1+402 "Ocean Storm" Release (4da5832, 2024-01-29) for Ubuntu Jammy
    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) rstudio/2023.12.1+402 Chrome/116.0.5845.190 Electron/26.2.4 Safari/537.36

  13. kevinushey commented on Mar 7, 2024

    @kevinushey
    Collaborator

    Presumedly this will happen in RStudio once Wayland is supported by default out-of-the-box in Electron? Until then, my guess is the various tricks in https://wiki.archlinux.org/title/wayland#Electron need to be tried?

  14. github-actions commented on Apr 9, 2025

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

  15. added
    stale
    on Apr 9, 2025
  16. github-actions commented on Apr 23, 2025

    @github-actions

    This issue has been automatically closed due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    electronenhancementstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions