Skip to content

Crash in Vulkan backend during window resize on Linux #9476

Description

@poweifeng

Discussed in #9475

Originally posted by A-Nnoyed December 2, 2025
I've been getting a 100% repro crash with an up-to-date sync of filament. When using the window resize handles in any of the samples, filament crashes.

I tracked this down to VulkanSwapChain::acquire(bool). During the first acquire after the has_resized() function returns true, the vkswapchain gets recreated and updated, and then mPlatform->acquire is called. That calls vkAcquireNextImageKHR which returns VK_ERROR_OUT_OF_DATE_KHR, and on my system at least, that Vulkan call doesn't write anything to &outImageSyncData->imageIndex. So mCurrentSwapIndex remains at INVALID_IMAGE_INDEX (= UINT_MAX) and mFinishedDrawing[mCurrentSwapIndex] = {}; crashes when attempting to access the array out of bounds.

I have what looks like a fix, at least on my system, so I'm passing it along in case it helps. On the line: if ((resized = mPlatform->hasResized(swapChain))), I just replaced the "if" with a "while". The thinking was that the OS was spamming window resize events so quickly that the new swapchain's surfaces were out of date before the swapchain could even be returned. Repeating the hasResized check until it returned false seems to have ensured the next image is valid when we get out of the loop and I no longer see crashes when resizing windows.

The samples now occasionally exhibit timing issues where the View's Viewport doesn't set up correctly for the final size of the window, but I figure I can work around that at the application level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions