Why is there a delay when typing certain characters with xdotool in 18.04?

Using xdotool type or xdotool key to type certain characters makes Gnome Shell lock up while the text is being typed. For example typing a single slash with xdotool type / or xdotool key slash takes a second or two, but for 23 slashes it’s more than 20 seconds.

Of all the printable ASCII characters, only these cause the problem:

  • slash /
  • backslash \
  • bracketleft [
  • bracketright ]
  • braceleft {
  • braceright }

Why does this happen and how can I fix it?

More details

I never had this problem in Unity on 14.04.

There is a small delay when typing other characters – maybe a second, even for long strings.

Any timing I’ve done in the terminal has come back normal, like time xdotool type ... or t=$ SECONDS; xdotool ...; echo $ ((SECONDS-t)), so it seems to be a problem on Gnome Shell’s side.

I’ve confirmed $ XDG_SESSION_TYPE is x11.