Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-66075

Wayland event dispatcher multi-threading support

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.10.0
    • Fix Version/s: None
    • Component/s: QPA: Wayland
    • Labels:
      None
    • Environment:
      AGL 5.0(EE) on R-Car M3

      Description

      Qt apps on AGL platform freeze when they are running in background and their visibility in IVI-Shell is set to false. They can not receive any notification from D-Bus or WebSockets until visibility is set to true.

      How to reproduce?

      1. Build AGL platform for R-Car M3 Starter Kit
        1. Introduction: Building target AGL image with Yocto project
        2. AGL Kickstart on Renesas R-Car Starter Kit Gen3 V2.23 (h3ulcb, m3ulcb)
      2. Build the example app attached
      3. Install the app
      4. Run the app
      5. Run another app to hide the app
      6. check journal log to see if the timer in the app is running or not 

      How Qt reads wayland events today?

      // http://code.qt.io/cgit/qt/qtwayland.git/tree/src/client/qwaylanddisplay.cpp#n184
      void QWaylandDisplay::flushRequests()
      {
          if (wl_display_prepare_read(mDisplay) == 0) {
              wl_display_read_events(mDisplay);    // <- this doesn't return
          }
      
          if (wl_display_dispatch_pending(mDisplay) < 0) {
              checkError();
              exitWithError();
          }
      
          wl_display_flush(mDisplay);
      }

      wl_display_read_events sometimes doesn't return because someone in the same process is doing something with wayland in other thread(i.e. drawing contents in rendering thread with EGL whose driver also does something with wayland).

      How it should be?

      wl_display_prepare_read_queue - Prepare to read events from the display's file descriptor to a queue. says that to be thread safe, the code will be something like this.

      while (wl_display_prepare_read_queue(display, queue) != 0)
          wl_display_dispatch_queue_pending(display, queue);
      wl_display_flush(display);
      ret = poll(fds, nfds, -1);
      if (has_error(ret))
          wl_display_cancel_read(display);
      else
          wl_display_read_events(display);
      wl_display_dispatch_queue_pending(display, queue);

      IIRC, current QPA architecture doesn't allow to run code right before poll(2), so some trick may be needed.

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              • Assignee:
                johanhelsing Johan Helsing
                Reporter:
                tasuku.suzuki Tasuku Suzuki
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes