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

useless file accesses in qt_findAtNxFile() originating from QStyleSheetStyle::loadPixmap()

    XMLWordPrintable

Details

    • b773a4f58 (dev), acff474a2 (6.7), 66db1195f (tqtc/lts-6.5)

    Description

      I have observed hundreds to thousands of syscalls per second to check whether files named "@2x" and "@3x" exist (depending on the screen used). These calls originate from QStyleSheetStyle::loadPixmap() which is called with an empty argument.

      The call to loadPixmap(""), and/or the work done by loadPixmap(""), may be seen as a bug in itself, as the calling code may short-circuit immediately. However, it seems intentional to call it with uri.isEmpty() at https://codereview.qt-project.org/gitweb?p=qt/qtbase.git;a=blob;f=src/widgets/styles/qstylesheetstyle.cpp;h=7602217f24c05331f3bab8c6b9050c5f53d47499;hb=HEAD#l958

      loadPixmap calls qt_findAtNxFile("") to see if a @Nx file exists for "", which should never be the case. qt_findAtNxFile("") could safely return "" immediately, instead of testing file existence with QFile::exists() at https://codereview.qt-project.org/gitweb?p=qt/qtbase.git;a=blob;f=src/gui/image/qicon.cpp;h=086ac37a07ede70506203b17c59fa0d9677a1051;hb=HEAD#l2006

      These calls vanish by setting QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING=1, which is a valid workaround if @Nx is not used anyway.

      I would like to supply a patch, but first I would like to get some feedback on what is seen as the best solution. In my view loadPixmap() doesn't need to be called at all if uri.isEmpty().

      update: The calls ultimately originated in QRenderRule instantiations, that were due to repeated calls to setStyleSheet() in my code, done to continuously update the color of a few QLabels, so the performance impact of the described bug isn't big, if those calls are optimized away.

      Attachments

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

        Activity

          People

            chehrlic Christian Ehrlicher
            maartenvds Maarten van der Schrieck
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes