Vulkan icon indicating copy to clipboard operation
Vulkan copied to clipboard

Pipelines demo is crashing on swapChain.acquireNextImage()

Open leiguo3 opened this issue 9 years ago • 8 comments

04-11 12:24:02.157 10566-10587/de.saschawillems.vulkanPipelines E/vulkan: dequeueBuffer returned unrecognized buffer 04-11 12:24:02.158 10566-10587/de.saschawillems.vulkanPipelines E/vulkanExample: Fatal : VkResult is " ERROR_OUT_OF_DATE_KHR " in D:/xxx/Vulkan_AS/pipelines/jni/../../pipelines/../code/base/vulkanexamplebase.cpp at line 556 04-11 12:24:02.159 10566-10587/de.saschawillems.vulkanPipelines E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -22 04-11 12:24:02.160 10566-10587/de.saschawillems.vulkanPipelines E/vulkan: queueBuffer failed: Invalid argument (-22) 04-11 12:24:02.161 10566-10587/de.saschawillems.vulkanPipelines E/vulkanExample: Fatal : VkResult is " ERROR_OUT_OF_DATE_KHR " in D:/xxx/Vulkan_AS/pipelines/jni/../../pipelines/../code/base/vulkanexamplebase.cpp at line 593

[ 04-11 12:24:02.177 1365:10313 D/ ] cmu_tune: rel=0.000000

[ 04-11 12:24:02.177 1365:10313 D/ ]

cmu_tune: cct=6504.087891

[ 04-11 12:24:02.177 1365:10313 D/ ] cmu_tune: new_cct=6504.087891

[ 04-11 12:24:02.207 1365:10313 D/ ] cmu_tune: rel=0.000000

Test on Nvidia SHIELD Tablet, Android 7.0, SHIELD tablet software version 5.0(24.29.404.121) The application crashes after a few seconds.

leiguo3 avatar Apr 11 '17 19:04 leiguo3

@SaschaWillems Also found the same crash on other applications on my SHIELD Tablet, such as "indirectdraw". Can you give me any idea on how to debug it?

leiguo3 avatar Apr 13 '17 18:04 leiguo3

Hard to tell. I noticed a few crashes after updating my Shield TV, but haven't had the time to investigate.

The VK_ERROR_OUT_OF_DATE_KHR hints at the swap chain becoming incompatible with the surface, and would need to be recreated. This is something that is not yet handled by my examples, but I'll try to add this once I get a bit more spare time.

If you want to try yourself you need to check the result of vkAcquireNextImageKHR and if this return VK_ERROR_OUT_OF_DATE_KHR you need to recreate the swap chain.

SaschaWillems avatar Apr 13 '17 20:04 SaschaWillems

@SaschaWillems I checked the result of vkAcquireNextImageKHR and recreated the swap chain when the return code is VK_ERROR_OUT_OF_DATE_KHR. It doesn't crash now. Thanks a lot.

The swap chain is recreated several times during the execution. If I touch the screen there would be more recreation.

leiguo3 avatar Apr 14 '17 21:04 leiguo3

@leiguo3 I pushed a commit that chsk for out_of_date (and suboptimal) and then recreates the swapchain. I couldn't test this as I wasn't able to reproduce on any of my Android devices.

Could you test and tell me if it works?

SaschaWillems avatar Apr 15 '17 08:04 SaschaWillems

Hi @SaschaWillems , I tested it. It is much stable now, however it still crashes after several minutes. The error message is as following.

=================================================================== 04-16 11:45:10.172 7826-7841/de.saschawillems.vulkanPipelines E/vulkanExample: Fatal : VkResult is " ERROR_OUT_OF_DATE_KHR " in jni/../../pipelines/jni/../../pipelines/../../base/vulkanexamplebase.cpp at line 600 --------- beginning of crash 04-16 11:45:10.173 7826-7841/de.saschawillems.vulkanPipelines A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x28 in tid 7841 (vulkanPipelines)

[ 04-16 11:45:10.175 175: 175 W/ ] debuggerd: handling request: pid=7826 uid=10189 gid=10189 tid=7841 04-16 11:45:10.263 13173-13173/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 04-16 11:45:10.264 13173-13173/? A/DEBUG: Build fingerprint: 'nvidia/wx_na_wf/shieldtablet:7.0/NRD90M/1928188_841.9637:user/release-keys' 04-16 11:45:10.265 13173-13173/? A/DEBUG: Revision: '0' 04-16 11:45:10.265 13173-13173/? A/DEBUG: ABI: 'arm' 04-16 11:45:10.266 13173-13173/? A/DEBUG: pid: 7826, tid: 7841, name: vulkanPipelines >>> de.saschawillems.vulkanPipelines <<< 04-16 11:45:10.267 13173-13173/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x28 04-16 11:45:10.267 13173-13173/? A/DEBUG: r0 8d7fdd80 r1 00000000 r2 a4e6e470 r3 00000000 04-16 11:45:10.268 13173-13173/? A/DEBUG: r4 a4e6e470 r5 8d7fdd80 r6 00000000 r7 9e664040 04-16 11:45:10.268 13173-13173/? A/DEBUG: r8 9e664040 r9 00000000 sl 00000000 fp 00000000 04-16 11:45:10.268 13173-13173/? A/DEBUG: ip 00000084 sp a4e6e3d0 lr 999ebb29 pc 999eb91a cpsr 600f0030 04-16 11:45:10.300 13173-13173/? A/DEBUG: backtrace: 04-16 11:45:10.300 13173-13173/? A/DEBUG: #00 pc 0065991a /system/vendor/lib/libglcore.so 04-16 11:45:10.300 13173-13173/? A/DEBUG: #01 pc 00659b25 /system/vendor/lib/libglcore.so 04-16 11:45:10.300 13173-13173/? A/DEBUG: #02 pc 00659bb7 /system/vendor/lib/libglcore.so 04-16 11:45:10.300 13173-13173/? A/DEBUG: #03 pc 006f14e3 /system/vendor/lib/libglcore.so 04-16 11:45:10.300 13173-13173/? A/DEBUG: #04 pc 006fb4b5 /system/vendor/lib/libglcore.so 04-16 11:45:10.300 13173-13173/? A/DEBUG: #05 pc 006e4561 /system/vendor/lib/libglcore.so 04-16 11:45:10.301 13173-13173/? A/DEBUG: #06 pc 000535bf /data/app/de.saschawillems.vulkanPipelines-1/lib/arm/libvulkanPipelines.so (_ZN17VulkanTextOverlay20updateCommandBuffersEv+402) 04-16 11:45:10.301 13173-13173/? A/DEBUG: #07 pc 0004dddb /data/app/de.saschawillems.vulkanPipelines-1/lib/arm/libvulkanPipelines.so (_ZN17VulkanExampleBase17updateTextOverlayEv+658) 04-16 11:45:10.301 13173-13173/? A/DEBUG: #08 pc 0004e035 /data/app/de.saschawillems.vulkanPipelines-1/lib/arm/libvulkanPipelines.so (_ZN17VulkanExampleBase10renderLoopEv+428) 04-16 11:45:10.301 13173-13173/? A/DEBUG: #09 pc 000453e1 /data/app/de.saschawillems.vulkanPipelines-1/lib/arm/libvulkanPipelines.so (android_main+64) 04-16 11:45:10.301 13173-13173/? A/DEBUG: #10 pc 000556af /data/app/de.saschawillems.vulkanPipelines-1/lib/arm/libvulkanPipelines.so 04-16 11:45:10.301 13173-13173/? A/DEBUG: #11 pc 00047543 /system/lib/libc.so (_ZL15__pthread_startPv+22) 04-16 11:45:10.301 13173-13173/? A/DEBUG: #12 pc 0001a115 /system/lib/libc.so (__start_thread+6)

===================================================================

I modified the code in a different way. Although the code structure is not as good as yours, there is no such crash. My modification:

pipelines.cpp:

void draw()
{
	bool succeed = VulkanExampleBase::prepareFrame();

    if(!succeed){
        VulkanExampleBase::windowResize();
        LOGE("Error: recreate swap chain");
        return;
    }

	submitInfo.commandBufferCount = 1;
	submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
	VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));

	VulkanExampleBase::submitFrame();
}

vulkanexamplebase.cpp:

bool VulkanExampleBase::prepareFrame()
{
	// Acquire the next image from the swap chaing
    VkResult result = swapChain.acquireNextImage(semaphores.presentComplete, &currentBuffer);
    if(result == VK_ERROR_OUT_OF_DATE_KHR ){
        return false;
    }else{
        return true;
    }
//	VK_CHECK_RESULT(swapChain.acquireNextImage(semaphores.presentComplete, &currentBuffer));
}

leiguo3 avatar Apr 16 '17 19:04 leiguo3

Thx for posting your working code snippet. Will see if it works on all devices and include it in my sources.

SaschaWillems avatar Apr 22 '17 11:04 SaschaWillems

Probably way different (since this issue is so old)

[96035:96043:0302/112205.248143:ERROR:vulkan_swap_chain.cc(441)] : vkAcquireNextImageKHR() hangs.
[96035:96035:0302/112205.248352:ERROR:gpu_service_impl.cc(964)] : Exiting GPU process because some drivers can't recover from errors. GPU process will restart shortly.

Version 98.0.4758.102 (Official Build) (64-bit)

$ vainfo
libva info: VA-API version 1.13.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_13
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.13 (libva 2.13.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 21.4.1 (be92568)

mcallaghan-geotab avatar Mar 03 '22 14:03 mcallaghan-geotab

at the same position, on the arm G76, i get this error code: VK_ERROR_SURFACE_LOST_KHR

luopan007 avatar Mar 26 '22 03:03 luopan007