Apps don't start and complain about "Invalid MIT-MAGIC-COOKIE-1 keyqt.qpa.xcb"

I have installed few apps from flathub but almost all of them exhibit a problem:

  • They won’t start sometimes.
  • They might if I restart.

Error when I try and run them from a terminal:

> flatpak run com.calibre_ebook.calibre
Invalid MIT-MAGIC-COOKIE-1 keyqt.qpa.xcb: could not connect to display :99.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
> flatpak run md.obsidian.Obsidian
[3 preload-host-spawn-strategy] Running: /app/bin/zypak-helper child - /app/obsidian --type=zygote
2021-09-17 18:15:34 Loading main app package /app/resources/obsidian.asar
Invalid MIT-MAGIC-COOKIE-1 keyThe futex facility returned an unexpected error code.
/app/bin/obsidian.sh: line 19:     3 Aborted                 (core dumped) zypak-wrapper /app/obsidian $@
> flatpak run com.github.johnfactotum.Foliate
Gtk-Message: 23:46:34.484: Failed to load module "canberra-gtk-module"
Invalid MIT-MAGIC-COOKIE-1 keyUnable to init server: Could not connect: Connection refused
Invalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 keyEGLDisplay Initialization failed: EGL_NOT_INITIALIZED
Portal call failed: Failed to start command: Failed to execute child process “dict” (No such file or directory)
Portal call failed: Failed to start command: Failed to execute child process “sdcv” (No such file or directory)
Invalid MIT-MAGIC-COOKIE-1 keyUnable to init server: Could not connect: Connection refused

(com.github.johnfactotum.Foliate:2): Gtk-WARNING **: 23:46:34.613: cannot open display: :99.0

> flatpak run net.ankiweb.Anki
Invalid MIT-MAGIC-COOKIE-1 keyQt warning: could not connect to display :99.0 
Qt info: Could not load the Qt platform plugin "xcb" in "" even though it was found. 
Qt fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Is this a never seen before bug? Where are you denvercoder9?

OS: openSUSE Leap 15.3
DE: XFCE

Temp fix:

rm .Xauthority
sudo shutdown -r now

Issue related to XFCE. With LxQt no such problem is encountered.

thanks for the awesome information.