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

QQuickView window creation hangs UI thread for 200-500ms due to loading fallback font families

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.11.1
    • GUI: Font handling
    • None
    • Windows

    Description

      On trying different perf optimizations (Loader, removing some nodes in QML tree), noticed that there's always a flat 200-300 ms spent before rendering any QML (profile with QtCreator QML Profiler)

      Profiled again using Windows Tools XPerf and noticed that upon creating the first element in a window that's based on QQuickText a lot of time is spent on the UI thread in QWindowsFontDatabase loading the fallback font families (see attached screenshot of stack and weights)

      Narrowed it down to the fact that qt_getCanonicalFontNames has to GetDC/ GetFontData/ReleaseDC for each font, which summed up over multiple fonts make for a very expensive set of calls. Especially GetFontData, which opens the TTF font tables.

      I don't know why the familyName information in the EnumFontFamiliesExProc params isn't enough and why each font's name has to be re-queried using GetFontData. At the very least, calling GetDC / ReleaseDC every time could be avoided.

      There should also be

      1. Some env var by which I can opt out of loading fallback families
      2. Some way to pre-load the QWindowsFontDatabase at application start-up so it doesn't freeze the UI thread when the user tries to open a new window
      3. This does not respect the async QML Loader behavior - it runs on the UI thread regardless of that flag, so using a Loader doesn't workaround the behavior

      Attachments

        Issue Links

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

          Activity

            People

              lagocs Laszlo Agocs
              cosminp Cosmin Pancratov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes