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

Crash in Vulkan RHI if window is recreated (released its resources on hide) (Qt 5.15)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.13
    • Qt RHI
    • None
    • All

    Description

      We have some custom QML comboboxes that use QML Window for the popovers.

      To conserve GPU memory after they are initialized, we call on them:

       

      // Release SceneGraph when hiding window
      window->setPersistentSceneGraph( false );
      // Release RHI (and GPU memory) if SG being release above too
      window->setPersistentOpenGLContext( false ); 

       

       

      This triggers a crash if window is reopened (recreated). For some reason the crash only occurs if the window width changes on the reopen. The general cause of the crash is:

      1. new frame has been started (primary VkCommand has been created)
      2. frame has been interrupted with a call to releaseSwapChainResources()
      3. the above call destroys the primary VkCommands
      4. but left the inFrame flag untouched
      5. next call to beginFrame() was not recreating the VkCommand as it assumed that it just needs to continue work on the prevously abandoned one
      6. crash due to use of nullptr VkCommand

      My fix:

      @@ -1500,12 +1500,14 @@ void QRhiVulkan::releaseSwapChainResources(QRhiSwapChain *swapChain)
           if (swapChainD->sc == VK_NULL_HANDLE)
               return;
       
           if (!deviceLost)
               df->vkDeviceWaitIdle(dev);
       
      +    inFrame = false;
      +
           for (int i = 0; i < QVK_FRAMES_IN_FLIGHT; ++i) { 

      Attachments

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

        Activity

          People

            lagocs Laszlo Agocs
            dariusz.maciejewski Dariusz Maciejewski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes