VulkanTutorial icon indicating copy to clipboard operation
VulkanTutorial copied to clipboard

Changing window states using tutorial code freezes system for some time

Open eligt opened this issue 5 years ago • 5 comments

Changing any window state, such as position, size, minimization, etc. causes the system to freeze for a certain amount of time, the time it freezes for seems to be directly related to the amount of time spent doing the window transformation (like move or resize).

This is on Lubuntu 18.04 x64 with kernel 5.2.8-050208-generic, with NVIDIA GeForce GTX 1060 using NVIDIA drivers version 435.21.

I'm using code from latest example, 29_multisampling.cpp and it happens both with/without validation layers enabled.

Might be related to https://github.com/Overv/VulkanTutorial/issues/15

eligt avatar Feb 17 '20 21:02 eligt

Adding this type of (awful) code to cap the frame rendering to 120 FPS fixes the freezes so maybe too many frames are sent in for rendering when you move/resize the window?

	void mainLoop() {
		auto now = std::chrono::system_clock::now();
		
		while (!glfwWindowShouldClose(window)) {
			glfwPollEvents();
			drawFrame();
			auto diff = std::chrono::system_clock::now() - now;
			auto micros = std::chrono::duration_cast<std::chrono::microseconds>(diff);
			//std::this_thread::sleep_for( std::chrono::microseconds(16600 - micros.count()) );
			std::this_thread::sleep_for( std::chrono::microseconds(8200 - micros.count()) );
			now = std::chrono::system_clock::now();
		}
		
		vkDeviceWaitIdle(device);
	}

eligt avatar Feb 21 '20 19:02 eligt

Just an extra note on this for anyone stumbling upon it: seems like switching the sample from GLFW to SDL2 fixed the freezes for me.

eligt avatar Mar 10 '20 20:03 eligt

I was having the same issue running this in Manjaro with X11. I needed to add a 33200 microsecond delay to drag the window smoothly.

RussellHolgate avatar May 26 '20 18:05 RussellHolgate

I should also mention that without the delay, I was getting a consistent validation error when resizing the window related to imageExtent being out of bounds on "16_swap_chain_recreation.cpp" before modifying the code.

RussellHolgate avatar May 26 '20 18:05 RussellHolgate

I tried using SDL2 instead of GLFW but the problem persists for me.

RussellHolgate avatar May 30 '20 21:05 RussellHolgate