Forum > QT

Weird Qt5 lags when creating windows

(1/3) > >>

Obi:
Hello! There is the following system:

Gentoo Linux with all the latest stable branch updates
Kernel 5.15.19 LTS
X.org Server 21.1.3
GeForce 660 / NVIDIA drivers 470.103.01
Qt 5.15.2
Lazarus 2.2.0
Free Pascal 3.2.2
Xfwm 4.16.1

The problem is the following. I compiled Double Commander from git repository. When compiling, I set lcl=qt5 in ENV variables.

Creating any windows is visually very slow. First, the window frame is drawn (using Xfwm), then, after about ≈500 ms, the window is filled with content. I recorded a video, you can watch it below.

https://imgur.com/mipUIOm

Surprisingly, when built with lcl=qt4, window rendering is much, much faster.

This problem has been reproduced for me for quite a long time, for two or three years, since of Lazarus 1.8.x. The entire graphics stack has since been updated many times, but the problem remains.

I also noticed that lags are practically absent in an empty project, perhaps the size of the created executable file somehow affects this. I made a simple application:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);begin  with TForm2.Create(Self) do    try      ShowModal;    finally      Free;    end;end;
The result is on video: https://imgur.com/zDy5LLL

All in all, it's quite a hindrance to using applications because, often, I press a sequence of buttons faster than the windows open. And until the window is created, it does not accept keyboard input. A classic example is deletion with confirmation. I press Delete and immediately Enter, but only pressing Delete works, and Enter has to be pressed again - after waiting for a window with a request to confirm the deletion to be drawn.

https://imgur.com/mcnibuD

The question, of course, is what could be the problem? Is it possible to fix it somehow? I am now forced to compile applications with lcl=qt4, but Qt4 is already removed from Gentoo, I have to use various tricks to keep it working on my system.

zeljko:
It's pretty strange since Qt5 is much faster than Qt4 here, in any aspect :)
Try to build lclqt5 with -dQtUseNativeEventLoop or
try to start your application with -disableaccurateframe cmd line param.
Also, please test with ./yourapplication -style windows just to check if current style is doing something weird.
I don't know what else could produce such slowness, maybe strace ./yourapp can show something ...

Obi:

--- Quote from: zeljko on February 10, 2022, 09:08:24 am ---It's pretty strange since Qt5 is much faster than Qt4 here, in any aspect :)
Try to build lclqt5 with -dQtUseNativeEventLoop or
try to start your application with -disableaccurateframe cmd line param.
Also, please test with ./yourapplication -style windows just to check if current style is doing something weird.

--- End quote ---

I have tried all 3 methods listed. Lag, unfortunately, did not stop.


--- Quote from: zeljko on February 10, 2022, 09:08:24 am ---I don't know what else could produce such slowness, maybe strace ./yourapp can show something ...

--- End quote ---

I am attaching the log from strace. At the very beginning, there are monotonous entries "poll ... (Timeout)" - at this moment I keep the mouse button pressed over the button from this video: https://imgur.com/mipUIOm

Immediately after I release the mouse button, next in the log are records of creating a new window.

https://pastebin.com/wkDcWvGC

zeljko:
Really don't know, it's something about glib loop IMO

Obi:

--- Quote from: zeljko on February 10, 2022, 02:34:42 pm ---Really don't know, it's something about glib loop IMO

--- End quote ---

At the same time, I should also say that applications that use Qt5, but are written in other languages, such as C++, do not have such problems with window rendering performance. All my suspicions come down to libqt5pas. Even when compiling with lсl=gtk2 has no such problems.

Is there any way to profile this library? Maybe somewhere to insert a code that detects the rendering time in milliseconds?

Navigation

[0] Message Index

[#] Next page

Go to full version