Keyboard won't switch its layout to a newly added second input source unless their order is rearranged

Bug #1890875 reported by Akbarkhon Variskhanov on 2020-08-08
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNOME Shell
Unknown
Unknown
gnome-shell (Ubuntu)
Low
Gunnar Hjalmarsson
Bionic
Low
Marco Trevisan (Treviño)

Bug Description

[Impact]

What should happen:
Adding a second input source (Russian, in my case) should result in being able to switch to it and use it immediately.
What happens now:
It is not recognized until you rearrange its order, or reboot.

[Test Case]

Steps to reproduce this bug:

1. Have English set as primary language.
2. Go to Settings > Region & Language > Input Sources and add Russian.
3. Russian layout is added to Input Sources and the indicator becomes visible in the Top Bar.
4. You can switch between languages with the assigned keyboard shortcut but the text input won't change.

5. Rearrange their order in Input Sources: make Russian primary, English secondary.
6. You can now enter text in Russian.
7. You can now put Russian back to being second in the list (so it does not cause problems at logic screen, opening up new browser window, etc.)

or 5. Reboot or re-login (restarting gnome-shell works as well: killall -3 gnome-shell or Alt+F2 > r > Enter)

Then install gnome-shell from bionic-proposed, reboot, and find that an added input source now is effective instantly without any of the mentioned workarounds.

[Regression Potential]

Minimal. The fix consists of a simple upstream commit which has been in use as from GNOME 3.32.

[Other info]

Screenshots are attached. The bug is easily reproduced as many times as possible.

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: gnome-control-center 1:3.28.2-0ubuntu0.18.04.6
ProcVersionSignature: Ubuntu 4.15.0-112.113-generic 4.15.18
Uname: Linux 4.15.0-112-generic x86_64
ApportVersion: 2.20.9-0ubuntu7.16
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Sat Aug 8 13:39:01 2020
InstallationDate: Installed on 2016-11-03 (1373 days ago)
InstallationMedia: Ubuntu 16.04.1 LTS "Xenial Xerus" - Release amd64 (20160719)
SourcePackage: gnome-control-center
UpgradeStatus: Upgraded to bionic on 2020-07-24 (15 days ago)

Akbarkhon Variskhanov (kbar) wrote :
Akbarkhon Variskhanov (kbar) wrote :

Rebooting also solves this issue and can be considered as a work-around.

summary: - Keyboard won't switch its layout to the newly added second input source
+ Keyboard won't switch its layout to a newly added second input source
unless their order is rearranged
description: updated
description: updated
Gunnar Hjalmarsson (gunnarhj) wrote :

Thanks for your well written bug report!

I can reproduce the problem on 18.04, but not on 20.04 or groovy, so the problem seems to have been fixed in later versions. For that reason, and since the workaround (reboot or relogin) is a natural measure, I set the importance to "Low".

Changed in gnome-control-center (Ubuntu):
importance: Undecided → Low
status: New → Confirmed
Daniel van Vugt (vanvugt) wrote :

^^^
That means the bug is "Fix Released". If the exact fix can be identified then we would be able to provide a fix to 18.04.

Changed in gnome-control-center (Ubuntu):
status: Confirmed → Fix Released
Akbarkhon Variskhanov (kbar) wrote :

I've looked through a lot of various bug trackers and other projects and could not find the exact fix.

It may be an ibus problem.

description: updated
Akbarkhon Variskhanov (kbar) wrote :

I have tried to add an input source through gsettings
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('xkb', 'ru')]"
but it still produced the same result: text input remains at default layout.

Restarting the GNOME Shell fixes the issue and the 'ru' layout gets added in /etc/default/keyboard configuration file: XKBLAYOUT=us,ru

This may explain why rearranging the order of input sources magically fixes the bug: newly added input sources probably need to be put into defaults once to be recognized later.

However, manually editing the keyboard configuration file does nothing.

What probably happens is that gnome-shell recognizes the added input sources but 'forgets' 1) to send the appropriate command to XKB (setxkbmap ru) whenever the switch shortcut is invoked; or 2) to reconfigure the keyboard settings.

Akbarkhon Variskhanov (kbar) wrote :

Maybe the reconfiguration process is delayed as waiting for 20-30 minutes sometimes works, but it's unreliable and I can't seem to reproduce it.

Gunnar Hjalmarsson (gunnarhj) wrote :

On 2020-08-12 13:57, Akbarkhon Variskhanov wrote:
> Restarting the GNOME Shell fixes the issue and the 'ru' layout gets
> added in /etc/default/keyboard configuration file: XKBLAYOUT=us,ru

If your system has one user only, and you add an XKB input source via Settings, /etc/default/keyboard is also updated instantly. It's per design; no need to restart anything.

> This may explain why rearranging the order of input sources
> magically fixes the bug: newly added input sources probably need to
> be put into defaults once to be recognized later.

Nope. When testing on 18.04, I added an additional user, so /etc/default/keyboard did not get updated. It behaved the same way. The input source settings for the user don't need to be synced with /etc/default/keyboard.

I saw that your upstream issue was closed. If you want to help solve the problem on 18.04, I would suggest that you look at upstream commits in gnome-shell and/or gnome-control-center which might be related. After all we know that the issue is not present in focal (GNOME 3.36).

Akbarkhon Variskhanov (kbar) wrote :

bug-exists Ubuntu 18.04.5 LTS bionic
  GNOME Shell 3.28.4 (=3.28.4-0ubuntu18.04.3)
  gnome-control-center 3.28.2 (=1:3.28.2-0ubuntu0.18.04.6)

bug-exists Ubuntu 18.10 cosmic
  GNOME Shell 3.30.1 (=3.30.1-2ubuntu1)
  gnome-control-center 3.30.1 (=1:3.30.1-1ubuntu2)

no-bug Ubuntu 19.04 disco
  GNOME Shell 3.32.0 (=3.32.0+git20190410-1ubuntu1)
  gnome-control-center 3.32.1 (=1:3.32.1-1ubuntu4)

Tested on various versions of Ubuntu running on a virtual machine.

Gunnar Hjalmarsson (gunnarhj) wrote :

I found an older upstream gnome-shell issue which seems to have been fixed through this commit:

https://gitlab.gnome.org/GNOME/gnome-shell/-/commit/b405ed64

May be worth a test.

description: updated
affects: gnome-control-center (Ubuntu) → gnome-shell (Ubuntu)
Changed in gnome-shell (Ubuntu Bionic):
assignee: nobody → Gunnar Hjalmarsson (gunnarhj)
importance: Undecided → Low
status: New → In Progress
Gunnar Hjalmarsson (gunnarhj) wrote :

Thanks for confirming!

On 2020-08-14 15:01, Akbarkhon Variskhanov wrote:
> bug-exists Ubuntu 18.10 cosmic
> GNOME Shell 3.30.1 (=3.30.1-2ubuntu1)
> gnome-control-center 3.30.1 (=1:3.30.1-1ubuntu2)
>
> no-bug Ubuntu 19.04 disco
> GNOME Shell 3.32.0 (=3.32.0+git20190410-1ubuntu1)
> gnome-control-center 3.32.1 (=1:3.32.1-1ubuntu4)

That info was helpful, since it limited the time frame for where to look for a possible upstream fix. And the commit mentioned in comment #11 now has proved to be it. :)

I have uploaded a gnome-shell fix to the bionic SRU queue.

Changed in gnome-shell (Ubuntu Bionic):
assignee: Gunnar Hjalmarsson (gunnarhj) → Marco Trevisan (Treviño) (3v1n0)
Changed in gnome-shell (Ubuntu):
assignee: nobody → Gunnar Hjalmarsson (gunnarhj)

An upload of gnome-shell to bionic-proposed has been rejected from the upload queue for the following reason: "Fix appears incomplete, and no progress in a month. Please see https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/1838152/comments/5 and subsequent discussion.".

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.