Public bug reported:

Summary

Since upgrading from 0.57-2 (noble) to 0.62, /etc/profile.d/im-config_wayland.sh
runs in every login shell. It now unconditionally sources
/usr/share/im-config/initializer, which takes about 0.4 s of wall time per
shell and writes three "debug" lines to the journal each time, even though
debug logging isn't enabled. Terminal emulators that start login shells
(kitty, for example) become noticeably slow to open.

The hook no longer sets any variables, because the code that used to set them
is commented out since 0.59. So this cost buys nothing.

Steps to reproduce

1. Install im-config 0.62. /etc/default/im-config is unchanged.
2. time bash -c '. /etc/profile.d/im-config_wayland.sh'
3. journalctl -t im-config -f, then open a terminal or run bash -l.

Expected

The hook takes a few milliseconds and logs nothing unless IM_CONFIG_VERBOSE is
set.

Actual

- Step 2 takes 0.39 s wall time (0.14 s user, 0.37 s sys) on a modern laptop.
- Every login shell logs these lines:
    @ IM_CONFIG_ENTRY='profile' XDG_SESSION_TYPE ='wayland' UID=1000 PID=... 
PPID=...
      GTK_IM_MODULE='ibus' QT_IM_MODULE='ibus' CLUTTER_IM_MODULE='' ...
      Set IM_CONFIG_CURRENT_DESKTOP <- '...'

Analysis (/usr/share/im-config/initializer)

1. logger_debug checks `[ -n "$IM_CONFIG_VERBOSE" ]`, but lines 66-67 set the
   fallback IM_CONFIG_VERBOSE="false". "false" isn't empty, so debug logging
   is always on, and each message starts /usr/bin/systemd-cat (about 25 ms
   each).
2. set_val runs `grep ... | head -1` twice for each of six keys: once in the
   eval, and once inside the logger_debug argument. The second one runs even
   when debug logging is off, because the shell expands the argument before
   logger_debug decides whether to use it. That makes 24 extra processes per
   shell.
3. The `$(id -u)` in the first logger_debug line starts another process.

Suggested fix

- Test the value of IM_CONFIG_VERBOSE in logger_debug (for example,
  `[ "$IM_CONFIG_VERBOSE" = true ]`), or leave the fallback empty.
- Read /etc/default/im-config once, for example by sourcing a filtered copy
  or using a single sed/awk pass, instead of running grep|head for each key.
- Don't source the initializer from im-config_wayland.sh at all while the
  Wayland code paths are disabled.
- (Minor typo: the "Common logging functions" comment has a stray backtick.)

Workaround

Comment out the `. /usr/share/im-config/initializer` line in
/etc/profile.d/im-config_wayland.sh. That file is a conffile, so dpkg keeps
the change on upgrade.

ProblemType: Bug
DistroRelease: Ubuntu 26.04
Package: im-config 0.62
ProcVersionSignature: Ubuntu 7.0.0-42.42-generic 7.0.14
Uname: Linux 7.0.0-42-generic x86_64
ApportVersion: 2.34.1-0ubuntu0.1
Architecture: amd64
CasperMD5CheckResult: pass
Date: Fri Nov  6 14:58:20 2026
InstallationDate: Installed on 2023-12-02 (1070 days ago)
InstallationMedia: Ubuntu 22.04 LTS "Jammy Jellyfish" - Release amd64 (20220419)
PackageArchitecture: all
SourcePackage: im-config
UpgradeStatus: Upgraded to resolute on 2026-11-03 (3 days ago)
mtime.conffile..etc.profile.d.im-config_wayland.sh: 2026-11-06T14:57:23.951520

** Affects: im-config (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug resolute wayland-session

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2173544

Title:
  im-config 0.62: profile.d hook adds ~0.4 s to every login shell and
  always logs debug messages

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/im-config/+bug/2173544/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to