Details

    Description

      It seems that all pictures used as source in qml Image's are stored in internal qml cache, QDeclarativePixmapStore. Its structure mimics QPixmapCache and for example the default size is the same for both (and depends on a system, e.g. very small for QWS). But while QPixmapCache has a static public member setCacheLimit(int), there is no way to influence the size of QDeclarativePixmapStore.

      We have a qws-based system and the defaults seem waaay to small for us (we have plenty of memory and slow internet; we expected that the first time large images are used it would be slow but the next time it should be fast due to caching; indeed in our case the second time around a few images are shown right away, but others are not). It seemed that we would need to increase cash limit of QDeclarativePixmapStore. But there is no public API for this, so this would mean changing the default hardcoded value of cache_limit in qdeclarativepixmapcache.cpp in qt sources.

      Thus the request: add to public API a call which would allow setting cache_limit of QDeclarativePixmapStore, similar to QPixmapCache::setCacheLimit(int).


      I attach an example patch with adds such call to QDeclarativeEngine (thus changing public API, breaking binary compatibility etc.) -> maybe you would find a better place for this (maybe even enabling changing this setting from within qml?), and an example program to test it.

      About qt patch:
      QDeclarativePixmapStore is completely internal, so it cannot even be accessed from QDeclarativeEngine; as a bridge I've added a call in QDeclarativePixmap. Thus:

      • QDeclarativeEngine got one static public function "void setCacheLimit( int n )"
      • it calls QDeclarativePixmap::setCacheLimit(int), which sets cache_limit (abusing a bit the fact that QDeclarativePixmap is implemented in the same file as QDeclarativePixmapStore; but all this in internal anyway and QDeclarativePixmap seems close enough to "its" cache QDeclarativePixmapStore for my taste).

      About test program:

      • it's just a standard qtcreator's qml project with two changes:
        1. qml has a timer which sets source of Image to three different sources in a loop
        2. there is additional call to the new function QDeclarativeEngine::setCacheLimit(int)
      • to see these changes more clearly I also include a diff between standard "empty" qtcreator qml project and the final test program;
      • you should run the test program while looking at console debug: every time a new source is set you will see debug on console, and you can observe how much time it takes before you actually see the image loaded;
      • the first time we loop over the 3 pictures they have to be downloaded from internet and it takes a while (in my case about 2-3 seconds for each picture);
      • now, the second time around - it depends:
      • if you call QDeclarativeEngine::setCacheLimit(1024*1024) (1MB, the standard for QWS) then the cache is too small and also the second time around the images will be again downloaded and you have again a few seconds delay between the moment you see debug in your console and the moment you actually see the new image;
      • if you call QDeclarativeEngine::setCacheLimit(500*1024*1024) (a bit of an overshoot ) then the cache is definitely enough to keep all the images and the second, third and so on time around you will the images in ui almost immediately after the debug message.

      Attachments

        1. qml_cache_size-qt480.diff
          2 kB
        2. qt_patch-qml_cache_size.patch
          3 kB
        3. test_program.diff
          3 kB
        4. test_program.tar.bz2
          12 kB
        For Gerrit Dashboard: QTBUG-19507
        # Subject Branch Project Status CR V

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            wiecko Marek Wieckowski
            Votes:
            14 Vote for this issue
            Watchers:
            12 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change