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

QOpenGLWidget missing events when update is called

    XMLWordPrintable

Details

    • Linux/X11, macOS

    Description

      Subclassing QOpenGLWidget and overriding mouseMoveEvent, looks like I get an average of ~1.8ms between events. Now if I call update inside mouseMoveEvent, the average time between mouse motion events becomes equal to the monitor vsync, ~16.6ms. As I understand it, many events are lost or not passed to the QOpenGLWidget.

      I attached a test code to demonstrate what I mean.

      Now, my vague understanding is that calling update triggers paintGL and swap buffers, and since vsync is enabled, the GUI thread is being put to sleep until the vsync, and during that period, the mouse events are lost? I can reduce the problem by using a timer to call update at a maximum of 60Hz, but that's basically duplicating work that is already being done inside Qt.

      EDIT: In Linux, if I enable debugging, and without update called from mouseMoveEvent, I get many mouse move events in the same sequence:

      events without update()

      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1721
      qt.qpa.input.events: XI2 mouse motion 365,190, time 135969488, source MouseEventNotSynthesized
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1721
      qt.qpa.input.events: XI2 mouse motion 367,190, time 135969489, source MouseEventNotSynthesized
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1721
      qt.qpa.input.events: XI2 mouse motion 369,190, time 135969490, source MouseEventNotSynthesized
      ...
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1721
      qt.qpa.input.events: XI2 mouse motion 437,169, time 135970097, source MouseEventNotSynthesized
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1721
      qt.qpa.input.events: XI2 mouse motion 436,169, time 135970121, source MouseEventNotSynthesized
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1721
      qt.qpa.input.events: XI2 mouse motion 436,169, time 135970148, source MouseEventNotSynthesized
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1721
      qt.qpa.input.events: XI2 mouse motion 435,169, time 135970159, source MouseEventNotSynthesized

      while with update from mouseMoveEvent:

      events with update()

      qt.qpa.backingstore: Composing and flushing QRegion(null) of QWidgetWindow(0x55789516aa70, name="QMainWindowClassWindow") at offset QPoint(0,0) with 3 texture(s) in QPlatformTextureList(0x5578951bda80)
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1657
      qt.qpa.input.events: XI2 mouse motion 335,293, time 135969219, source MouseEventNotSynthesized
      16ms
      qt.qpa.backingstore: Composing and flushing QRegion(null) of QWidgetWindow(0x55789516aa70, name="QMainWindowClassWindow") at offset QPoint(0,0) with 3 texture(s) in QPlatformTextureList(0x5578951bda80)
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1661
      qt.qpa.input.events: XI2 mouse motion 393,309, time 135969237, source MouseEventNotSynthesized
      16ms
      qt.qpa.backingstore: Composing and flushing QRegion(null) of QWidgetWindow(0x55789516aa70, name="QMainWindowClassWindow") at offset QPoint(0,0) with 3 texture(s) in QPlatformTextureList(0x5578951bda80)
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1665
      qt.qpa.input.events: XI2 mouse motion 457,307, time 135969253, source MouseEventNotSynthesized
      16ms
      qt.qpa.backingstore: Composing and flushing QRegion(null) of QWidgetWindow(0x55789516aa70, name="QMainWindowClassWindow") at offset QPoint(0,0) with 3 texture(s) in QPlatformTextureList(0x5578951bda80)
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1669
      qt.qpa.input.events: XI2 mouse motion 521,287, time 135969269, source MouseEventNotSynthesized
      16ms
      qt.qpa.backingstore: Composing and flushing QRegion(null) of QWidgetWindow(0x55789516aa70, name="QMainWindowClassWindow") at offset QPoint(0,0) with 3 texture(s) in QPlatformTextureList(0x5578951bda80)
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1673
      qt.qpa.input.events: XI2 mouse motion 560,255, time 135969286, source MouseEventNotSynthesized
      16ms
      qt.qpa.backingstore: Composing and flushing QRegion(null) of QWidgetWindow(0x55789516aa70, name="QMainWindowClassWindow") at offset QPoint(0,0) with 3 texture(s) in QPlatformTextureList(0x5578951bda80)
      qt.qpa.events: Event | XInput Event(XCB_INPUT_MOTION) | sequence: 1677
      qt.qpa.input.events: XI2 mouse motion 569,232, time 135969304, source MouseEventNotSynthesized

      Attachments

        1. main.cpp
          3 kB
          Nick Tasios
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            grieverheart Nick Tasios
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes