Skip to content

Модификация YRTMetalView и YRTGLView вне главного потока #263

@alexeymilakhin

Description

@alexeymilakhin

Воспроизводится на последней версии этого демо-проекта

MacBook на процессоре M2 Pro
Xcode 16.2
Симулятор iPhone 16 Pro iOS 18.2

Modifying properties of a view's layer off the main thread is not allowed: view <YRTMetalView: 0x105e08c70> with nearest ancestor view controller <Full.MapViewController: 0x1162048a0>; backtrace: 
(
	0   UIKitCore                           0x00000001860ace98 -[UIView(UIKitManual) _raiseExceptionForBackgroundThreadLayerPropertyModification] + 404
	1   UIKitCore                           0x00000001860ad394 -[UIView(UIKitManual) actionForLayer:forKey:] + 524
	2   QuartzCore                          0x000000018b32aae4 -[CALayer actionForKey:] + 144
	3   QuartzCore                          0x000000018b3310f0 _ZN2CA5Layer12begin_changeEPNS_11TransactionEjP11objc_objectRS4_ + 200
	4   QuartzCore                          0x000000018b335234 _ZN2CA5Layer6setterEj12_CAValueTypePKv + 784
	5   QuartzCore                          0x000000018b32f850 -[CALayer setMagnificationFilter:] + 52
	6   Full.debug.dylib                    0x000000010b906114 _yandex_impl___ZN12MVKSwapchain16initCAMetalLayerEPK24VkSwapchainCreateInfoKHRj + 204
	7   Full.debug.dylib                    0x000000010b905fe0 _yandex_impl___ZN12MVKSwapchainC2EP9MVKDevicePK24VkSwapchainCreateInfoKHR + 236
	8   Full.debug.dylib                    0x000000010b8c8884 _yandex_impl___ZN9MVKDevice15createSwapchainEPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacks + 48
	9   Full.debug.dylib                    0x000000010b9286d4 _yandex_impl__vkCreateSwapchainKHR + 268
	10  Full.debug.dylib                    0x000000010bed4760 _ZN6yandex4maps7runtime6vulkan9SwapchainC2EPKNS2_13LogicalDeviceEPKNS2_19PresentationSurfaceE16VkPresentModeKHR18VkSurfaceFormatKHRRK10VkExtent2Dj27VkCompositeAlphaFlagBitsKHR + 208
	11  Full.debug.dylib                    0x000000010bed4648 _ZNK6yandex4maps7runtime6vulkan16SwapchainFactory6createERK10VkExtent2D + 504
	12  Full.debug.dylib                    0x000000010bed5e5c _ZN6yandex4maps7runtime6vulkan16SwapchainManager15createSwapchainERK10VkExtent2D + 32
	13  Full.debug.dylib                    0x000000010bedafa8 _ZN6yandex4maps7runtime6vulkan12RendererImpl10startFrameEv + 828
	14  Full.debug.dylib                    0x000000010befcb28 _ZN6yandex4maps7runtime4view14VulkanRenderer6renderEv + 312
	15  Full.debug.dylib                    0x000000010bf039cc _ZNSt3__110__function6__funcIZZ55-[YRTVulkanView initWithFrame:scale:lifecycleProvider:]ENK3$_0clENS_8functionIFvvEEEEUlvE_NS_9allocatorIS6_EES4_EclEv + 44
	16  Full.debug.dylib                    0x000000010bb47610 _ZN6yandex4maps7runtime6BinderIvJEEclEv + 80
	17  Full.debug.dylib                    0x000000010bb48d70 _ZN6yandex4maps7runtime5async8internal12PackagedTaskILNS2_6PolicyE1EvJEE6invokeEv + 24
	18  Full.debug.dylib                    0x000000010bb47c08 _ZN6yandex4maps7runtime5async8internal18PackagedTaskCommonINS2_7PromiseIvNS2_6HandleEEELNS2_6PolicyE1EEclEv + 40
	19  Full.debug.dylib                    0x000000010bb46518 _ZN6yandex4maps7runtime5async8internal12_GLOBAL__N_113CallbackEventclEv + 92
	20  Full.debug.dylib                    0x000000010bb33acc _ZN6yandex4maps7runtime8internal12threadRunnerIZNS2_10ThreadPoolC1EjRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEENS5_8functionIFvPNS1_5EventEEEENS1_14ThreadPriorityEE3$_0JEEEvSD_SJ_OT_DpOT0_ + 104
	21  Full.debug.dylib                    0x000000010bb352a0 _ZNSt3__114__thread_proxyB7v160006INS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEPFvRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEN6yandex4maps7runtime14ThreadPriorityEOZNSH_8internal10ThreadPoolC1EjSE_NS_8functionIFvPNSH_5EventEEEESI_E3$_0ESC_SI_SQ_EEEEEPvSV_ + 64
	22  libsystem_pthread.dylib             0x000000010493f6f8 _pthread_start + 104
	23  libsystem_pthread.dylib             0x000000010493a940 thread_start + 8
)
Modifying properties of a view's layer off the main thread is not allowed: view <YRTMetalView: 0x105e08c70> with nearest ancestor view controller <Full.MapViewController: 0x1162048a0>; backtrace: 
(
	0   UIKitCore                           0x00000001860ace98 -[UIView(UIKitManual) _raiseExceptionForBackgroundThreadLayerPropertyModification] + 404
	1   UIKitCore                           0x00000001860ad394 -[UIView(UIKitManual) actionForLayer:forKey:] + 524
	2   QuartzCore                          0x000000018b32aae4 -[CALayer actionForKey:] + 144
	3   QuartzCore                          0x000000018b3310f0 _ZN2CA5Layer12begin_changeEPNS_11TransactionEjP11objc_objectRS4_ + 200
	4   QuartzCore                          0x000000018b335234 _ZN2CA5Layer6setterEj12_CAValueTypePKv + 784
	5   QuartzCore                          0x000000018b3072f8 -[CAMetalLayer(CAMetalLayerPrivate) setNonDefaultColorspace:] + 96
	6   Full.debug.dylib                    0x000000010b90dcc0 -[CAMetalLayer(MoltenVK) setColorspaceNameMVK:] + 40
	7   Full.debug.dylib                    0x000000010b906240 _yandex_impl___ZN12MVKSwapchain16initCAMetalLayerEPK24VkSwapchainCreateInfoKHRj + 504
	8   Full.debug.dylib                    0x000000010b905fe0 _yandex_impl___ZN12MVKSwapchainC2EP9MVKDevicePK24VkSwapchainCreateInfoKHR + 236
	9   Full.debug.dylib                    0x000000010b8c8884 _yandex_impl___ZN9MVKDevice15createSwapchainEPK24VkSwapchainCreateInfoKHRPK21VkAllocationCallbacks + 48
	10  Full.debug.dylib                    0x000000010b9286d4 _yandex_impl__vkCreateSwapchainKHR + 268
	11  Full.debug.dylib                    0x000000010bed4760 _ZN6yandex4maps7runtime6vulkan9SwapchainC2EPKNS2_13LogicalDeviceEPKNS2_19PresentationSurfaceE16VkPresentModeKHR18VkSurfaceFormatKHRRK10VkExtent2Dj27VkCompositeAlphaFlagBitsKHR + 208
	12  Full.debug.dylib                    0x000000010bed4648 _ZNK6yandex4maps7runtime6vulkan16SwapchainFactory6createERK10VkExtent2D + 504
	13  Full.debug.dylib                    0x000000010bed5e5c _ZN6yandex4maps7runtime6vulkan16SwapchainManager15createSwapchainERK10VkExtent2D + 32
	14  Full.debug.dylib                    0x000000010bedafa8 _ZN6yandex4maps7runtime6vulkan12RendererImpl10startFrameEv + 828
	15  Full.debug.dylib                    0x000000010befcb28 _ZN6yandex4maps7runtime4view14VulkanRenderer6renderEv + 312
	16  Full.debug.dylib                    0x000000010bf039cc _ZNSt3__110__function6__funcIZZ55-[YRTVulkanView initWithFrame:scale:lifecycleProvider:]ENK3$_0clENS_8functionIFvvEEEEUlvE_NS_9allocatorIS6_EES4_EclEv + 44
	17  Full.debug.dylib                    0x000000010bb47610 _ZN6yandex4maps7runtime6BinderIvJEEclEv + 80
	18  Full.debug.dylib                    0x000000010bb48d70 _ZN6yandex4maps7runtime5async8internal12PackagedTaskILNS2_6PolicyE1EvJEE6invokeEv + 24
	19  Full.debug.dylib                    0x000000010bb47c08 _ZN6yandex4maps7runtime5async8internal18PackagedTaskCommonINS2_7PromiseIvNS2_6HandleEEELNS2_6PolicyE1EEclEv + 40
	20  Full.debug.dylib                    0x000000010bb46518 _ZN6yandex4maps7runtime5async8internal12_GLOBAL__N_113CallbackEventclEv + 92
	21  Full.debug.dylib                    0x000000010bb33acc _ZN6yandex4maps7runtime8internal12threadRunnerIZNS2_10ThreadPoolC1EjRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEENS5_8functionIFvPNS1_5EventEEEENS1_14ThreadPriorityEE3$_0JEEEvSD_SJ_OT_DpOT0_ + 104
	22  Full.debug.dylib                    0x000000010bb352a0 _ZNSt3__114__thread_proxyB7v160006INS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEPFvRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEN6yandex4maps7runtime14ThreadPriorityEOZNSH_8internal10ThreadPoolC1EjSE_NS_8functionIFvPNSH_5EventEEEESI_E3$_0ESC_SI_SQ_EEEEEPvSV_ + 64
	23  libsystem_pthread.dylib             0x000000010493f6f8 _pthread_start + 104
	24  libsystem_pthread.dylib             0x000000010493a940 thread_start + 8
)

На реальном устройстве iPhone 15 Pro плюс минус то же самое

Modifying properties of a view's layer off the main thread is not allowed: view <YRTGLView: 0x104a66080> with nearest ancestor view controller <Full.MapViewController: 0x104b31c00>; backtrace: 
(
	0   UIKitCore                           0x000000019d593438 8CC54497-F7EC-3903-AE5A-A274047C0CF1 + 5076024
	1   UIKitCore                           0x000000019d0e435c 8CC54497-F7EC-3903-AE5A-A274047C0CF1 + 164700
	2   QuartzCore                          0x000000019c3891b0 8A08CC24-0017-3108-BEA4-29111B40063C + 98736
	3   QuartzCore                          0x000000019c389024 8A08CC24-0017-3108-BEA4-29111B40063C + 98340
	4   QuartzCore                          0x000000019c402bd4 8A08CC24-0017-3108-BEA4-29111B40063C + 596948
	5   QuartzCore                          0x000000019c5ad5d4 8A08CC24-0017-3108-BEA4-29111B40063C + 2344404
	6   OpenGLES                            0x0000000228652790 4BF80FAF-8774-300C-A7B7-D3815C82DCBD + 26512
	7   libglInterpose.dylib                0x0000000103e5e3c4 _ZL43EAGLContext_renderbufferStorageFromDrawableP11EAGLContextP13objc_selectormPU23objcproto12EAGLDrawable11objc_object + 828
	8   Full.debug.dylib                    0x000000010964c6e8 -[YRTGLView createBuffers] + 116
	9   Full.debug.dylib                    0x000000010964c58c -[YRTGLView doRender] + 160
	10  Full.debug.dylib                    0x000000010964d384 _ZNSt3__110__function6__funcIZ51-[YRTGLView initWithFrame:scale:lifecycleProvider:]E3$_1NS_9allocatorIS2_EEFvvEEclEv + 40
	11  Full.debug.dylib                    0x00000001092b2130 _ZN6yandex4maps7runtime6BinderIvJEEclEv + 80
	12  Full.debug.dylib                    0x00000001092b391c _ZN6yandex4maps7runtime5async8internal12PackagedTaskILNS2_6PolicyE1EvJEE6invokeEv + 24
	13  Full.debug.dylib                    0x00000001092b2738 _ZN6yandex4maps7runtime5async8internal18PackagedTaskCommonINS2_7PromiseIvNS2_6HandleEEELNS2_6PolicyE1EEclEv + 40
	14  Full.debug.dylib                    0x00000001092b1000 _ZN6yandex4maps7runtime5async8internal12_GLOBAL__N_113CallbackEventclEv + 92
	15  Full.debug.dylib                    0x000000010929e2ec _ZN6yandex4maps7runtime8internal12threadRunnerIZNS2_10ThreadPoolC1EjRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEENS5_8functionIFvPNS1_5EventEEEENS1_14ThreadPriorityEE3$_0JEEEvSD_SJ_OT_DpOT0_ + 104
	16  Full.debug.dylib                    0x000000010929fac0 _ZNSt3__114__thread_proxyB7v160006INS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEPFvRKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEN6yandex4maps7runtime14ThreadPriorityEOZNSH_8internal10ThreadPoolC1EjSE_NS_8functionIFvPNSH_5EventEEEESI_E3$_0ESC_SI_SQ_EEEEEPvSV_ + 64
	17  libsystem_pthread.dylib             0x00000002256527d0 _pthread_start + 136
	18  libsystem_pthread.dylib             0x0000000225652480 thread_start + 8
)

В прод пускать страшно

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions