精选圈子榜单优站
Echo
Echo
普通用户
大家好,我是Echo!

Win7 纯色背景用户曾遭 30 秒启动延迟,微软资深工程师揭秘代码设计缺陷


IT之家 4 月 30 日消息,据外媒 Tom's Hardware 昨日报道,当年倾向于使用纯色背景而非图像壁纸的 Windows 7 用户,曾在系统启动时遭遇更长的等待时间。这一启动延迟问题出现在 2009 年,持续了约四个月。

微软资深工程师 Raymond Chen 最近在其博客《Old New Thing》中回顾了这段历史,并探讨了背后的代码设计问题。

Chen 自 Windows 95 起,就偏好以蓝绿色的纯色作为桌面背景。然而,从 2009 年 6 月 Windows 7 上市起,直到当年 11 月,微软才反应过来并修复前文所述的这一“反直觉”问题。

是什么原因导致使用纯色背景的用户反而启动更慢?根源其实“不难理解”:Windows 7 的登录系统会等待壁纸位图加载完毕并收到完成信号,然后才切换到桌面。而当用户选择关闭壁纸时,这一信号便永远不会到来,系统只能傻等超时,最多延迟达 30 秒。

Chen 在文中附上了代码。他表示:“用于报告‘壁纸已就绪’的逻辑被写进了壁纸加载模块里。也就是说,如果没有启用壁纸,这份‘报告’就不会发送,登录系统便一直在等,最后只能等到超时。”

IT之家附有关的代码如下:

InitializeWallpaper()
{
   if (wallpaper bitmap defined)
   {
       LoadWallpaperBitmap();
   }
}

LoadWallpaperBitmap()
{
   locate the bitmap on disk
   load it into memory
   paint it on screen
   Report(WallpaperReady);
}

// Original code
InitializeDesktopIcons()
{
   bind to the desktop folder
   enumerate the icons
   add them to the screen
   Report(DesktopIconsReady);
}

// Updated with group policy support

InitializeDesktopIcons()
{    if (desktop icons allowed by policy)
   {                                  
       bind to the desktop folder
       enumerate the icons
       add them to the screen
       Report(DesktopIconsReady);

   }                                  
}

他还提到,另一类可能遭遇相同问题的用户,是那些选择“隐藏桌面图标”的人。

Chen 特别强调,“准确地说,是 Windows 欢迎界面会强制显示 30 秒,而不是依据系统各组件真正准备好的时间 —— 有时可能只需 5 秒,也可能要 25 秒,取决于性能。”

广告声明:文内含有的对外跳转链接(包括不限于超链接、二维码、口令等形式),用于传递更多信息,节省甄选时间,结果仅供参考,IT之家所有文章均包含本声明。



  • 2025-04-30
  • 436阅读
评论