ibus-x11 does not start automatically

Bug #1946969 reported by Ikuya Awashiro
24
This bug affects 2 people
Affects Status Importance Assigned to Milestone
mozc (Ubuntu)
Undecided
Gunnar Hjalmarsson
Impish
High
Gunnar Hjalmarsson

Bug Description

[Impact]

This is bugfix SRU.

The mainly problem is user cannot input Japanese language with IBus/Mozc.

One of the causes is Xwayland will not start on 21.10.
If there is no Xwayland process, gnome-shell/mutter will drop "--xim"
option of ibus-daemon and ibus-x11 process doesn't start.

For reasons unknown, IBus/Mozc does not work as a result.

Essentially, it should be fixed so that it works without Xwayland
and ibus-x11, but it takes time to investigate, so we will workaround
it by forcing Xwayland to start by xrefresh command.

[Test Plan]

1. run Ubuntu 21.10 installer
2. select Japanese language and keyboard
3. finish to install and reboot
4. login and complete gnome-initial-setup
5. apply the mozc SRU and reboot
6. login
7. press Windows key + Space key and select Japanese (Mozc)
8. startup gedit
9. press Hankaku/Zenkaku key

If you can input Japanese language, then test is ok.

[Where problems could occur]

* Only affects to mozc installed machine, it is mainly Japanese user's machine.
* The worst case is that those user cannot input Japanese language if the update is invalid.
* However current 21.10 is already same state.

[Original description]

ibus-x11 does not start automatically due to Xwayland on demand by default.
IBus user does not input any cjkv languages before start to ibus-x11 or xwayland process.

Steps to reproduce:

1. run Ubuntu 21.10 installer
2. select Japanese language
3. finish to install and reboot
4. login
5. reboot
6. login
7. push Windows key + Space key and select Japanese (Mozc)
8. run gedit
9. push Hankaku/Zenkaku key

Expected results:

show any Japanese characters

Actual results:

input any alphabetical key which I push

observation:

This may be mutter's matter.
Xwayland on demand by default
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1673

workaround:

1. run gnome-terminal and run command "ibus-daemon -rxd"
2. run any xwayland application like Libreoffice
3. use X session
4. restart IBus automatically when log in

exaple:
$ sudo editor /etc/xdg/autostart/ibus-autostart.desktop

[Desktop Entry]
Name=ibus-autostart
Exec=sh -c 'if [ "${IM_CONFIG_CHECK_ENV}" = "1" ] && [ "${XDG_SESSION_TYPE}" = "wayland" ] && [ "${XDG_CURRENT_DESKTOP}" = "ubuntu:GNOME" ] || [ "${XDG_CURRENT_DESKTOP}" = "GNOME" ]; then ibus-daemon -rxd true; fi'
TryExec=ibus-daemon
Type=Application

Revision history for this message
Ikuya Awashiro (ikuya-fruitsbasket) wrote (last edit ):

Hi Gunnar-san and Shibata-san, please take a look.
Noone report such a problem. Is it my fault?

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1946969/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
Changed in ubuntu:
status: New → Confirmed
Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

I can reproduced this issue in new installed impish.
However to reproduce this behaviour, you need to reboot on twice, isn't it?

First reboot will startup gnome-initial setup with GNOME_SETUP_DISPLAY, this environment variable will cause starting ibus-daemon with "--xim" option.

GNOME Shell drop "--xim" option[1] on wayland session[2] and there is no x11 apps.

[1] https://gitlab.gnome.org/GNOME/gnome-shell/-/commit/8adfc5b106d373bdae83b9a7b32e995f2a0d8331
[2] https://gitlab.gnome.org/GNOME/gnome-shell/-/commit/1a0ec782b521dbcb66c31fe6f56784127f71926a

Anyway, mozc require ibus-x11? or all ibus related ime require ibus-x11 on wayland?

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

> 4. restart IBus automatically when log in

More simple, but identical workaround:

---
cat <<'EOF' | sudo tee /etc/xdg/autostart/launch-xwayland.desktop
[Desktop Entry]
Name=Launch XWayland on startup
Exec=sh -c 'if [ "x$XDG_SESSION_TYPE" = "xwayland" ] ; then xrefresh; fi'
TryExec=xrefresh
Type=Application
EOF
---

* xrefresh just refresh X screen.
* if there is no ibus, this command will startup xwayland and refresh screen only.
* if there is ibus, Mutter will startup XWayland and GNOME Shell restart ibus-daemon with --xim option
* at the moment, Mutter doesn't remove xwayland even if all x11 apps exited.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Hi Ikuya, Mitsuya!

Confirmed here as well.

My understanding is that not all IBus IMs need ibus-x11, which may explain why the GNOME folks didn't notice this issue as regards ibus-mozc. It would be good if any of you could submit an upstream GNOME issue. I suppose that candidate projects are mutter and gnome-shell.

In the meantime im-config is the natural package for a workaround. This PPA:

https://launchpad.net/~gunnarhj/+archive/ubuntu/im-config

contains a modified im-config, which I think deals with the issue for now. I chose to edit two existing files instead of adding yet another autostart script.

Please let me know if you consider the im-config change to be sufficient, and also if you see any adverse side effects. If it's ok, we should make an SRU soon after the 21.10 release.

affects: ubuntu → im-config (Ubuntu)
Changed in im-config (Ubuntu):
assignee: nobody → Gunnar Hjalmarsson (gunnarhj)
importance: Undecided → High
status: Confirmed → In Progress
tags: added: impish regression-release
Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Hi Osamu,

This issue is reasonably present in bookworm too, and also your eyes on the patch in the PPA would be appreciated. Especially there is one thing I'm not sure about: To make it work I had to set IM_CONFIG_CHECK_ENV=0, and with that bypass the check in im-launch.

description: updated
Revision history for this message
Ikuya Awashiro (ikuya-fruitsbasket) wrote :

Thank you for your comments!

> However to reproduce this behaviour, you need to reboot on twice, isn't it?
Yes. You are right. Always right.

> It would be good if any of you could submit an upstream GNOME issue.
I think it is not mutter or gnome-shell issue but ibus-mozc issue.
ibus-mozc should work under wayland session.
Latest Mozc renderer was completely re-written.
https://github.com/google/mozc/commit/3b3068e924e17f8820a35899f105f2ef838d0535
I will try it later.

> Please let me know if you consider the im-config change to be sufficient, and also if you see any adverse side effects.
This change works great for me. Thank you for your work.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Gunnar,

> In the meantime im-config is the natural package for a workaround. This PPA:

It works for me. Thank you for your quick response!

However ibus-x11 process is doubled, it is ok?

    PID PGID SID TTY STAT TIME COMMAND
   1400 1400 1400 ? Ssl 0:00 /usr/libexec/gnome-session-binary --systemd-service --session=ubuntu
(snip)
   1438 1438 1438 ? Ssl 0:12 /usr/bin/gnome-shell
   1724 1438 1438 ? Sl 0:00 /usr/bin/Xwayland :0 -rootless -noreset -accessx -core -auth /run/user/1000/.mutter-Xwaylandauth.EDN3A1 -listen 4 -listen 5 -displayfd 6 -initfd 7
   1771 1771 1438 ? Sl 0:01 ibus-daemon --panel disable -r --xim
   1792 1771 1438 ? Sl 0:00 /usr/libexec/ibus-dconf
   1794 1771 1438 ? Sl 0:01 /usr/libexec/ibus-extension-gtk3
   1844 1771 1438 ? Sl 0:00 /usr/lib/ibus-mozc/ibus-engine-mozc --ibus
   1847 1771 1438 ? SLl 0:00 /usr/lib/mozc/mozc_server
(snip)
   1704 1696 1400 ? Sl 0:00 /usr/libexec/ibus-x11 --kill-daemon
   1776 1776 1776 ? Ssl 0:00 /usr/libexec/gsd-xsettings
   1803 1771 1438 ? Sl 0:00 /usr/libexec/ibus-x11 --kill-daemon
   1807 1302 1302 ? Sl 0:00 /usr/libexec/ibus-portal

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

On 2021-10-14 15:43, Ikuya Awashiro wrote:
>> It would be good if any of you could submit an upstream GNOME issue.
> I think it is not mutter or gnome-shell issue but ibus-mozc issue.
> ibus-mozc should work under wayland session.
> Latest Mozc renderer was completely re-written.
> https://github.com/google/mozc/commit/3b3068e924e17f8820a35899f105f2ef838d0535
> I will try it later.

Hmm.. My thoughts in response to that:

* The commit message says: "Initial implementation of Qt-based renderer". When that reaches Debian, there is a risk that Ubuntu's desktop team won't accept to keep mozc in main (and on the ISO). Please remember that mozc-utils-gui is already not in main due to the qt dependencies.

* I assumed that the issue may be present also for other IBus IMs, which is why I proposed a general workaround in im-config. But if it's a pure mozc thing, it may be better to let the ibus-mozc package install a separate autostart file in line with what you and Mitsuya discuss above.

On 2021-10-14 15:46, Mitsuya Shibata wrote:
> However ibus-x11 process is doubled, it is ok?

Yeah, I saw that and assumed that it won't hurt... Is that duplication avoided with your idea with xrefresh (a command whose existence I wasn't aware of)? If it is, maybe that's a better approach.

Anyway, thanks both for confirming that the proposal in the PPA works. But I'm not sure ATM that doing it in im-config is right.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

> When that reaches Debian, there is a risk that Ubuntu's desktop team won't accept to keep mozc in main (and on the ISO).

I think so too. Unfortunately the Qt renderer and Gtk renderer seem to be exclusive at the moment. We still need Gtk renderer.

> > However ibus-x11 process is doubled, it is ok?

> Yeah, I saw that and assumed that it won't hurt... Is that duplication avoided with your idea with xrefresh (a command whose existence I wasn't aware of)? If it is, maybe that's a better approach.

Thanks confirm. I agree to adopt im-config approach. Please SRU it.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

I just found that this problem is not present in Debian testing, even if they have the same version of both mutter and ibus. Something seems to make Xwayland start at login, and hence ibus-x11 is also running.

That speaks against using im-config to work around it, since im-config is used by both Debian and Ubuntu.

I think we need to ask the Ubuntu desktop folks for advice.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

I submitted <https://discourse.ubuntu.com/t/24669> to involve the desktop team in the solution.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

> I just found that this problem is not present in Debian testing

Indeed, Xwayland is living on Debian/testing and ibus-daemon is restarted with --xim by gnome-shell. However xlsclients show only ibus-x11/gsd-xsettings/gnome-shell only.

Is any X11 related process started and then closed?

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

I tested multiple IBus IMs, and AFAICT the issue is a pure ibus-mozc one. Consequently I now believe that a reasonable solution is to let the ibus-mozc package install an autostart file for launching Xwayland. That way users who don't use ibus-mozc won't be affected.

New proposal in this PPA:

https://launchpad.net/~gunnarhj/+archive/ubuntu/mozc

If you agree, I'm ready to upload. Let me know.

Also, can someone please make the bug description 'SRU compatible':

https://wiki.ubuntu.com/StableReleaseUpdates#SRU_Bug_Template

no longer affects: gnome-shell (Ubuntu)
no longer affects: im-config (Ubuntu)
no longer affects: mutter (Ubuntu)
Changed in mozc (Ubuntu):
assignee: nobody → Gunnar Hjalmarsson (gunnarhj)
status: New → In Progress
Changed in mozc (Ubuntu Impish):
assignee: nobody → Gunnar Hjalmarsson (gunnarhj)
importance: Undecided → High
status: New → In Progress
Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Gunnar,

> New proposal in this PPA:

Many many thanks, confirmation and new patch.

I tried it on 21.10, and works great.

> Also, can someone please make the bug description 'SRU compatible':

I updated description.

description: updated
Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Thanks for editing the description! Ok, then let's get the ball rolling.

I uploaded the change to Debian unstable (to sync later) and to the impish unapproved queue.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mozc - 2.26.4220.100+dfsg-5.1

---------------
mozc (2.26.4220.100+dfsg-5.1) unstable; urgency=medium

  * Non-maintainer upload
  * Add autostart file to launch Xwayland on startup of wayland session
    - Proved to be useful on Ubuntu 21.10 (LP: #1946969)

 -- Gunnar Hjalmarsson <email address hidden> Sat, 16 Oct 2021 21:11:28 +0200

Changed in mozc (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Ikuya, or anyone else affected,

Accepted mozc into impish-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/mozc/2.26.4220.100+dfsg-4.1ubuntu0.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-impish to verification-done-impish. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-impish. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in mozc (Ubuntu Impish):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-impish
Revision history for this message
Ikuya Awashiro (ikuya-fruitsbasket) wrote :

mozc 2.26.4220.100+dfsg-4.1ubuntu0.1 works as expected.
Thanks!

tags: added: verification-done-impish
removed: verification-needed-impish
Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Gunnar,

For future release, I'm trying to figure out the cause this problem.

Here's what we know at this point.

1. DISPLAY=:1

For some reason, the DISPLAY env of ibus-daemon/ibus-engine-mozc is set to ":1".

$ strings /proc/$(pidof ibus-engine-mozc)/environ | grep ^DISPLAY
DISPLAY=:1

It seems that this should be "DISPLAY=:0".

2. Mozc call functions of libxcb on startup even if session is pure wayland.

https://github.com/google/mozc/blob/master/src/unix/ibus/selection_monitor.cc#L108-L143

3. xcb_connect() will be blocked infinity.

On Ubuntu, xcb_connect(":1") will be blocked infinity.

You can reproduce this behaviour with simple code.

  * Downlaod sample XCB code on Wikipedia.

    https://en.wikipedia.org/wiki/XCB#Example

  * Build sample code

    $ sudo apt install gcc libxcb1-dev
    $ gcc test.c -o test -lxcb

  * Do logout and login and confirm not start Xwayland process

    $ ps -fe | grep -i xwayland
    (check no xwayland process)

  * Check exists ":1" socket

    $ ls -l /tmp/.X11-unix/X1
    /tmp/.X11-unix/X1

  * Execute thesample program with DISPLAY=":1"

    DISPLAY=":1" ./test

The sample program will be blocked. You can comfirm this is blocked on connect() via xcb_connect().

---

However I doesn't investigate how about Debian testing.

Could you check following status?

* What value of $DISPLAY of ibus-engin-mozc:
  $ strings /proc/$(pidof ibus-engine-mozc)/environ | grep ^DISPLAY

* How number of x11 unix socket
  $ ls -l /tmp/.X11-unix/

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

This was run on Debian testing (GNOME / Wayland):

$ strings /proc/$(pidof ibus-engine-mozc)/environ | grep ^DISPLAY
DISPLAY=:1
$ ls -l /tmp/.X11-unix/
total 0
srwxr-xr-x 1 gunnar gunnar 0 okt 24 19:35 X0
srwxr-xr-x 1 gunnar gunnar 0 okt 24 19:35 X1
srwxr-xr-x 1 Debian-gdm Debian-gdm 0 okt 24 19:35 X1024
srwxr-xr-x 1 Debian-gdm Debian-gdm 0 okt 24 19:35 X1025

But please note that the ibus-x11 process is started on Debian even if mozc isn't installed.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

> This was run on Debian testing (GNOME / Wayland):

Thanks!

Umm... It seems that "DISPLAY=:1" is valid...

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mozc - 2.26.4220.100+dfsg-4.1ubuntu0.1

---------------
mozc (2.26.4220.100+dfsg-4.1ubuntu0.1) impish; urgency=medium

  * Add autostart file to launch Xwayland on startup of wayland session
    - Proved to be useful on Ubuntu 21.10 (LP: #1946969)

 -- Gunnar Hjalmarsson <email address hidden> Sat, 16 Oct 2021 21:21:15 +0200

Changed in mozc (Ubuntu Impish):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for mozc has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers