[Interest] QML Loader Performance
Bo Thorsen
bo at vikingsoft.eu
Tue Mar 8 15:36:36 CET 2016
Hi Ingo,
Den 07-03-2016 kl. 08:27 skrev Ingo Schiller:
> I have a serious performance problem in my application which uses QML
> for the UI and several C++ datamodels. The application consists of
> several "pages", which is a set of ui elements and covers the whole
> screen. These pages can be loaded on request. Loading such a page is
> done by a QML Loader component. The loaded page itself loads other
> elements, so called "blocks" which group several ui elements. These
> "blocks" also contain a loader element which loads so called "widgets",
> UI qml elements used to display information. After loading a block or
> widget JS functions are used to set the properties (15 - 30) of the ui
> elements such as position, z-layer, data to display, etc.
>
> Load Page -> load block 1 -> load widget 1
> -> load widget 2
> -> load widget 3
> ...
> -> load widget n
> -> load block 2 -> load widget 1
> -> load widget 2
> -> load widget 3
> ...
> -> load widget n
> ...
> -> load block n -> load widget x
>
> The problem is, that loading sich a "page" is far too slow, On a really
> good developer PC and as a release build it takes 150ms. On a weaker
> hardware it takes several seconds which is not acceptable. The time
> required to load a "page" is linear with the amount of "widgets" on that
> "page", no matter what widgets are on that page. I have very simple
> widgets which have only a label to display, up to grafical widgets with
> transparency and animations, but that does not seam to influence the
> loading procedure.
>
> I already tried several things to speed it up:
> - Use qt quick compiler
> - Strip down loaded elements to have fewer properties
> - Construct all elements on startup and only set them (in-)visible on
> request
> - Omit z-layering
>
> Profiling the loading procedure shows that compiling the qml elements
> and painting are not the issues.
>
> Can anyone advise what I could do else? Or is that loader component so
> terribly slow? Any help is highly appreciated!
What you're doing here seems really difficult to speed up. I guess the
problem is the multiple layers of loaders you have.
But I guess that's a pretty fundamental design for you application, and
not one you're about to change.
If you could create a set of pages based on the blocks that can go in
them, you could have a single loader object instead of the n * m + 1
loaders you're doing right now.
Another option would be to attempt this with C++ instead of doing
loaders. I mean instantiating every item inside in C++ code instead of
doing it in QML/JS code. This makes the code a lot less friendly to
modify, but it seems you are desperate enough to start pulling out
solutions that hurts in other ways just to get more speed.
If you can cut down on the initialization for each page, block or
widget, that would obviously help a lot. You mention that JS code is run
after each add, which sounds like a place where you might have some
possibilities.
Fewer bindings might also be a possibility.
Have you considered a total redesign based on models instead? It sounds
like a page is really just a list of widgets - which is a bad word in
QML land :) - so perhaps you would be much better off with a standard
list model, a list view where what you have as a widget now is a
delegate for a row in the model. That would definitely be much much
faster than what you're doing right now.
Those are just the ideas I have off the top of my head. I hope it helps.
Bo Thorsen,
Director, Viking Software.
--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
More information about the Interest
mailing list