mach_msg_trap, - (void) 鼠标拖动和计时器性能
豹 10.5.8、XCode 3.1.1;使用 runModalForWindow 来实现(预期的)高性能鼠标跟踪机制,我必须在其中进行实时复杂的位图修改。
模态循环运行,计时器触发,鼠标跟踪......但性能很糟糕,并且运行循环持续的时间越长,性能就越差。我不是每像素左右捕获一次鼠标消息,而是每 5...10....20 秒捕获一次。
Instruments 显示,在这个不断增长的响应瓶颈期间,大部分时间都花在 mach_msg_trap 上(是的,我将视角设置为正在运行的应用程序),所以我的印象是,它“认为”它没有任何工作要做,尽管事实上我像一个疯子一样按住按钮拖动鼠标。没有出现内存泄漏,并且在我的 8 核 2.8 GHZ 机器中,几乎没有 CPU 活动发生。
同样,该应用程序在我的代码中没有花费太多时间......所以这不是我的性能问题。我可能配置了一些错误的东西,或者根本没有配置它,或者只是错误地接近了整个想法——但我肯定会感激这里的一些见解。就目前情况而言,鼠标消息和定时器消息的调度是绝对不可接受的。按照我得到的响应时间,你无法为沉浸在冷糖蜜中的人实施蜡笔绘图程序。
编辑:一些附加信息:在我的 10.5.8 macbook pro 上不会发生。就是 8 核、6 显示屏的 Mac Pro。我尝试取出drawrect中croprect的显示代码,用NSLog()替换它......在发出鼠标更新时仍然拖延。还尝试重新启动并运行而不运行通常的应用程序补充。并配有镜面显示屏。没有区别。
想象一下在屏幕上拖动画笔;一开始,绘制是否顺利,然后画笔放置之间出现间隙,然后它们变大,这种情况持续下去,直到每 10 秒只放置一个画笔。这就是它的作用。使用 NSlog() 和各种其他跟踪方法,我确定它至少在最高级别发生,因为 mouseDragged 事件减慢为涓流。简而言之,问题是,为什么会发生这种情况?
有人吗?
Leopard 10.5.8, XCode 3.1.1; using runModalForWindow to implement (what is intended to be) a high performance mouse tracking mechanism where I have to do real-time complex bitmap modifications.
The modal loop runs, the timer fires, the mouse tracks... but the performance is abysmal, and it gets worse and worse the longer the runloop goes on. Instead of catching mouse messages every pixel or so, I get them every 5... 10.... 20 seconds.
Instruments shows that the majority of the time during this growing response bottleneck is being spent in mach_msg_trap (and yes, I have the perspective set to the running app), so the impression I am under is that it "thinks" it doesn't have any work to do, despite the fact that I'm dragging the mouse around with the button held down like a crazy person. There are no memory leaks showing up, and in my 8-core 2.8 GHZ machine, there's almost no CPU activity going on.
Again, the app is not spending much time in my code... so it's not a performance problem of mine. I've probably configured something wrong, or failed to configure it at all, or am simply approaching the whole idea wrong -- but I sure would appreciate some insight here. As it stands now, the dispatch of mouse messages and timer messages is absolutely unacceptable. You couldn't implement a crayon drawing program for someone immersed in cold molasses with the response times I'm getting.
EDIT: Some additional info: doesn't happen on my 10.5.8 macbook pro. Just the 8--core, 6-display Mac Pro. I tried taking the display code for the croprect in drawrect out, replaced it with an NSLog()... still drags on issuing mouse updates. Also tried rebooting and running without the usual complement of apps running. And with mirrored displays. No difference.
Imagine dragging a brush across the screen; at first, is paints smoothly, then gaps appear between brush placements, then they get larger, and this goes on until you're only getting one brush placement every 10 seconds. That's how this acts. Using NSlog() and various other tracking methods, I've determined that it is at least at the highest level occurring because the mouseDragged events slow down to a trickle. The question in a nutshell is, why would that happen?
Anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,已将其隔离 — 问题出在我的 Wacom 平板电脑鼠标上。插入普通的光电鼠标,一切都运行良好。我的 Macbook pro 上也有同样的情况,使用触控板。工作正常。
该平板电脑是 Wacom Intuos 4,带有截至 2011 年 1 月的原厂驱动程序。接下来我将访问 Wacom 网站并报告这一点。
那真是一场噩梦。我在这上面花了 100 多个小时,认为我已经掌握了应用程序处理、绘图等方面的一些微妙之处。天啊。
OK, isolated it -- the problem comes from my Wacom Tablet mouse. Plug in a regular optical mouse, and everything runs great. Same thing on my Macbook pro, using the trackpad. Works fine.
The tablet is a Wacom Intuos 4 with the stock drivers as of January 2011. I'm going over to the Wacom site and reporting this next.
What a nightmare that was. I have spent over 100 hours on this, thinking I'd hosed some subtlety in the app handling, drawing, etc. Sheesh.