Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash introduced in commit bc65135 (vk: refactor resource ref-counting) #8288

Open
emezeske opened this issue Dec 2, 2024 · 3 comments · May be fixed by #8368
Open

Crash introduced in commit bc65135 (vk: refactor resource ref-counting) #8288

emezeske opened this issue Dec 2, 2024 · 3 comments · May be fixed by #8368
Assignees
Labels
vulkan Issues with the Vulkan backend

Comments

@emezeske
Copy link
Contributor

emezeske commented Dec 2, 2024

Describe the bug
Commit bc65135 introduced a crash (Filament panic) when destroying and re-creating a swap chain using the Vulkan backend. I noticed the crash after pulling in recent Filament changes, and then bisected it to this commit. For me it is deterministically reproducible. The commit before this does not ever crash.

I ran it in a debugger; I'm not sure what info you might need but the line it crashes on is:

L249: VkResult result = vkCreateSwapchainKHR(mDevice, &createInfo, VKALLOC, &mSwapchain);

The error is:

Exception has occurred: CPP/_com_error
Exception thrown at 0x00007FFCD5EFFA4C in Anukari.exe: Microsoft C++ exception: _com_error at memory location 0x000000F63378EC70.

I tried to figure out what 0x000000F63378EC70 was supposed to be pointing to, but it wasn't obvious to me.

The error in the panic message is VK_ERROR_NATIVE_WINDOW_IN_USE_KHR, which makes me think that destroy() on the swap chain is not fully destroying it?

To Reproduce
Steps to reproduce the behavior:

  1. Use the Vulkan backend
  2. Create a swap chain
  3. Destroy the swap chain
  4. Create a new swap chain
  5. Crash

Expected behavior
No crash.

Screenshots
N/A

Logs

[Filament I]: vkCreateSwapchain: 1852x1297, 44, 0, swapchain-size=3, identity-transform=true, depth=126, protected=false
[Filament E]: Postcondition in create:250 reason: vkCreateSwapchainKHR error: -1000000001
[Filament E]:
*** SIGABRT received at time=1733166246 ***
    @   00007FF7658BDEAC  (unknown)  abort
    @   00007FF7658E3FC5  (unknown)  terminate
    @   00007FF76587FB4A  (unknown)  FindHandler<__FrameHandler4>
    @   00007FF765880BAC  (unknown)  __InternalCxxFrameHandler<__FrameHandler4>
    @   00007FF765880CB9  (unknown)  __InternalCxxFrameHandlerWrapper<__FrameHandler4>
    @   00007FF7658717C9  (unknown)  __CxxFrameHandler4
    @   00007FFCD8AD527F  (unknown)  _chkstk
    @   00007FFCD8A4E886  (unknown)  RtlFindCharInUnicodeString
    @   00007FFCD8A84955  (unknown)  RtlRaiseException
    @   00007FFCD5EFFA4C  (unknown)  RaiseException
    @   00007FF76587036B  (unknown)  _CxxThrowException
    @   00007FF760EB72EA  (unknown)  anukari::`anonymous namespace'::HandleFilamentPanic
    @   00007FF761B79923  (unknown)  utils::UserPanicHandler::call
    @   00007FF761B79FD1  (unknown)  utils::TPanic<utils::PostconditionPanic>::panic
    @   00007FF761B79F10  (unknown)  utils::TPanic<utils::PostconditionPanic>::panic
    @   00007FF7619ADA98  (unknown)  filament::backend::VulkanPlatformSurfaceSwapChain::create
    @   00007FF7619ABB41  (unknown)  filament::backend::VulkanPlatformSurfaceSwapChain::VulkanPlatformSurfaceSwapChain
    @   00007FF76197149E  (unknown)  filament::backend::VulkanPlatform::createSwapChain
    @   00007FF761A444E7  (unknown)  filament::backend::VulkanSwapChain::VulkanSwapChain
    @   00007FF7619C9BDA  (unknown)  filament::backend::VulkanDriver::createSwapChainR
    @   00007FF76195AF4D  (unknown)  std::_Func_impl_no_alloc<`filament::backend::CommandStream::execute'::`2'::<lambda_1>,void>::_Do_call
    @   00007FF76195B07E  (unknown)  filament::backend::CommandStream::execute
    @   00007FF761806364  (unknown)  filament::FEngine::execute
    @   00007FF7618083ED  (unknown)  filament::FEngine::loop
    @   00007FF7617F50EF  (unknown)  std::thread::_Invoke<std::tuple<int (__cdecl filament::FEngine::*)(void),filament::FEngine *>,0,1>
    @   00007FF7658BDF66  (unknown)  thread_start<unsigned int (__cdecl*)(void *),1>
    @   00007FFCD751259D  (unknown)  BaseThreadInitThunk
    @   00007FFCD8A8AF38  (unknown)  RtlUserThreadStart

Desktop (please complete the following information):

  • OS: Windows
  • GPU: NVIDIA 2080 ti
  • Backend: Vulkan

Smartphone (please complete the following information):
N/A

Additional context
N/A

@pixelflinger pixelflinger added the vulkan Issues with the Vulkan backend label Dec 2, 2024
@pixelflinger pixelflinger added bug Something isn't working and removed bug Something isn't working labels Jan 16, 2025
@emezeske
Copy link
Contributor Author

A similar question to #8185: any chance this is on Q1 OKRs?

I checked again at HEAD just to make sure that this crash wasn't fixed by some other change, and it still occurs. I did a little bit more digging around, and still can't see anything silly that I'm doing to cause an issue here. I'm quite sure that my code is calling engine->destroy() for the existing swap chain, before creating a new one, and still panicing due to VK_ERROR_NATIVE_WINDOW_IN_USE_KHR.

@poweifeng
Copy link
Contributor

Yes. I'll be looking at both of these issues in coming days (next couple of weeks). Thanks

@emezeske
Copy link
Contributor Author

That's wonderful news -- thanks a bunch Powei!

poweifeng added a commit that referenced this issue Jan 17, 2025
Because of a recent ref-counting refactor, the swapchains are not
being immediately destroyed when destorySwapChain is called. This
might cause issue with following calls to createSwapChain.

We make sure the ref-counted resources are cleaned-up before new
swapchains are created.

Fixes #8288
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vulkan Issues with the Vulkan backend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants