互联网与文化support.microsoft.com
微软 KB:请不停移动鼠标,否则查询可能失败
If you move your mouse continually the query may not fail. Do not stop moving
2009 — 2014,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是微软官方知识库的一篇 KB 文章,标题令人啼笑皆非:在使用 Excel 查询外部数据时,如果用户持续移动鼠标,查询可能就不会失败——文章甚至建议“不要停止移动鼠标”。它因暴露了 Windows 消息循环与线程调度中一个古怪的历史遗留问题而成为经典。
为什么经久不衰:它以一个荒诞却真实的官方文档,揭示了 Windows 消息循环、线程调度和 Excel 老代码库的深层机制,是理解 GUI 事件驱动编程怪癖的绝佳案例。
HN 评论精选
亲历者解释了根因:跨线程泵消息循环导致事件依赖鼠标移动来驱动。
我大约十年前做 Windows 开发时遇到过这个 bug。在一个已有窗口的线程上创建第二个窗口,然后在后台线程泵它的主循环,就会导致这个问题。此时两个消息循环会互相挂钩,子窗口必须等父窗口转发事件,第二个线程才能取到它。鼠标移动会发送 WM 消息,让另一个线程上的子窗口循环保持运转,我的 WM_TIMER 也卡住了。当时的 bug 报告很好笑:“连接 USB 数据采集探针后,用户必须移动鼠标才能工作”,后续 bug 是“只有移动鼠标时数据采集才正常”。
zbowling查看英文原文
I had this bug once about 10ish years ago when I was still a windows dev. Creating a 2nd window on a thread with a window already but then pumping it's main loop on a background thread can cause this. If you do that the loops get hooked to each other regardless of the thread pumping it. The child window has to wait until the parent window forwards the event for the second thread to pop it off. A mouse move will send a WM event and keep the child windows loop on the other thread spinning. My WM_TIMER on the child window was stuck as well. It happened to me because I had a hidden window on the background thread to get WM events for USB disconnect and reconnect messages from the system. The bug report was funny. "Connecting USB data collection probe doesn't work unless the user moves the mouse after connecting." and the follow up bug "Data collection only works when moving the mouse."
Excel 代码库极其古老,其手动调度的纤程架构正是这类怪异行为的温床。
Excel 代码库非常古老,大部分代码至今仍在使用。Excel 2010 仍依赖 WinAPI 的纤程(轻量线程),由应用手动调度而非依赖操作系统——这个思路近年随 Lua 协程和 Go 的 goroutine 又流行起来。2014 年时 Excel 里还有大量代码可追溯到 Excel 3(1990 年),Excel 2010 也仍沿用 Win 3 时代过时的 MDI 概念。
frik查看英文原文
Excel codebase is very old, most is still in recent versions. Excel 2010 still relies on WinAPI's Fibers [1] (lightweight threads). In recent years the idea got popular again with Lua's co-routines and GO's goroutines. So it is manually scheduled by the application, instead of relying on the OS. In 2014, there is a lot of code in Excel that dates back to Excel 3 (1990). Excel 2010 still relied on the outdated MDI concept [2] that had been introduced with Win 3 and only one Excel instance/main window can run. One can embed the Excel OLE component in one app [3]. As soon as the component get the focus it replaces the traditional menu bar with the custom drawn "ribbon bar". It looks weird out of place (Win9x style OLE app with ribbon bar). Office apps started with custom drawn UI objects with Office 97. It had these fancy toolbars and a italic window title [4] instead of the boring Win95 look that WinAPI provided. [1] http://msdn.microsoft.com/en-us/library/windows/desktop/ms682661(v=vs.85).aspx ; http://msdn.microsoft.com/en-us/library/windows/desktop/ms682402(v=vs.85).aspx [2] http://en.wikipedia.org/wiki/Multiple_document_interface [3] e.g. using the sample apps that come "Inside OLE 2nd" book. [4] http://www.cheresources.com/economics.shtml
从支持人员视角看,这种用户描述听起来荒诞不经。
想象一下,如果你是技术支持人员,客户坚称必须这样做才能解决问题,你会觉得客户有多疯狂?
ck2查看英文原文
Can you imagine how crazy you'd think the customer was if you were giving technical support and they insisted they had to do this?
提醒大家:这条建议未经微软验证,可能只是记录了客户的经验,不必急着嘲讽。
别忘了页面顶部的警告:“此信息是初步的,未经微软确认或测试。”所以虽然嘲笑“哈哈,这就是典型的愚蠢微软”很有趣,但这建议显然不是微软刻意给出的。更可能是某个支持工程师为了完整记录而写下了客户提到的鼠标操作,七年过去仍未验证……
CUViper查看英文原文
Don't forget the warning at the top, "This information is preliminary and has not been confirmed or tested by Microsoft." So while it's funny to say, "haha, isn't this typical of stupid M$," they apparently didn't produce this advice. More likely, some support tech recorded the mouse bit from the customer just to be complete, and 7 years later it still hasn't been verified...
历次讨论
同类还值得读
如今电脑上几乎所有操作在感知上都比 1983 年更慢(2017)
Almost everything on computers is perceptually slower than it was in 1983 (2017)
2017 年的推文串认为,尽管计算机硬件比 1983 年快得多,日常操作的感知速度却常常更慢:启动、界面响应和网络应用被层层抽象、动画、后台检查与网络依赖拖累。
互联网与文化上首页 5 次 · 2017–2020twitter.com网站肥胖危机
The Website Obesity Crisis
Maciej Cegłowski(idlewords)的经典演讲文稿《网站肥胖症危机》,批评现代网页越来越臃肿:动辄数 MB 的 JavaScript、追踪脚本和广告,把本可以轻…
互联网与文化上首页 5 次 · 2016–2021idlewords.com编辑精选亚马逊那本标价 23,698,655.93 美元的苍蝇书
Amazon’s $23,698,655.93 book about flies
博文讲的是亚马逊上一本关于果蝇的二手书被标到 23,698,655.93 美元。
互联网与文化上首页 5 次 · 2011–2022michaeleisen.org浏览器 User-Agent 字符串的历史
History of the browser user-agent string (2008)
2008 年的经典文章用戏谑的“创世纪”口吻,讲述浏览器 User-Agent 字符串如何从简单的标识演变成层层叠加的伪装:浏览器为了绕过按 UA 分发的网站检测,纷纷把自己伪装…
互联网与文化上首页 5 次 · 2012–2022webaim.org编辑精选最后的问题——艾萨克·阿西莫夫
The Last Question - Isaac Asimov
阿西莫夫最著名的短篇科幻小说《最后的问题》的在线全文。
互联网与文化上首页 5 次 · 2009–2019multivax.com编辑精选