Xmir disconnects and reconnects to Mir when the X client count reaches zero

Bug #1481330 reported by Christopher Townsend
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical Pocket Desktop
New
High
kevin gunn
xorg-server (Ubuntu)
Won't Fix
Low
Unassigned

Bug Description

Xmir reconnects to Mir when the final client drops its connection to Xmir, either through XCloseDisplay, or by normal program termination. This affects xprop and GTK applications (they temporarily open a connection to the X server to obtain the value of the AT_SPI_BUS property on the root window).

This is what is printed in application's upstart log:

(EE)
Fatal server error:
(EE) Failed to connect to Mir: Failed to process connect response: /build/mir-3eDTxk/mir-0.14.0+15.10.20150723.1/src/client/probing_client_platform_factory.cpp(37): Throw in function virtual std::shared_ptr<mir::client::ClientPlatform> mir::client::ProbingClientPlatformFactory::create_client_platform(mir::client::ClientContext*)
Dynamic exception type: N5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE
std::exception::what: No appropriate client platform module found

(EE)

Tags: xmir
Revision history for this message
Christopher Townsend (townsend) wrote :

I'm also adding Mir to this since the error kind of implicates it.

tags: added: xmir
Revision history for this message
William Hua (attente) wrote :

GTK apps are breaking this because at-spi2-core is calling XCloseDisplay, not because of XGetWindowProperty.

I tried commenting (https://git.gnome.org/browse/at-spi2-core/tree/atspi/atspi-misc.c#n1456, XGetWindowProperty call) and this bug still occurred. Then I tried commenting (https://git.gnome.org/browse/at-spi2-core/tree/atspi/atspi-misc.c#n1462, XCloseDisplay call) and it allows GTK apps to run without crashing XMir.

Aside, to run GTK apps under XMir, pass the display name as a command line argument (--display :1) instead of setting DISPLAY/AT_SPI_DISPLAY.

Revision history for this message
Christopher Townsend (townsend) wrote : Re: Reading/setting xprop on Xmir window causes it to close

I also ran xprop in gdb to see what may be causing the Xmir window to clsoe and just the simple exit(0) at the end of xprop.c causes it to close.

Based on the call to XCloseDisplay() and xprop exiting causing Xmir to close, I'm wondering if Xmir is being too aggressive on cleaning up when the application is done with DISPLAY???? Need some expert advice here:)

summary: - Reading/setting xprop on Xmir causes it to crash
+ Reading/setting xprop on Xmir window causes it to close
William Hua (attente)
summary: - Reading/setting xprop on Xmir window causes it to close
+ Xmir crashes when client closes display
Revision history for this message
William Hua (attente) wrote : Re: Xmir crashes when client closes display
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mir (Ubuntu):
status: New → Confirmed
Changed in xorg-server (Ubuntu):
status: New → Confirmed
Revision history for this message
Christopher Townsend (townsend) wrote :

I'm not sure if Xmir crashes. I ran xprop w/ gdb and it just seems Xmir exits when the client closes the display. I also don't get any crash file nor any evidence of a core dump.

kevin gunn (kgunn72)
Changed in xorg-server (Ubuntu):
assignee: nobody → Robert Ancell (robert-ancell)
importance: Undecided → Critical
Revision history for this message
William Hua (attente) wrote :

Ok, it might not be a crash per se, but it's definitely still printing fatal server error in the logs.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

What version of XMir? I'm not getting any crashing here.

Revision history for this message
William Hua (attente) wrote :

This was with version 2:1.17.2-1ubuntu3. It might not be an actual crash, but Xmir is terminating with that exception in the logs.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

That error looks like one of the cryptic messages you'll get if you haven't installed drivers for Mir yet. They're not automatically installed unless you have a phone image, or have installed the full desktop-next stack. Reasons....

Try this:
   sudo apt-get install mir-graphics-drivers-desktop
or
   sudo apt-get install mir-graphics-drivers-android

Revision history for this message
William Hua (attente) wrote :

I have version 0.14.0+15.10.20150723.1-0ubuntu1 of mir-graphics-drivers-desktop installed.

Revision history for this message
Christopher Townsend (townsend) wrote :

Most definitely not the lack of the graphics drivers as I have those installed on my machine and have a working Unity 8 desktop session.

Another data point is that this doesn't occur when running against mir_demo_server, but only when running in a Unity 8 desktop session. I start an Xmir instance using a desktop file like the following:

$cat ~/.local/share/applications/xmir-debug.desktop
[Desktop Entry]
Version=1.0
Name=XMir Debug
Exec=Xmir :1
Type=Application
StartupNotify=true
X-Ubuntu-Touch=true

Then from an ssh session, I do something like:
$ DISPLAY=:1 xprop -root

I get the following output:
_XKB_RULES_NAMES(STRING) = "evdev", "pc105", "us", "", ""

But after the command is finished, the Xmir window goes away and the error message I put in the description is printed in ~/.cache/upstart/application-legacy-xmir-debug-blah.log.

The test program that William attached to this bug also produces the same behavior while in a Unity 8 desktop session.

I hope this helps. Also, considering it doesn't occur when running with mir_demo_server, it's probably not a Mir/Xmir issue, but I'm really not sure whose problem it is, but it needs fixing:)

Changed in xorg-server (Ubuntu):
importance: Critical → Medium
status: Confirmed → Triaged
Revision history for this message
Robert Ancell (robert-ancell) wrote :

The trigger is the X server resetting - this occurs when the last X client disconnects. This causes the root window to be destroyed and re-created. Thus the Mir surface is destroyed and then (attempted to be) recreated.

This occurs when running XMir inside a Unity 8 session, other cases that were tested were:
 - Running XMir inside mir_demo_server (works fine)
 - Running Unity 8 directly inside mir_demo_server (works fine)

In the normal use case the X server doesn't reset until you have completed using it - the window manager is constantly connected so the reset does not occur. For this reason this bug is not critical but worth investigating when we have the time.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I wonder if this is another case of Mir choosing the wrong version of the right driver (bug 1488500). Can you please list all mir debs you have installed?

Changed in mir:
status: New → Incomplete
Changed in mir (Ubuntu):
status: Confirmed → Incomplete
Changed in mir:
importance: Undecided → Medium
Changed in mir (Ubuntu):
importance: Undecided → Medium
Revision history for this message
William Hua (attente) wrote :

These are the packages that I can replicate the bug with:

libmirprotobuf1:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
libmirserver33:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
libmirplatform9:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
libmircommon-dev:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
libmirplatform-dev:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
libmirserver-dev:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
mirtest-dev:
  Installed: (none)
--
libmirclient9:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
libmirclient-dev:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
libmirclient-debug-extension1:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
libmirclient-debug-extension-dev:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
mir-demos:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
mir-utils:
  Installed: (none)
--
mir-doc:
  Installed: (none)
--
mir-test-tools:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
libmircommon5:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
mir-platform-graphics-mesa-x4:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
mir-platform-graphics-mesa-kms4:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
mir-platform-graphics-android4:
  Installed: (none)
--
mir-client-platform-mesa3:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
mir-client-platform-mesa-dev:
  Installed: (none)
--
mir-client-platform-android3:
  Installed: (none)
--
mir-graphics-drivers-desktop:
  Installed: 0.15.0+15.10.20150818-0ubuntu1
--
mir-graphics-drivers-android:
  Installed: (none)
--
python3-mir-perf-framework:
  Installed: (none)

Revision history for this message
William Hua (attente) wrote :

The bug still happens with the packages in Wily proposed:

libmirprotobuf1:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
libmirserver33:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
libmirplatform9:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
libmircommon-dev:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
libmirplatform-dev:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
libmirserver-dev:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
mirtest-dev:
  Installed: (none)
--
libmirclient9:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
libmirclient-dev:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
libmirclient-debug-extension1:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
libmirclient-debug-extension-dev:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
mir-demos:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
mir-utils:
  Installed: (none)
--
mir-doc:
  Installed: (none)
--
mir-test-tools:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
libmircommon5:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
mir-platform-graphics-mesa-x4:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
mir-platform-graphics-mesa-kms4:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
mir-platform-graphics-android4:
  Installed: (none)
--
mir-client-platform-mesa3:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
mir-client-platform-mesa-dev:
  Installed: (none)
--
mir-client-platform-android3:
  Installed: (none)
--
mir-graphics-drivers-desktop:
  Installed: 0.15.1+15.10.20150825-0ubuntu1
--
mir-graphics-drivers-android:
  Installed: (none)
--
python3-mir-perf-framework:
  Installed: (none)

Changed in mir:
status: Incomplete → Confirmed
Changed in mir (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

For me I found much improved stability on client disconnection after this fix:

https://git.launchpad.net/~xmir-team/xorg-server/+git/xmir/commit/?id=9287786b58a90cf376c05692fe4d6d0712946337

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Xmir (through no choice of its own) is told to destroy all resources (destroy xmir_screen) when the last client disconnects. We could make Xmir leak its resources (including the connection to the Mir server)... that would also solve some annoying flickering but I'm not sure it's the right answer.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

BTW, I've been hacking Xmir for a week and a half and cannot reproduce this bug yet. Although I have been using Mir 0.15 (wily) the whole time too. So Incomplete.

Changed in mir:
status: Confirmed → Incomplete
Changed in mir (Ubuntu):
status: Confirmed → Incomplete
Changed in xorg-server (Ubuntu):
status: Triaged → Incomplete
Revision history for this message
Christopher Townsend (townsend) wrote : Re: Xmir closes when client closes display

I still see this issue when launching gedit from a Unity 8 desktop session.

I'm not really sure what the correct solution is, but as a workaround, I can open the X display in the libertine-launch program before launching any other application and then close it after the application exits. This will at least hold a resource open and not kill the Xmir window.

summary: - Xmir crashes when client closes display
+ Xmir closes when client closes display
kevin gunn (kgunn72)
Changed in canonical-pocket-desktop:
assignee: nobody → kevin gunn (kgunn72)
Revision history for this message
Robert Ancell (robert-ancell) wrote :

I think holding a connection from libertine-launch to XMir is a good idea - this is what LightDM does anyway for the X servers it spawns.

Changed in xorg-server (Ubuntu):
importance: Medium → High
Changed in mir:
status: Incomplete → Invalid
Changed in mir (Ubuntu):
status: Incomplete → Invalid
kevin gunn (kgunn72)
Changed in canonical-pocket-desktop:
importance: Undecided → High
no longer affects: mir
no longer affects: mir (Ubuntu)
Changed in xorg-server (Ubuntu):
assignee: Robert Ancell (robert-ancell) → nobody
description: updated
summary: - Xmir closes when client closes display
+ Xmir disconnects and reconnects to Mir when the X client count reaches
+ zero
Changed in xorg-server (Ubuntu):
importance: High → Medium
status: Incomplete → Triaged
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Reworded and confirmed.

Although if there ever were any crashes related to this bounce, they have probably been fixed now.

The only remaining annoying part about this bug I can see is if you use non-rootless mode; resize the root window and then lose your last X client. The Mir connection+window gets recreated fullscreen again, instead of the size you made it.

That all said, just keeping non-zero X clients running is a sufficient workaround. The bug is not a problem at all in -rootless mode because you never see the root window when it does go away and return. For non-rootless if you're running a desktop (e.g. nautilus) and/or any window manager, any of those are enough to keep the connection alive. So I don't see any major problem here that anyone will see in reality.

Changed in xorg-server (Ubuntu):
importance: Medium → Low
Changed in xorg-server (Ubuntu):
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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