Open orion1vi opened 11 months ago
When crash happens in beginPresentation state looks like this: swapchain and device are used in that function but they're NULL so it crashes. Moving addPresentedHandler outside of addScheduledHandler solved this for me.
Er, uh, why did you close this? If there's a problem with our code, and you have a fix for it, you should probably submit it to this repo. We'd really appreciate that.
Because it was moved inside here: https://github.com/KhronosGroup/MoltenVK/commit/f0cb31a12b59f05177f07ab5a46bc9084ba5fbc9#diff-ee7f9cb03a11bba9ad9e2f634103f46908e74a8e5e630894a0a94340f312fd1bR1329 But if @billhollings wouldn't see a problem with moving it back outside the handler...
It looks like you have a race condition, where you are occasionally destroying the swapchain before the command buffer that is presenting its images has finished executing, or in your case, hasn't been scheduled into the GPU (which would happen almost immediately after submission to the queue).
Are you performing a vkDeviceWaitIdle()
after you detect the resize, but before you destroy the old swapchain? See demo_resize()
in cube.c
in the Cube demo for their use of it.
Were you are running with MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS=0
(disabled)?
If the current code is still causing this problem, PR #2297 may fix this. Please test again with that update, and re-close this issue if it fixes the problem.
Getting crash when addPresentedHandler is called at:
https://github.com/KhronosGroup/MoltenVK/blob/568cc3acc0e2299931fdaecaaa1fc3ec5b4af281/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm#L1321
I'm suspecting 9f64faadbcf490e73e69db8bc3e10154e61f17e5 and f0cb31a12b59f05177f07ab5a46bc9084ba5fbc9. If I remove all commits inclusive from 9f64faadbcf490e73e69db8bc3e10154e61f17e5 I cannot reproduce the crash. If I remove all commits from 9f64faadbcf490e73e69db8bc3e10154e61f17e5, but keep 9f64faadbcf490e73e69db8bc3e10154e61f17e5 a28437d8f21dff45563eaa550a8331698a32babb 7fe4963985d8ae44159243d8babff25cf830bca7 f0cb31a12b59f05177f07ab5a46bc9084ba5fbc9 I can reproduce the crash. Removing just f0cb31a12b59f05177f07ab5a46bc9084ba5fbc9 breaks sizing completely with
[mvk-error] VK_TIMEOUT: MTLCommandBuffer "vkQueueSubmit MTLCommandBuffer on Queue 0-0" execution failed (code 2): Caused GPU Timeout Error (IOAF code 2)
.Crash is difficult to reproduce but the way I'm reproducing is by spamming animated window resize (Window->Zoom with assigned key bind) where layer frame is auto resized to window frame, so autoresizingMask must be set, I use [.layerWidthSizable, .layerHeightSizable], but could reproduce with other masks. If I enable "Reduce motion" in Accessibility preferences, window zoom becomes non animated and I can't reproduce the crash.
Unfortunately I can't reproduce it with cube and can't provide any simple example application.
Tested on macOS 11.7 only.