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

QtQuick not rendering into correct frame on layer-backed view when resizing window

    XMLWordPrintable

Details

    • macOS
    • d8c210d7f576fc54b41ad06c061ece7cadeed648 (qt/qtbase/5.12)

    Description

      I found a lot of tickets that visually seem to have the same issue as me, but under different configurations. Is this a regression or has this never been fixed? 

      Basically, when resizing the window, the QtQuick content's resizing does not sync with the window's frame. 

      On my macOS this happens when the view is layer-backed. I uploaded a toy project. You can play with it. 

      To reproduce, you need to use multi-threaded renderloop, have the QNSView set to layer-backed, and have some sort of QuickItem that keeps the render loop busy rendering, while resizing the window (for example, a scrollview)

      From some other tickets I read that there was a plan to switch to layer-backed views by default before 5.12. Are you guys still working on that?

      I have looked into qpa source code and attempted to fix the issue myself. Not much success so far. What might be the problem?

        

      System:  macOS 10.13.5

      Macbook Air (mid 2011)  non-retina display.

       

      Update: after more probs I found the problem disappears by using single-threaded qsg renderloop. (Doing so make the view flickers when resizing because drawRect is called when resizing when layer-backed view is used. set NSView.layerContentsRedrawPolicy = NSViewLayerContentsRedrawNever to solve this.)

      It seems that the threaded render loop has issues with getting the correct frame to render into when the window is being resized.

       

      int main(int argc, char *argv[])
      {
      //    QLoggingCategory::setFilterRules(QStringLiteral("qt.qpa.cocoa.*=true\n qt.qpa.cocoa.drawing=false"));
      //    QLoggingCategory::setFilterRules(QStringLiteral("*=true"));
          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
          // Using QSGRendererInterface::Software does not have the issue
          // but on my macOS it loses the FastBlur so it's not viable for me
          QQuickWindow::setSceneGraphBackend(QSGRendererInterface::OpenGL);
      
          QGuiApplication app(argc, argv);
      
          QQmlApplicationEngine engine;
          engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
          if (engine.rootObjects().isEmpty()) {
              return -1;
          }
      
          QWindow* view = QGuiApplication::allWindows()[0];
          NSView* nsview = reinterpret_cast<NSView*>(view->winId());
      
          nsview.wantsLayer = NO; // Try disabling layer-backed
          // Observe that when layer-backed is enabled,
          // the picture moves way faster than when it's not,
          // however, resizing the window seems to have some syncing issue
          nsview.layer.borderWidth = 1;
          return app.exec();
      }
      

      Attachments

        1. nsview.zip
          18 kB
          ylilarry

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes