Skip to content

Sometimes crashing during animated layer resize #2031

Open
@orion1vi

Description

@orion1vi

Getting crash when addPresentedHandler is called at:

addPresentedHandler(mtlDrwbl, presentInfo, signaler);

Thread 2 Queue : com.Metal.CompletionQueueDispatch (serial)
#0	0x000000010b2e9678 in unsigned int std::__1::__cxx_atomic_fetch_add<unsigned int>(std::__1::__cxx_atomic_base_impl<unsigned int>*, unsigned int, std::__1::memory_order) at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/atomic:1050
#1	0x000000010b2e95d1 in std::__1::__atomic_base<unsigned int, true>::fetch_add(unsigned int, std::__1::memory_order) at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/atomic:1719
#2	0x000000010b2e7672 in std::__1::__atomic_base<unsigned int, true>::operator++(int) at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/atomic:1748
#3	0x000000010b2e7645 in MVKSwapchain::beginPresentation(MVKImagePresentInfo const&) at /Users/orion/Developer/MoltenVK/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm:248
#4	0x000000010b17f131 in MVKPresentableSwapchainImage::beginPresentation(MVKImagePresentInfo const&) at /Users/orion/Developer/MoltenVK/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm:1403
#5	0x000000010b17ed9c in MVKPresentableSwapchainImage::addPresentedHandler(id<CAMetalDrawable>, MVKImagePresentInfo, MVKSwapchainSignaler) at /Users/orion/Developer/MoltenVK/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm:1384
#6	0x000000010b17ec8a in invocation function for block in MVKPresentableSwapchainImage::presentCAMetalDrawable(id<MTLCommandBuffer>, MVKImagePresentInfo) at /Users/orion/Developer/MoltenVK/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm:1321
#7	0x00007fff20d1e322 in -[MTLToolsCommandBuffer invokeScheduledHandlers] ()
#8	0x00007fff2856b292 in MTLDispatchListApply ()
#9	0x00007fff2856b1f4 in -[_MTLCommandBuffer didScheduleWithStartTime:endTime:error:] ()
#10	0x00007fff28543cd6 in ioAccelCommandQueueBlockFenceCallback ()
#11	0x00007fff22d816cb in IODispatchCalloutFromCFMessage ()
#12	0x00007fff22d8154c in _IODispatchCalloutWithDispatch ()
#13	0x000000011052eee3 in dispatch_mig_server ()
#14	0x000000011050f264 in _dispatch_client_callout ()
#15	0x00000001105120b8 in _dispatch_continuation_pop ()
#16	0x000000011052864a in _dispatch_source_invoke ()
#17	0x00000001105165ee in _dispatch_lane_serial_drain ()
#18	0x00000001105176ba in _dispatch_lane_invoke ()
#19	0x00000001105252c4 in _dispatch_workloop_worker_thread ()
#20	0x00000001105b2b0d in _pthread_wqthread ()
#21	0x00000001105b1ae3 in start_wqthread ()

I'm suspecting 9f64faa and f0cb31a.
If I remove all commits inclusive from 9f64faa I cannot reproduce the crash.
If I remove all commits from 9f64faa, but keep 9f64faa a28437d 7fe4963 f0cb31a I can reproduce the crash.
Removing just f0cb31a 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugCompletedIssue has been fixed, or enhancement implemented.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions