Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(linux): Don't start ibus-daemon multiple times 🚌 #6283

Merged
merged 5 commits into from
Mar 15, 2022

Conversation

ermshiperete
Copy link
Contributor

@ermshiperete ermshiperete commented Feb 24, 2022

This change adds a 1s sleep after restarting ibus before checking that it actually runs. Hopefully this will solve the problem. Since
this bug is hard to reproduce, we also log a critical error for the other code path this could happen.

Fixes #6237.

User Testing

Preparations

  • Since this bug is hard to reliably reproduce, the tests should be run on all Linux platforms:

    • GROUP_BIONIC: Ubuntu 18.04 Bionic with Gnome Shell and X11
    • GROUP_FOCAL: Ubuntu 20.04 Focal with Gnome Shell and X11
    • GROUP_IMPISH_X11: Ubuntu 21.10 Impish with Gnome Shell and X11
    • GROUP_IMPISH_WAYLAND: Ubuntu 21.10 Impish with Gnome Shell and Wayland
    • GROUP_WASTA: Wasta 20.04 with Cinnamon
  • Install build artifacts of this PR

  • Reboot

Tests

  • TEST_KB_INSTALL1: Download and install a keyboard

    • On the command line, run:
      km-config -v 2>&1 | tee /tmp/km-config.log
    • click "Download", enter search for "Khmer", and install the "Khmer Angkor" keyboard
    • On the command line, run:
      ps --user $USER -o cmd -o pid= -o s= | grep -e "^ibus-daemon"
    • Verify that this outputs exactly one line starting with ibus-daemon
    • If the test fails, attach the file /tmp/km-config.log or paste the content of /tmp/km-config.log
  • TEST_KB_INSTALL2: Download and install a second keyboard

    • repeat the previous test with a different keyboard:
    • On the command line, run:
      km-config -v 2>&1 | tee /tmp/km-config2.log
    • click "Download", enter search for "Icelandic", and install the "EuroLatin (SIL)" keyboard
    • On the command line, run:
      ps --user $USER -o cmd -o pid= -o s= | grep -e "^ibus-daemon"
    • Verify that this outputs exactly one line starting with ibus-daemon
    • If the test fails, attach the file /tmp/km-config2.log or paste the content of /tmp/km-config2.log

@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Feb 24, 2022

User Test Results

Test specification and instructions

  • ✅ GROUP_BIONIC: Ubuntu 18.04 Bionic with Gnome Shell and X11

    2 tests PASSED
    • TEST_KB_INSTALL1 (PASSED): Installed Keyman 15.0.212-beta and re-tested this in Bionic and it is working as expected.
    • TEST_KB_INSTALL2 (PASSED): Installed Keyman 15.0.212-beta and re-tested this in Bionic and it is working as expected.
  • ✅ GROUP_FOCAL: Ubuntu 20.04 Focal with Gnome Shell and X11

    2 tests PASSED
    • TEST_KB_INSTALL1 (PASSED): Installed 15.0.212-beta build in Ubuntu Focal Linux and it is working as expected.
    • TEST_KB_INSTALL2 (PASSED): Installed 15.0.212-beta build in Ubuntu Focal Linux and it is working as expected.
  • ✅ GROUP_IMPISH_X11: Ubuntu 21.10 Impish with Gnome Shell and X11

    2 tests PASSED
    • TEST_KB_INSTALL1 (PASSED): Installed Keyman 15.0.212-beta build (from PR) in Impish(Ubuntu) Linux and it is working as expected.
    • TEST_KB_INSTALL2 (PASSED): Installed Keyman 15.0.212-beta build (from PR) in Impish(Ubuntu) Linux and it is working as expected.
  • ✅ GROUP_IMPISH_WAYLAND: Ubuntu 21.10 Impish with Gnome Shell and Wayland

    2 tests PASSED
    • TEST_KB_INSTALL1 (PASSED): Installed Keyman 15.0.212-beta build (from PR) in Impish (Ubuntu on Xorg)Linux and it is working as expected.
    • TEST_KB_INSTALL2 (PASSED): Installed Keyman 15.0.212-beta build (from PR) in Impish (Ubuntu on Xorg) Linux and it is working as expected.
  • ✅ GROUP_WASTA: Wasta 20.04 with Cinnamon

    2 tests PASSED
    • TEST_KB_INSTALL1 (PASSED): Installed Keyman15.0.212-beta (from PR) and it is working as expected.
    • TEST_KB_INSTALL2 (PASSED): Installed Keyman15.0.212-beta (from PR) and it is working as expected.

Test Artifacts

Copy link
Contributor

@darcywong00 darcywong00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@bharanidharanj
Copy link

  • GROUP_FOCAL: Ubuntu 20.04 Focal with Gnome Shell and X11

    • TEST_KB_INSTALL1 (PASSED): The output line starting with ibus-daemon.
    • TEST_KB_INSTALL2 (PASSED): The output line starting with ibus-daemon.

@bharanidharanj
Copy link

  • GROUP_WASTA: Wasta 20.04 with Cinnamon

    • TEST_KB_INSTALL1 (PASSED): The output line starting with ibus-daemon.

    • TEST_KB_INSTALL2 (PASSED): The output line starting with ibus-daemon.

@bharanidharanj
Copy link

  • GROUP_BIONIC: Ubuntu 18.04 Bionic with Gnome Shell and X11

    • TEST_KB_INSTALL1 (PASSED): The output line starting with ibus-daemon.

    • TEST_KB_INSTALL2 (FAILED): The output message starting with ibus-daemon with double lines.

@bharanidharanj
Copy link

  • GROUP_IMPISH_X11: Ubuntu 21.10 Impish with Gnome Shell and X11

    • TEST_KB_INSTALL1 (FAILED): The output message starting with ibus-daemon with double lines.

    • TEST_KB_INSTALL2 (FAILED): The output message starting with ibus-daemon with double lines.

@bharanidharanj
Copy link

  • GROUP_IMPISH_WAYLAND: Ubuntu 21.10 Impish with Gnome Shell and Wayland

    • TEST_KB_INSTALL1 (PASSED): Tested this on Ubuntu on Xorg and the output line starting with ibus-daemon.

    • TEST_KB_INSTALL2 (PASSED): Tested this on Ubuntu on Xorg and the output line starting with ibus-daemon.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Mar 1, 2022
This change adds a 1s sleep after restarting ibus before checking
that it actually runs. Hopefully this will solve the problem. Since
this bug is hard to reproduce, we also log a critical error for the
other code path this could happen.

Fixes #6237.
@ermshiperete ermshiperete changed the base branch from master to beta March 7, 2022 17:22
@@ -130,6 +132,7 @@ def restart_ibus(bus=None):
except Exception as e:
logging.warning("Failed to restart IBus")
logging.warning(e)
time.sleep(1) # 1s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining this delay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@ermshiperete ermshiperete changed the title fix(linux): Don't start ibus-daemon multiple times fix(linux): Don't start ibus-daemon multiple times 🚌 Mar 8, 2022
@ermshiperete
Copy link
Contributor Author

ermshiperete commented Mar 8, 2022

@bharanidharanj Could I ask you to re-run the tests with the new instructions. Thanks!

I added some debug output, so hopefully this will allow me to figure out what's going wrong. In my local testing I'm not able to reproduce the problem after having the additional debug statements in place.

@keymanapp-test-bot retest all

@keymanapp-test-bot keymanapp-test-bot bot added the user-test-required User tests have not been completed label Mar 8, 2022
@ermshiperete ermshiperete marked this pull request as draft March 8, 2022 16:49
@ermshiperete ermshiperete added this to the B15S4 milestone Mar 8, 2022
@ermshiperete ermshiperete marked this pull request as ready for review March 8, 2022 16:52
@bharanidharanj
Copy link

GROUP_BIONIC: Ubuntu 18.04 Bionic with Gnome Shell and X11

  • TEST_KB_INSTALL1 (FAILED): Tested this in Bionic 18.04 Linux OS and this test is failed. Attached km-config.log file for reference.

km-config.log

- output error if more than one ibus-daemon is running
- log Keyman version after starting km-config
@ermshiperete
Copy link
Contributor Author

@bharanidharanj Can you please test again? Don't forget to install the new build (linked in the "User Test Results" comment). Please test on all platforms, starting with Bionic, until you get a failure. Thanks!

@keymanapp-test-bot retest GROUP_BIONIC all

@keymanapp-test-bot keymanapp-test-bot bot added the user-test-required User tests have not been completed label Mar 9, 2022
@bharanidharanj
Copy link

@bharanidharanj Can you please test again? Don't forget to install the new build (linked in the "User Test Results" comment). Please test on all platforms, starting with Bionic, until you get a failure. Thanks!

@keymanapp-test-bot retest GROUP_BIONIC all

@ermshiperete Sure. I will test it and will post my comment.

@bharanidharanj
Copy link

GROUP_BIONIC: Ubuntu 18.04 Bionic with Gnome Shell and X11

  • TEST_KB_INSTALL1 (FAILED): Re-tested this in Bionic and I getting more than 1 outputs in the Terminal. Attached the log file for reference.

km-config.log

  • TEST_KB_INSTALL2 (FAILED): Re-tested this in Bionic and I am getting more than 1 outputs in the Terminal. Attached the log file for reference.

km-config2.log

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Mar 10, 2022
@ermshiperete
Copy link
Contributor Author

@bharanidharanj That doesn't look like it's running the version from this PR. Can you show me the output of km-config --version?

@bharanidharanj
Copy link

@ermshiperete km-config version 16.0.2-alpha

@bharanidharanj
Copy link

bharanidharanj commented Mar 10, 2022

GROUP_IMPISH_X11: Ubuntu 21.10 Impish with Gnome Shell and X11

  • TEST_KB_INSTALL1 (FAILED): Got more than 1 Output lines.
    km-config.log

  • TEST_KB_INSTALL2 (FAILED): Got more than 1 Output lines.
    km-config2.log

GROUP_IMPISH_WAYLAND: Ubuntu 21.10 Impish with Gnome Shell and Wayland

  • TEST_KB_INSTALL1 (PASSED): Tested this in Ubuntu 21.10 and it is working as expected.
  • TEST_KB_INSTALL2 (PASSED): Tested this in Ubuntu 21.10 and it is working as expected.

GROUP_WASTA: Wasta 20.04 with Cinnamon

  • TEST_KB_INSTALL1 (FAILED): Crash after installing Khmer Angkor Keyboard.
  • TEST_KB_INSTALL2 (FAILED): Crash after installing Icelandic Keyboard.

km-config.log

GROUP_FOCAL: Ubuntu 20.04 Focal with Gnome Shell and X11

  • TEST_KB_INSTALL1 (PASSED): Working fine
  • TEST_KB_INSTALL2 (PASSED): Working fine.

@ermshiperete
Copy link
Contributor Author

@ermshiperete km-config version 16.0.2-alpha

@bharanidharanj That should be 15.0.210-beta. Please install the package built for this PR by following the steps in the wiki. Please let me know if the instructions in the wiki are not clear enough. Thanks!

@bharanidharanj
Copy link

@ermshiperete As per our discussion, I have attached the Screenshot as well as the log file for your reference.

km-config.log

Instead of trying to restart ibus by passing True to bus.exit()
we now exit ibus and then let verify_ibus_daemon() start it again.
Also added additional checks to verify that we're not running
multiple ibus-daemons at the start of km-config and before
restarting.
@ermshiperete
Copy link
Contributor Author

@bharanidharanj Please try again. I made some preliminary changes - so you can stop testing after the first failure.

@keymanapp-test-bot retest all

@keymanapp-test-bot keymanapp-test-bot bot added the user-test-required User tests have not been completed label Mar 11, 2022
@MakaraSok
Copy link
Collaborator

Test Results

GROUP_BIONIC: Ubuntu 18.04 Bionic with Gnome Shell and X11

  • TEST_KB_INSTALL1 (FAILED):

I've uninstalled and removed everything related to Keyman using

sudo apt remove keyman ibus-keyman python3-keyman-config libkmnkbp0-0
sudo apt autoremove

and

rm -rf ~/.local/share/keyman/
sudo rm -rf /usr/local/share/keyman/

then after restarting the machine, the instructions at https://github.com/keymanapp/keyman/wiki/How-to-test-artifacts-from-pull-requests-for-Keyman-for-Linux were followed, but the second line of commands show some suspicious errors, see below:

keyman@keyman-VirtualBox:~/Desktop/archive-6/results$ sudo apt update
[sudo] password for keyman: 
Hit:1 http://kh.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://kh.archive.ubuntu.com/ubuntu bionic-updates InRelease             
Hit:3 http://kh.archive.ubuntu.com/ubuntu bionic-backports InRelease           
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease              
Reading package lists... Done
Building dependency tree       
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
keyman@keyman-VirtualBox:~/Desktop/archive-6/results$ sudo dpkg -i \
> {ibus-keyman,libkmnkbp0}*$(lsb_release -s -c)*$(dpkg --print-architecture).deb \
> {keyman,python3-keyman-config}*$(lsb_release -s -c)*all.deb
Selecting previously unselected package ibus-keyman.
(Reading database ... 168797 files and directories currently installed.)
Preparing to unpack ibus-keyman_15.0.212-1~PR-6283+bionic21_amd64.deb ...
Unpacking ibus-keyman (15.0.212-1~PR-6283+bionic21) ...
Selecting previously unselected package libkmnkbp0-0:amd64.
Preparing to unpack libkmnkbp0-0_15.0.212-1~PR-6283+bionic21_amd64.deb ...
Unpacking libkmnkbp0-0:amd64 (15.0.212-1~PR-6283+bionic21) ...
Selecting previously unselected package keyman.
Preparing to unpack keyman_15.0.212-1~PR-6283+bionic21_all.deb ...
Unpacking keyman (15.0.212-1~PR-6283+bionic21) ...
Selecting previously unselected package python3-keyman-config.
Preparing to unpack python3-keyman-config_15.0.212-1~PR-6283+bionic21_all.deb ...
Unpacking python3-keyman-config (15.0.212-1~PR-6283+bionic21) ...
Setting up libkmnkbp0-0:amd64 (15.0.212-1~PR-6283+bionic21) ...
dpkg: dependency problems prevent configuration of python3-keyman-config:
 python3-keyman-config depends on python3-bs4; however:
  Package python3-bs4 is not installed.
 python3-keyman-config depends on python3-sentry-sdk (>= 1.1) | python3-raven; however:
  Package python3-sentry-sdk is not installed.
  Package python3-raven is not installed.
 python3-keyman-config depends on python3-lxml; however:
  Package python3-lxml is not installed.
 python3-keyman-config depends on python3-magic; however:
  Package python3-magic is not installed.
 python3-keyman-config depends on python3-numpy; however:
  Package python3-numpy is not installed.
 python3-keyman-config depends on python3-qrcode; however:
  Package python3-qrcode is not installed.
 python3-keyman-config depends on python3-requests-cache; however:
  Package python3-requests-cache is not installed.

dpkg: error processing package python3-keyman-config (--install):
 dependency problems - leaving unconfigured
Setting up ibus-keyman (15.0.212-1~PR-6283+bionic21) ...
dpkg: dependency problems prevent configuration of keyman:
 keyman depends on python3-keyman-config (= 15.0.212-1~PR-6283+bionic21); however:
  Package python3-keyman-config is not configured yet.

dpkg: error processing package keyman (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.5) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for libglib2.0-0:amd64 (2.56.4-0ubuntu0.18.04.9) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for shared-mime-info (1.9-2) ...
Errors were encountered while processing:
 python3-keyman-config
 keyman

@ermshiperete
Copy link
Contributor Author

@MakaraSok The errors you get in the dpkg step are kind of expected - you get them because dpkg doesn't automatically install all dependencies python3-keyman-config requires, and so that package can't be completely installed yet. However, the next command in the instructions (sudo apt install -f) will fix this.

@keymanapp-test-bot retest GROUP_BIONIC TEST_KB_INSTALL1

@bharanidharanj
Copy link

bharanidharanj commented Mar 15, 2022

GROUP_BIONIC: Ubuntu 18.04 Bionic with Gnome Shell and X11

  • TEST_KB_INSTALL1 (FAILED): Re-tested this in Bionic (Keyman 16.0.2-alpha) and I am getting more than 1 output in the Terminal. Attached the log file for reference. Seems to be an issue.

km-config.log

  • TEST_KB_INSTALL2 (FAILED): Re-tested this in Bionic (Keyman 16.0.2-alpha) and I am getting more than 1 output in the Terminal. Attached the log file for reference.

km-config2.log

@bharanidharanj
Copy link

bharanidharanj commented Mar 15, 2022

GROUP_WASTA: Wasta 20.04 with Cinnamon

  • TEST_KB_INSTALL1 (PASSED): Installed Keyman15.0.212-beta (from PR) and it is working as expected.
  • TEST_KB_INSTALL2 (PASSED): Installed Keyman15.0.212-beta (from PR) and it is working as expected.

@bharanidharanj
Copy link

GROUP_FOCAL: Ubuntu 20.04 Focal with Gnome Shell and X11

  • TEST_KB_INSTALL1 (PASSED): Installed 15.0.212-beta build in Ubuntu Focal Linux and it is working as expected.
  • TEST_KB_INSTALL2 (PASSED): Installed 15.0.212-beta build in Ubuntu Focal Linux and it is working as expected.

@bharanidharanj
Copy link

GROUP_BIONIC: Ubuntu 18.04 Bionic with Gnome Shell and X11

  • TEST_KB_INSTALL1 (PASSED): Installed Keyman 15.0.212-beta and re-tested this in Bionic and it is working as expected.

  • TEST_KB_INSTALL2 (PASSED): Installed Keyman 15.0.212-beta and re-tested this in Bionic and it is working as expected.

@bharanidharanj
Copy link

GROUP_IMPISH_X11: Ubuntu 21.10 Impish with Gnome Shell and X11

  • TEST_KB_INSTALL1 (PASSED): Installed Keyman 15.0.212-beta build (from PR) in Impish(Ubuntu) Linux and it is working as expected.
  • TEST_KB_INSTALL2 (PASSED): Installed Keyman 15.0.212-beta build (from PR) in Impish(Ubuntu) Linux and it is working as expected.

GROUP_IMPISH_WAYLAND: Ubuntu 21.10 Impish with Gnome Shell and Wayland

  • TEST_KB_INSTALL1 (PASSED): Installed Keyman 15.0.212-beta build (from PR) in Impish (Ubuntu on Xorg)Linux and it is working as expected.
  • TEST_KB_INSTALL2 (PASSED): Installed Keyman 15.0.212-beta build (from PR) in Impish (Ubuntu on Xorg) Linux and it is working as expected.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Mar 15, 2022
@ermshiperete ermshiperete merged commit 27c7ed0 into beta Mar 15, 2022
@ermshiperete ermshiperete deleted the fix/linux/6237-ibus branch March 15, 2022 17:55
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 15.0.213-beta

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

Successfully merging this pull request may close these issues.

bug(linux): keyboard installation starts additional ibus-daemon
6 participants