Page MenuHomePhabricator

Delayed interaction due to event-loop bug in Qt5
Closed, ResolvedPublic

Description

Details in:
http://markmail.org/message/l76z3mppijvpy6sn

Only reproducible for some linux distributions

Event Timeline

The issue has been confirmed on ubuntu. I don't know which version yet.

User kolbch has pushed new remote branch:

bug-18799-DisableRenderingInVTKInteractor

I have found a fix which is very consistent to the mitk rendering:
the vtkRenderWindowInteractor triggers the rendering by itself. This happens only in the 3D renderwindow because we are using a standard vtkInteractorStyle for the camera movement.
In this branch bug-18799-DisableRenderingInVTKInteractor I disabled the rendering in the vtkRenderWindowInteractor and added an observer to the vtkCommand::RenderEvent which is now triggering a call to mitk::BaseRenderer::RequestUpdate.
This spares us many unnecessary rendering calls and enables smooth interactions in Qt5

Changing severity: We should really check, if this bug can be integrated into the upcoming release.
From my point of view the proposed change sounds good.
Are there any other comments?

How was/is this fix tested? On which platforms?

On which platforms does this occur? Only Arch Linux? I have no issues with Ubuntu 14.04.

Summary of problem description

Interactions using the mouse-move event in the 3D renderwindow are delayed due to missing event compression in Qt5. This affects only linux with newer versions of Xorg-server. This has been confirmed so far on archlinux and ubuntu 14.10

Actual behavior

Zooming, panning and rotation interactions in the 3D renderwindow are, depending on the scene complexity, severely delayed. Meaning that all mouse events are processed and rendered smoothly but too late.

Expected behavior

A new event, i.e. moving the mouse should have an immediate effect on the rendered scene.

Cause of the bug

The actual cause of this bug lies within the XCB event handling in Qt5 (see https://bugreports.qt.io/browse/QTBUG-40889). The secondary cause, however is VTK trying to invoke and complete the rendering on every single event, even if there are numerous newer events in the event queue. The problem only occurs in the 3D rendering, because only there VTK controls its own rendering invocations. The 2D renderwindows are using the "requestUpdate" mechanism of mitk, which only allows the rendering to be invoked if there isn't already an update pending. This results in an update rate which is adjusted to the rendering time, and only the newest events are processed when the last rendering is finished.

Proposed solution

In this branch bug-18799-DisableRenderingInVTKInteractor I disabled the rendering in the vtkRenderWindowInteractor and added an observer to the vtkCommand::RenderEvent which is now triggering a call to mitk::BaseRenderer::RequestUpdate.
This spares us many unnecessary rendering calls and enables smooth interactions with Qt5.

Affected classes

mitkVtkProprenderer - added RenderingCallback and disabled rendering in vtkRenderWindowInteractors.
mitkDisplayInteractor - Filter events coming from the 3D Renderwindow, since they have their own interactor.

How will the bugfix get tested?

Try zooming, panning and rotation in the 3D renderwindow. Automated tests are not possible.

Sounds like a real improvement, thank you. I think this should be tested really well on all platforms, maybe you could assign some "key testers" that try everything in 3D and look for any unwanted effects.

Was tested on Mac by Andreas and on Windows by me. When testing the application framework the next days we should test this again even more intense.

[28ad18]: Merge branch 'bug-18799-DisableRenderingInVTKInteractor'

Merged commits:

2015-04-09 15:39:35 Christoph Kolb [dfd92a]
Disable rendering in the vtkRenderwindowInteractor and call BaseRenderer::RequestUpdate instead.

[045114]: Merge branch 'bug-18799-DisableRenderingInVTKInteractor'

Merged commits:

2015-04-21 15:18:10 Christoph Kolb [754b17]
COMP: delete vtkCallbackCommand to fix leak