fcitx / fcitx5

maybe a new fcitx.
1.62k stars 118 forks source link

electron调用wayland的时候,无法调用fcitx lib #760

Closed sci-42ver closed 1 year ago

sci-42ver commented 1 year ago
          可以先查一下这个进程加载的lib,里边有没有fcitx的插件

Originally posted by @san-Hei in https://github.com/fcitx/fcitx5/issues/458#issuecomment-1078779242

试过了 不使用wayland可以调用,用了之后就调用不了,能帮忙看下什么问题么(按照archwiki 配了参数, 应该是起效了,headbar有wayland图标)

还有一个问题是 如果用官方tar包安装,然后运行,会显示以下报错(drm link出错),看aur的insider版本并没有 link 这些so文件,不知道影不影响

lib权限都是755,owner为root,把~/VSCode-linux-x64/code owner改为root用户和用户组依旧会报错

$ ~/VSCode-linux-x64/code --ozone-platform-hint=auto  --enable-features=WaylandWindowDecorations --gtk-version=4
[main 2023-03-31T06:08:23.673Z] update#setState idle
[58952:0331/140823.689811:ERROR:gpu_init.cc(481)] Passthrough is not supported, GL is egl, ANGLE is 
MESA-LOADER: failed to open nvidia-drm: /usr/lib/gbm/nvidia-drm_gbm.so: cannot open shared object file: Permission denied (search paths /usr/lib/gbm, suffix _gbm)
MESA-LOADER: failed to retrieve device information
MESA-LOADER: failed to open nvidia-drm: /usr/lib/dri/nvidia-drm_dri.so: cannot open shared object file: Permission denied (search paths /usr/lib/dri, suffix _dri)
MESA-LOADER: failed to open zink: /usr/lib/dri/zink_dri.so: cannot open shared object file: Permission denied (search paths /usr/lib/dri, suffix _dri)
MESA-LOADER: failed to open kms_swrast: /usr/lib/dri/kms_swrast_dri.so: cannot open shared object file: Permission denied (search paths /usr/lib/dri, suffix _dri)
MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: Permission denied (search paths /usr/lib/dri, suffix _dri)

electron 使用版本 (vscode developer tool console看的)

navigator.userAgent
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.76.2 Chrome/102.0.5005.196 Electron/19.1.11 Safari/537.36'

复现 (开wayland 不能调用fcitx)

$ code-insiders --ozone-platform-hint=auto  --enable-features=WaylandWindowDecorations --gtk-version=4
$ pstree -apnh | grep code-ins | head
  |   |   |   |   |-grep,57497 --color=auto code-ins
  |   |-code-insiders,56272
  |   |   |-{code-insiders},56273
  |   |   |-code-insiders,56275
  |   |   |   `-code-insiders,56312
  |   |   |       |-code-insiders,56328
  |   |   |       |-{code-insiders},56337
  |   |   |       |-{code-insiders},56338
  |   |   |       |-{code-insiders},56339
  |   |   |       |-{code-insiders},56341
$ pmap 56272 | grep fci
$ pmap 59758 | grep drm
00007f2d084df000     20K r---- libdrm.so.2.4.0
00007f2d084e4000     48K r-x-- libdrm.so.2.4.0
00007f2d084f0000     16K r---- libdrm.so.2.4.0
00007f2d084f4000      4K r---- libdrm.so.2.4.0
00007f2d084f5000      4K rw--- libdrm.so.2.4.0
$ pmap 59758 | grep gbm
00007f2d0843c000     12K r---- libgbm.so.1.0.0
00007f2d0843f000     28K r-x-- libgbm.so.1.0.0
00007f2d08446000     16K r---- libgbm.so.1.0.0
00007f2d0844a000      4K r---- libgbm.so.1.0.0
00007f2d0844b000      4K rw--- libgbm.so.1.0.0
$ pmap 59758 | grep dri

但是 不开

$ code-insiders
$  pstree -apnh | grep code-ins | head
  |   |   |   |   |-grep,60970 --color=auto code-ins
  |   |-code-insiders,60325
  |   |   |-{code-insiders},60326
  |   |   |-code-insiders,60328
  |   |   |   `-code-insiders,60360
  |   |   |       |-code-insiders,60409
  |   |   |       |-{code-insiders},60410
  |   |   |       |-{code-insiders},60411
  |   |   |       |-{code-insiders},60412
  |   |   |       |-{code-insiders},60413
$ pmap 60325 | grep fci
00007f9a88eeb000     24K r---- im-fcitx5.so
00007f9a88ef1000     48K r-x-- im-fcitx5.so
00007f9a88efd000     12K r---- im-fcitx5.so
00007f9a88f00000      4K r---- im-fcitx5.so
00007f9a88f01000      4K rw--- im-fcitx5.so
$ pmap 60325 | grep drm
00007f9a9ebba000     20K r---- libdrm.so.2.4.0
00007f9a9ebbf000     48K r-x-- libdrm.so.2.4.0
00007f9a9ebcb000     16K r---- libdrm.so.2.4.0
00007f9a9ebcf000      4K r---- libdrm.so.2.4.0
00007f9a9ebd0000      4K rw--- libdrm.so.2.4.0
$ pmap 60325 | grep dri
CoelacanthusHex commented 1 year ago

electron can't use gtk4, you should use --enable-wayland-ime instead. But you need a compositor that supports text-input-v1, such as KWin 5.27+, weston or hyprland.

sci-42ver commented 1 year ago

electron can't use gtk4, you should use --enable-wayland-ime instead. But you need a compositor that supports text-input-v1, such as KWin 5.27+, weston or hyprland.

Yes. thanks very much. I used kde(kwin 5.27.3).

1- I had followed this wiki. Maybe made some mistakes when following the instructions.

In the above wiki, is things like text-input-v1 same as this one

2- However vscode seems to still not load im-fcitx5.so when using Wayland. With this help, I found whether with wayland or not libdbus-1.so.3.32.2 always load (because dbus is important for communication) , but may not found compositor lib loaded. So does it mean it use dbus as the medium ?

debug info (6013 is code parent pid)

$ pmap 6013 | grep kw
$ pmap 6013 | grep fc
$ pmap 6013 | grep db            
...
00007f10dbfce000     56K r---- libdbus-1.so.3.32.2
00007f10dbfdc000    184K r-x-- libdbus-1.so.3.32.2
00007f10dc00a000     72K r---- libdbus-1.so.3.32.2
00007f10dc01c000      8K r---- libdbus-1.so.3.32.2
00007f10dc01e000      4K rw--- libdbus-1.so.3.32.2
...
CoelacanthusHex commented 1 year ago

electron can't use gtk4, you should use --enable-wayland-ime instead. But you need a compositor that supports text-input-v1, such as KWin 5.27+, weston or hyprland.

Yes. thanks very much. I used kde(kwin 5.27.3).

1- I had followed this wiki. Maybe made some mistakes when following the instructions.

Make sure your fcitx was launched by kwin through Virtual Keyboard KCM instead of xdg autostarts.

In the above wiki, is things like text-input-v1 same as this one

2- However vscode seems to still not load im-fcitx5.so when using Wayland. With this help, I found whether with wayland or not libdbus-1.so.3.32.2 always load (because dbus is important for communication) , but may not found compositor lib loaded. So does it mean it use dbus as the medium ?

text-input-v1 need load neither fcitx im module nor dbus library. It was implemented by chromium self.

sci-42ver commented 1 year ago

1- Yes, I use KCM. and based on this wiki I used to autostart by xdg, now I changed.

$ ls /etc/xdg/autostart/                        
at-spi-dbus-bus.desktop     klipper.desktop                    pam_kwallet_init.desktop                   xembedsniproxy.desktop
baloo_file.desktop          org.kde.discover.notifier.desktop  polkit-kde-authentication-agent-1.desktop
gmenudbusmenuproxy.desktop  org.kde.plasmashell.desktop        powerdevil.desktop
kaccess.desktop             org.kde.plasma-welcome.desktop     pulseaudio.desktop
# no fcitx5 now
$ ls ~/.config/autostart/

2- similar to this issue, when launching vscode by code-insiders --ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime, I fails to select by mouse. But dropping --enable-wayland-ime I can select but no fcitx5 in vscode. what may cause this ?

version info

$ code-insiders -v
1.77.0-insider
7f329fe6c66b0f86ae1574c2911b681ad5a45d63
x64
$ pacman -Qs fcitx
local/fcitx5 5.0.23-1 (fcitx5-im)
    Next generation of fcitx
local/fcitx5-chinese-addons 5.0.17-1
    Addons related to Chinese, including IME previous bundled inside fcitx4
local/fcitx5-configtool 5.0.17-1 (fcitx5-im)
    Configuration Tool for Fcitx5
local/fcitx5-gtk 5.0.23-1 (fcitx5-im)
    Fcitx5 gtk im module and glib based dbus client library
local/fcitx5-pinyin-zhwiki 1:0.2.4.20230329-1
    Fcitx 5 Pinyin Dictionary from zh.wikipedia.org
local/fcitx5-qt 5.0.17-1 (fcitx5-im)
    Fcitx5 Qt Library
local/fcitx5-rime 5.0.16-1
    RIME support for Fcitx5
local/fcitx5-solarized 0.1-1
    Solarized color theme for Fcitx5
$ pacman -Q plasma-meta sddm
plasma-meta 5.27-2
sddm-git 0.19.0.212.g5fceaa9-1
$ pacman -Qs wayland        
local/egl-wayland 2:1.1.11-3
    EGLStream-based Wayland external platform
local/kwayland 5.104.0-1 (kf5)
    Qt-style Client and Server library wrapper for the Wayland libraries
local/kwayland-integration 5.27.3-1 (plasma)
    Provides integration plugins for various KDE frameworks for the wayland windowing system
local/layer-shell-qt 5.27.3-1 (plasma)
    Qt component to allow applications to make use of the Wayland wl-layer-shell protocol
local/libdecor 0.1.1-2
    Client-side decorations library for Wayland clients
local/libva 2.17.0-1
    Video Acceleration (VA) API for Linux
local/plasma-wayland-session 5.27.3-1
    Plasma Wayland session
local/qt5-wayland 5.15.8+kde+r63-1 (qt qt5)
    Provides APIs for Wayland
local/wayland 1.21.0-2
    A computer display server protocol
local/wayland-protocols 1.31-1
    Specifications of extended Wayland protocols
local/wayland-utils 1.1.0-1
    Wayland tools to display information about current compositor
local/weston 11.0.1-1
    Reference implementation of a Wayland compositor
local/xorg-xwayland 23.1.0-1 (xorg)
    run X clients under wayland
wengxt commented 1 year ago

it doesn't need to load fcitx library to work. just to let you know.

And you want to check if fcitx is correctly using kwin's input method protocol, specifically if you run

qdbus org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1.DebugInfo 

Under Group [wayland:] there should be a line looks like (program name is empty) and frontend is wayland:

  IC [4a8e1487ded94c81b1e487cc7d750e1e] program: frontend:wayland cap:52 focus:0
sci-42ver commented 1 year ago

it doesn't need to load fcitx library to work. just to let you know.

And you want to check if fcitx is correctly using kwin's input method protocol, specifically if you run

qdbus org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1.DebugInfo 

Under Group [wayland:] there should be a line looks like (program name is empty) and frontend is wayland:

  IC [4a8e1487ded94c81b1e487cc7d750e1e] program: frontend:wayland cap:52 focus:0

1- Thanks for your answers and in my computer fcitx is actually using kwin's input method protocol. So in this way, fctix5 use wayland -> compositor -> fcitx to communicate, is this true?

2- Although mouse select has problems, as my comment show, shift is one workaround. Also can use vim (although normally I not use vim keymap in vscode)

Or just use x11, wayland may be still in experiment in some aspects.

Thanks anyway.

wengxt commented 1 year ago

It's a interesting bug (mouse selection). I can reproduce it here but I'm also a little bit surprise that I never noticed this because I guess I always use keyboard to do such things. The bug itself probably have nothing to do with fcitx.

The bug you have seen is not the only bug when wayland (wayland ime is enabled).

I reported another bug I had here: https://github.com/microsoft/vscode/issues/176338

sci-42ver commented 1 year ago

In vscode-insiders 1.78 the above two bug has been fixed tested on my machine. Thanks for the vscode development team and fcitx5 team all.