IT之家 04-30
Win7纯色背景用户曾遇启动延迟,微软资深工程师揭秘代码设计缺陷
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_keji1.html

 

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 秒,取决于性能。"

宙世代

宙世代

ZAKER旗下Web3.0元宇宙平台

一起剪

一起剪

ZAKER旗下免费视频剪辑工具

相关标签

微软 windows it之家 工程师
相关文章
评论
没有更多评论了
取消

登录后才可以发布评论哦

打开小程序可以发布评论哦

12 我来说两句…
打开 ZAKER 参与讨论