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

QML Image not cached when loaded from network

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Closed
    • Priority: P5: Not important
    • Resolution: Out of scope
    • Affects Version/s: 5.7.0
    • Fix Version/s: None
    • Labels:
      None

      Description

      Hi.

      From the http://doc.qt.io/qt-5/qml-qtquick-image.html documentation I'm not sure if this is expected but here it is.

      If you run example attached below you will see that images are fetched as you scroll. Since hidden delegates get destroyed images will once again be fetched from server when we scroll back. Given that there is cache property on Image I would expect that this would mean images are cached on disk. There is also some mention of this in sourceSize property:

      Note: Changing this property dynamically causes the image source to be reloaded, potentially even from the network, if it is not in the disk cache.

      Here is example code:

      import QtQuick 2.6
      import QtQuick.Window 2.2
      
      Window
      {
          visible: true
      
          width: 1024
          height: 512
      
          ListView
          {
              orientation: ListView.Horizontal
              width: parent.width
              height: parent.height / 2
              model:
              [
                  "http://www.eonline.com/eol_images/Entire_Site/2016015/rs_634x937-160115101507-634-martian-parody-poster.jpg",
                  "http://www.shockya.com/news/wp-content/uploads/keanu-movie-poster-oscar-parody-02.jpg",
                  "http://8weekly.nl/wp-content/uploads/2012/9837-the-grey-c.jpg",
                  "http://www.freedesign4.me/wp-content/gallery/posters/free-movie-film-poster-the_dark_knight_movie_poster.jpg",
                  "http://www.theflea.co.nz/wp-content/uploads/2010/02/star-trek-movie-poster.jpg",
                  "http://s3.amazonaws.com/auteurs_production/post_images/19593/Assassin.jpg?1443151342",
                  "http://cdn.collider.com/wp-content/uploads/shutter-island-movie-poster.jpg",
                  "http://www.printmag.com/wp-content/uploads/skyfall_xlg.jpg?950846",
                  "https://videocitylondon.files.wordpress.com/2013/01/looper-poster-11.jpg",
                  "http://img04.deviantart.net/e5ca/i/2013/156/7/e/man_of_steel_movie_poster_by_sumitsjc-d67w4t5.jpg"
              ]
              delegate: Image
              {
                  width: 512
                  height: 512
                  fillMode: Image.Stretch
                  source: modelData
                  cache: true // this is default
              }
          }
      }
      

      I have my own simple caching mechanism for images which works as expected on all platforms tested (osx, linux, ios, android). I have C++ function called from Javascript which is used as a proxy for Image source property. If there is no image locally, it is fetched and saved to disk (QStandardPaths::CacheLocation) first and then source property is always set to local image path.

      We have this in production for a year now but, if possible, I would much rather use existing caching from Image or implement it myself if it sounds interesting.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              w00t Robin Burchell
              Reporter:
              pkoretic Petar Koretic
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes