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

100% CPU caused by NSFontSetChangedNotification subscription in QCoreTextFontDatabase

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4.3, 6.5.0
    • QPA
    • None
    • macOS 10.14
    • macOS

    Description

      In commit d84018616a24fa66502cf62f5ebbcf5ed4ca0742 a change was added to subscribe to NSFontSetChangedNotification. When this notification is triggered, it happens many times (62 times for me in the attached test case), and creates a situation where Qt causes high CPU load due to repeated invalidation of its font cache, which then causes repeated invalidation of all layouts, etc.. This notification is known as needing debounce, and Qt does not appear to be doing that.

      It is also possible this is not the correct notification to use at all. Blink, Firefox, React Native, Swift, etc. all appear to use kCTFontManagerRegisteredFontsChangedNotification which is documented by Apple as “This notification is posted when fonts are added to the font registry”, versus NSFontSetChangedNotification which is documented as “Posted after the currently-set font changes.”

      I have attached a test case that should reproduce the issue, but I also have a font manager installed so it is possible that the font manager is responsible for causing the extra notifications by automatically activating more fonts during fallback resolution. I also only encountered this bug when the application was built as a macOS bundle with an Info.plist containing a CFBundleIdentifier key (even if the value is empty), which was confusing.

      Attachments

        For Gerrit Dashboard: QTBUG-113394
        # Subject Branch Project Status CR V

        Activity

          People

            vestbo Tor Arne Vestbø
            csnover C S
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change