SimulaVR / Simula

Linux VR Desktop
MIT License
2.97k stars 91 forks source link

XWayland transient error #82

Closed georgewsinger closed 5 years ago

georgewsinger commented 5 years ago

The error(s) @NerveCoordinator is receiving. After running make run, an instance of Xwayland spins up:

2019-08-30 11:34:31 - [xwayland/sockets.c:47] Failed to bind socket @/tmp/.X11-unix/X0: Address already in use
2019-08-30 11:34:31 - [xwayland/sockets.c:47] Failed to bind socket @/tmp/.X11-unix/X1: Address already in use
New DISPLAY=:2
OpenVR: initialising OpenVR context
2019-08-30 11:34:31 - [xwayland/xwayland.c:103] WAYLAND_SOCKET=30 Xwayland :2 -rootless -terminate -listen 28 -listen 29 -wm 32

and at this point either xwayland will fail to accept new surfaces:

2019-08-30 11:34:33 - [types/wlr_surface.c:595] New wlr_surface 0x87cd140 (res 0x87cb7d0)
2019-08-30 11:34:33 - [modules/gdwlroots/wlr_surface.cpp:103] Created surface 0x8e58250 for 0x87cd140
2019-08-30 11:34:33 - [xwayland/xwayland.c:352] sent SIGUSR1 to process 22927
2019-08-30 11:34:33 - [xwayland/xwayland.c:236] waitpid for Xwayland fork failed: No child processes

or new surfaces will be interceptable at the cost of the the HMD failing to init:

Unable to init VR runtime: Hmd Not Found (108)
Compositor initialization failed. See log file for details.
OpenVR: releasing OpenVR context
Failed to initialize VR interface.
/home/zephyr/.steam/steam/steamapps/common/SteamVR/bin/linux64/vrmonitor: error while loading shared libraries: libQt5OpenGL.so.5: cannot open shared object file: No such file or directory
cannot open shared object file: No such file or directory

2019-08-31 08:46:38 - [types/wlr_surface.c:595] New wlr_surface 0x7cb14b0 (res 0x796c240)
2019-08-31 08:46:38 - [modules/gdwlroots/wlr_surface.cpp:103] Created surface 0x7c4c930 for 0x7cb14b0
2019-08-31 08:46:38 - [xwayland/xwayland.c:352] sent SIGUSR1 to process 6140
2019-08-31 08:46:38 - [xwayland/xwayland.c:243] Xserver is ready
2019-08-31 08:46:38 - [xwayland/xwm.c:1483] xfixes version: 5.0
2019-08-31 08:46:38 - [xwayland/xwm.c:923] XCB_PROPERTY_NOTIFY (668)
2019-08-31 08:46:38 - [xwayland/xwm.c:923] XCB_PROPERTY_NOTIFY (668)
2019-08-31 08:46:38 - [xwayland/xwm.c:792] XCB_CREATE_NOTIFY (2097153)
2019-08-31 08:46:38 - [xwayland/xwm.c:792] XCB_CREATE_NOTIFY (2097154)
2019-08-31 08:46:38 - [xwayland/xwm.c:923] XCB_PROPERTY_NOTIFY (2097154)
2019-08-31 08:46:38 - [xwayland/xwm.c:792] XCB_CREATE_NOTIFY (2097155)
2019-08-31 08:46:38 - [xwayland/xwm.c:923] XCB_PROPERTY_NOTIFY (668)
2019-08-31 08:46:38 - [xwayland/xwm.c:1249] unhandled X11 event: 34
2019-08-31 08:46:38 - [xwayland/xwm.c:1249] unhandled X11 event: 34

There was also a single time that @NerveCoordinator was able to get both the VR HMD to initialize and XWayland to intercept apps.

@NerveCoordinator's vrcompositor.txt logs.

Specs. This error isn't affecting everyone.

User XWayland Bug Exhibited? Machine Specs
@NerveCoordinator :heavy_check_mark: Ubuntu 19.04; nvidia 430.40; HTC Vive is treated as its own DISPLAY sometimes.
@georgewsinger :x: Ubuntu 19.04; nvidia 418.56; HTC Vive is treated as its own DISPLAY never.
@kanetw :heavy_check_mark: vmware vm
georgewsinger commented 5 years ago

Delaying the Simula compositor from starting until after VR is initialized fails to fix the issue:

-- Simula.hs
ready :: GFunc GodotSimula
ready self _ = do
  -- addSimulaServerNode -- <- Formerly here
  openVR >>= initVR (safeCast self) >>= \case
    InitVRSuccess -> do
      -- ..

    InitVRFailed  -> return ()

  addSimulaServerNode -- <- Now here

  retnil
georgewsinger commented 5 years ago

Commenting out the following in xserver_handle_ready_(..) causes Simula to run (silently ignoring the waitpid error):

//wlroots/xwayland/xwayland.c
static int xserver_handle_ready(int signal_number, void *data) {
  //..
  int stat_val = -1;
  while (waitpid(wlr_xwayland->pid, &stat_val, 0) < 0) {
    if (errno == EINTR) {
      continue;
    }
    wlr_log_errno(WLR_ERROR, "waitpid(%d) for Xwayland fork failed", wlr_xwayland->pid); //← Simula gets caught here
    return 1;
  }
  if (stat_val) {
    wlr_log(WLR_ERROR, "Xwayland startup failed, not setting up xwm");
    return 1;
  }
  //..
}

For some reason this was already commented out in my stripped down version of wlroots, and that's why I wasn't duplicating this error. This is far from the most elegant solution but it works and allows us to move on. So: