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

Fix Vulkan Validation issues on Android #8139

Merged
merged 5 commits into from
May 26, 2024

Conversation

renderexpert
Copy link
Contributor

@renderexpert renderexpert commented May 11, 2024

Added extended validation (VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT) - https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkValidationFeatureEnableEXT.html

The following validation errors are fixed:
1.

OMcore                  app.organicmaps.debug                E  vulkan/vulkan_layers.cpp:162 DebugReportCallbackImpl(): Vulkan Diagnostics [ Validation ] [ COMMAND_BUFFER ] [OBJ: 12970367442591508160 LOC: 1611758864 ]: Validation Error: [ VUID-vkCmdBindDescriptorSets-pDescriptorSets-06715 ] Object 0: handle = 0xb400007815f566c0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x4a581c0000000195, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; Object 2: handle = 0xa7baa9000000011c, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x60117d10 | vkCmdBindDescriptorSets(): pDynamicOffsets[0] is 256, but must be zero since the buffer descriptor's range is VK_WHOLE_SIZE in descriptorSet #0 binding #0 descriptor[0]. The Vulkan spec states: For each dynamic uniform or storage buffer binding in pDescriptorSets, if the range was set with VK_WHOLE_SIZE then pDynamicOffsets which corresponds to the descriptor binding must be 0 (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdBindDescriptorSets-pDescriptorSets-06715)
OMcore                  app.organicmaps.debug                E  vulkan/vulkan_layers.cpp:170 DebugReportCallbackImpl(): Vulkan Diagnostics [ Validation ] [ RENDER_PASS ] [OBJ: 684740657406804014 LOC: 1544472022 ]: Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0x980b0000000002e, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x5c0ec5d6 | vkCmdBeginRenderPass():  Hazard WRITE_AFTER_WRITE vs. layout transition in subpass 0 for attachment 1 aspect depth during load with loadOp VK_ATTACHMENT_LOAD_OP_CLEAR.
OMcore                  app.organicmaps.debug                I  vulkan/vulkan_layers.cpp:170 DebugReportCallbackImpl(): Vulkan Diagnostics [ Validation ] [ BUFFER ] [OBJ: 15462946592855688298 LOC: 1544472022 ]: Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0xd6976c000000046a, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x5c0ec5d6 | vkCmdCopyBuffer():  Hazard WRITE_AFTER_WRITE for dstBuffer VkBuffer 0xd6976c000000046a[], region 0. Access info (usage: SYNC_COPY_TRANSFER_WRITE, prior_usage: SYNC_COPY_TRANSFER_WRITE, write_barriers: SYNC_INDEX_INPUT_INDEX_READ|SYNC_VERTEX_ATTRIBUTE_INPUT_VERTEX_ATTRIBUTE_READ, command: vkCmdCopyBuffer, seq_no: 13, reset_no: 1011).
OMcore                  app.organicmaps.debug                I  vulkan/vulkan_layers.cpp:170 DebugReportCallbackImpl(): Vulkan Diagnostics [ Validation ] [ QUEUE ] [OBJ: 12970367442600201344 LOC: 1544472022 ]: Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0xb4000078167a0c80, type = VK_OBJECT_TYPE_QUEUE; | MessageID = 0x5c0ec5d6 | vkQueueSubmit():  Hazard WRITE_AFTER_WRITE for entry 0, VkCommandBuffer 0xb4000078167a1b80[], Submitted access info (submitted_usage: SYNC_COPY_TRANSFER_WRITE, command: vkCmdCopyBuffer, seq_no: 1, reset_no: 1011). Access info (prior_usage: SYNC_COPY_TRANSFER_WRITE, write_barriers: SYNC_INDEX_INPUT_INDEX_READ|SYNC_VERTEX_ATTRIBUTE_INPUT_VERTEX_ATTRIBUTE_READ, queue: VkQueue 0xb4000078167a0c80[], submit: 2020, batch: 0, batch_tag: 122569, command: vkCmdCopyBuffer, command_buffer: VkCommandBuffer 0xb4000078167a1900[], seq_no: 1, reset_no: 1011).

@biodranik
Copy link
Member

Thank you! @Jean-BaptisteC can you please check it on different Android devices?

@vng
Copy link
Member

vng commented May 11, 2024

nit: android_vulkan_context_factory.cpp Discard unrelated formatting changes (not good IMO).

drape/vulkan/vulkan_texture.cpp Outdated Show resolved Hide resolved
@Jean-BaptisteC
Copy link
Member

How to see errors in logcat?

@biodranik
Copy link
Member

To test changes in Vulkan rendering engine:

  • Run OM on different real devices in landscape and portrait, drag and zoom in different places
  • type ?vulkan in search if ?gl was typed before and restart the app
  • the renderer engine is tested by building routes, enabling navigation, opening place page, showing search results and bookmarks/tracks
  • move app to background and show it again in different states.

@biodranik
Copy link
Member

biodranik commented May 21, 2024

@renderexpert The beta with this change has many crashes on Galaxy A33 5G, Pixel 7, P30 Pro, Galaxy A41, Galaxy A31, Pixel 7a, Poco F5 with this log and call stack:

05-20 14:45:05.031 (Thread-23) E/OMcore: vulkan/vulkan_object_manager.cpp:224 CreateDescriptorSetGroup(): CHECK(statusCode == VK_SUCCESS) Vulkan error: vkAllocateDescriptorSets(m_device, &allocInfo, &s.m_descriptorSet) finished with code VK_ERROR_FRAGMENTED_POOL


      Crashed: Thread: SIGABRT  0x0000000000000000
#00 pc 0x59b38 libc.so (BuildId: 7841d31efc11481579e4cb75ccbcdb4f)
#01 pc 0x59b08 libc.so (BuildId: 7841d31efc11481579e4cb75ccbcdb4f)
#02 pc 0x777de4 liborganicmaps.so (dp::vulkan::VulkanObjectManager::CreateDescriptorSetGroup(ref_ptr<dp::vulkan::VulkanGpuProgram>) [vulkan_object_manager.cpp:224]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#03 pc 0x73455c liborganicmaps.so (dp::vulkan::ParamDescriptorUpdater::Update(ref_ptr<dp::GraphicsContext>) [vulkan_param_descriptor.cpp:101]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#04 pc 0x73d300 liborganicmaps.so (dp::vulkan::VulkanVertexArrayBufferImpl::RenderRange(ref_ptr<dp::GraphicsContext>, bool, dp::IndicesRange const&) [vulkan_vertex_array_buffer_impl.cpp:63]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#05 pc 0x762e0c liborganicmaps.so (dp::VertexArrayBuffer::RenderRange(ref_ptr<dp::GraphicsContext>, bool, dp::IndicesRange const&) [vertex_array_buffer.cpp:194]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#06 pc 0x7540f8 liborganicmaps.so (dp::RenderBucket::Render(ref_ptr<dp::GraphicsContext>, bool) [vertex_array_buffer.cpp:177]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#07 pc 0x6330f8 liborganicmaps.so (df::RenderGroup::Render(ref_ptr<dp::GraphicsContext>, ref_ptr<gpu::ProgramManager>, ScreenBase const&, df::FrameValues const&, ref_ptr<df::DebugRectRenderer>) [render_group.cpp:118]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#08 pc 0x6c3410 liborganicmaps.so (df::FrontendRenderer::RenderOverlayLayer(ScreenBase const&) [frontend_renderer.cpp:1888]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#09 pc 0x6c23fc liborganicmaps.so (df::FrontendRenderer::RenderScene(ScreenBase const&, bool) [frontend_renderer.cpp:1471]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#10 pc 0x6c4a70 liborganicmaps.so (df::FrontendRenderer::RenderFrame() [frontend_renderer.cpp:1765]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#11 pc 0x6c7f04 liborganicmaps.so (df::FrontendRenderer::Routine::Do() [base_renderer.cpp:64]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#12 pc 0xadb964 liborganicmaps.so (threads::(anonymous namespace)::RunRoutine(std::__ndk1::shared_ptr<threads::IRoutine>) [thread.cpp:26]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#13 pc 0xae3a84 liborganicmaps.so (void* std::__ndk1::__thread_proxy[abi:v170000]<std::__ndk1::tuple<std::__ndk1::unique_ptr<std::__ndk1::__thread_struct, std::__ndk1::default_delete<std::__ndk1::__thread_struct> >, void (*)(std::__ndk1::shared_ptr<threads::IRoutine>), std::__ndk1::shared_ptr<threads::IRoutine> > >(void*) [invoke.h:394]) (BuildId: 630db1d7abb840dc394734505f2145c4e0f5f7e7)
#14 pc 0xbe888 libc.so (BuildId: 7841d31efc11481579e4cb75ccbcdb4f)
#15 pc 0x5b370 libc.so (BuildId: 7841d31efc11481579e4cb75ccbcdb4f)

@Jean-BaptisteC
Copy link
Member

Able to reproduce crash

Select a POI -> start routing and locks your device
Wait few seconds -> app crashed

2024-05-22 13:08:49.307 16547-16622 OMcore                  app.organicmaps.web.debug            E  vulkan/vulkan_object_manager.cpp:224 CreateDescriptorSetGroup(): CHECK(statusCode == VK_SUCCESS) Vulkan error: vkAllocateDescriptorSets(m_device, &allocInfo, &s.m_descriptorSet) finished with code VK_ERROR_OUT_OF_POOL_MEMORY_KHR
2024-05-22 13:08:49.308 16547-16622 libc                    app.organicmaps.web.debug            A  /home/runner/work/organicmaps/organicmaps/drape/vulkan/vulkan_object_manager.cpp:224: DescriptorSetGroup dp::vulkan::VulkanObjectManager::CreateDescriptorSetGroup(ref_ptr<VulkanGpuProgram>): assertion "false" failed
2024-05-22 13:08:49.308 16547-16622 libc                    app.organicmaps.web.debug            A  Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 16622 (Thread-17), pid 16547 (cmaps.web.debug)

@renderexpert renderexpert force-pushed the vulkan_validation_fixes branch 2 times, most recently from 0c4d36d to f58eec0 Compare May 24, 2024 14:30
@renderexpert
Copy link
Contributor Author

@vng PTAL
@Jean-BaptisteC could you please re-test this PR and a follow-up (#8276)

@biodranik biodranik added this to the Needs alpha/beta testing milestone May 25, 2024
Copy link
Member

@vng vng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine for me.

@vng vng merged commit 088bef5 into organicmaps:master May 26, 2024
15 checks passed
Copy link
Member

@Jean-BaptisteC Jean-BaptisteC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Pixel 6 - Android 14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants