简体   繁体   English

Visual Studio 调试时出现极端滞后峰值

[英]Visual studio extreme lag spikes while debugging

When Im debugging my app in VS2012 and it crashes, the input (mouse and keyboard) starts to lag extremely, the fps drops to about 0.3 or less and I can't even move my mouse without waiting 3 seconds... The only solution is to do Shift-F5 which will end the debugging, and everythng is fine then again.当我在 VS2012 中调试我的应用程序并崩溃时,输入(鼠标和键盘)开始极度滞后,fps 下降到大约 0.3 或更低,我什至无法在不等待 3 秒的情况下移动鼠标......唯一的解决方案是做 Shift-F5 这将结束调试,然后一切都很好。

Whats more interesting, the only lagging thing is the input, the whole background works perfectly fine, text caret is blinking at normal rate and tooltips are nicely animated when mouse gets over a button.更有趣的是,唯一滞后的是输入,整个背景工作得很好,文本插入符号以正常速度闪烁,当鼠标移到按钮上时,工具提示动画效果很好。

Im compiling the project with allegro 4.2 (I have to use it, it would take too long to explain why).我用allegro 4.2编译项目(我必须使用它,解释原因需要很长时间)。

I have no extensions, a pretty fast pc which should be able to handle debugging...我没有扩展,一个相当快的电脑应该能够处理调试......

Im interested in any solution, it may be dirty/hackish... I can of course provide more information if needed.我对任何解决方案感兴趣,它可能很脏/很黑……如果需要,我当然可以提供更多信息。

Thanks for any help.谢谢你的帮助。

EDIT: Reading through forums I found some information about the "Auto" window or something like that (don't remember exactly and can't find it anymore), which is doing some "background tasks" and that causes lags... Do you think running it on separate core would fix that?编辑:通过论坛阅读我发现了一些关于“自动”窗口或类似的信息(记不清了,也找不到了),它正在执行一些“后台任务”并导致滞后......做你认为在单独的核心上运行它会解决这个问题吗?

A tale of multi-second stalls when hitting a breakpoint, related to the raw input API: http://the-witness.net/news/2012/12/finding-and-fixing-a-five-second-stall/ ( archived )一个与原始输入 API 相关的断点时多秒停顿的故事: http : //the-witness.net/news/2012/12/finding-and-fixing-a-five-second-stall/存档

It's a very long time since I last saw this sort of thing myself, but I seem to remember that the culprit in my case was DirectInput.自从我自己上次看到这种事情以来已经很长时间了,但我似乎记得在我的案例中罪魁祸首是 DirectInput。 (This makes some sense, given the tale above, as DirectInput has long been a wrapper over the raw input API.) And I think the solution was to use the emulated keyboard and mouse devices rather than the default ones, which you do this by passing in one of the emulated device GUIDs to IDirectInput8_CreateDevice . (鉴于上面的故事,这是有道理的,因为 DirectInput 长期以来一直是原始输入 API 的包装器。)而且我认为解决方案是使用模拟键盘和鼠标设备而不是默认设备,您可以通过将模拟设备 GUID 之一传递给IDirectInput8_CreateDevice Discussed briefly here: http://msdn.microsoft.com/en-us/library/windows/desktop/ee416845%28v=vs.85%29.aspx在这里简要讨论: http : //msdn.microsoft.com/en-us/library/windows/desktop/ee416845%28v=vs.85%29.aspx

(I don't remember whether cooperative and exclusivity levels made a difference - it might be worth trying changing these too.) (我不记得合作和排他性级别是否有所不同 - 也可能值得尝试更改这些级别。)

I recently experienced the following similar issues while debugging a game:我最近在调试游戏时遇到了以下类似的问题:

  • Hit a breakpoint, halting the program for debugging.命中断点,停止程序进行调试。
  • Pressing any key now takes around 1 second to "process".现在按任意键大约需要 1 秒钟来“处理”。 It will be buffered and sent slowly one after another to whatever window is now active.它将被缓冲并缓慢地一个接一个地发送到现在处于活动状态的任何窗口。

In my case, the application installed a low level keyboard hook with SetWindowsHookEx(WH_KEYBOARD_LL, ...) .就我而言,应用程序安装了一个带有SetWindowsHookEx(WH_KEYBOARD_LL, ...)的低级键盘钩子。 After removing this (for !NDEBUG builds only as you wish), the input lag was gone.删除它后(对于 !NDEBUG 仅根据您的意愿构建),输入延迟消失了。

I suppose the hook cannot respond at all while your application is halted, and eventually the system skips it (after the ~1 second timeout).我想在您的应用程序暂停时钩子根本无法响应,最终系统会跳过它(大约 1 秒超时后)。 In fact, the link in the accepted answer mentions this issue, but I thought I explain the core of it right here, also because the link went dead before I fixed it.事实上,接受的答案中的链接提到了这个问题,但我想我在这里解释了它的核心,也是因为链接在我修复它之前就失效了。

Try to find such a hook in your application or dependencies, and check if removing it helps.尝试在您的应用程序或依赖项中找到这样的钩子,并检查删除它是否有帮助。 Since you mentioned this happens to your mouse too, check for a (low level) mouse hook ( WH_MOUSE_LL ) aswell.由于您提到这也会发生在您的鼠标上,因此还要检查(低级)鼠标挂钩( WH_MOUSE_LL )。 The available hooks are listed on MSDN . MSDN列出了可用的挂钩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM