惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园_首页
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
ThreatConnect
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
H
Help Net Security
T
Threat Research - Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
A
Arctic Wolf
G
Google Developers Blog
量子位
U
Unit 42
I
InfoQ
V
V2EX
F
Fox-IT International blog
P
Privacy & Cybersecurity Law Blog
V
Visual Studio Blog
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏
C
CERT Recently Published Vulnerability Notes
博客园 - 三生石上(FineUI控件)
T
The Exploit Database - CXSecurity.com
T
Tailwind CSS Blog
SecWiki News
SecWiki News
Know Your Adversary
Know Your Adversary
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
The Hacker News
The Hacker News
Project Zero
Project Zero
Application and Cybersecurity Blog
Application and Cybersecurity Blog
月光博客
月光博客
Recent Commits to openclaw:main
Recent Commits to openclaw:main
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
GRAHAM CLULEY
C
Cisco Blogs
I
Intezer
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
Recorded Future
Recorded Future
T
Tenable Blog
W
WeLiveSecurity
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
T
The Blog of Author Tim Ferriss
www.infosecurity-magazine.com
www.infosecurity-magazine.com
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
PCI Perspectives
PCI Perspectives

文章列表

AI,AI,AI - 友人C 成为 Chromium Committer 我的个人经历 何以为我 - Being Leads Doing. LifeTimer - 记录生活、学习、工作 为什么软件在 macOS 上启动很慢? - 友人C 支持 Markdown 行级别评论 | 聊聊 AI 如何高效代码开发 内存指标与基础概念 - 友人C 工作三年感言 - 友人C 真相不会因我们的承受能力而改变(2024年终总结) - 友人C handsome —— 一款typecho主题
macOS 中 Chromium 中打开 Save File Dialog 后主进程cpu上涨到 20%+
友人C · 2025-11-29 · via

摘要

在macos 26上,chromium 中打开 Save File Dialog后主进程cpu上涨到20%+,在macOS 其他版本没有问题,只有chromium 存在问题,Firefox / safari 没有问题,通过 Instruments 定位到问题所在并给 Chromium 提交修复。

分析过程

对于这种必现的单场景问题比较好排查,通过instrument 抓一个trace,发现这里的罪魁祸首是firstBselineOffsetFromTop的调用。image(1)(1).png

接着找到SaveFileDialog在chromium代码的位置:components/remote_cocoa/app_shim/select_file_dialog_bridge.mm

image(2).png

这里首先需要了解两个概念:AccessoryView 和 firstBaselineAnchor 对齐规则。

  • AccessoryView: macOS在打开文件选择框时候,有一个自定义的区域,允许代码传入一个自定义的view显示在文件选择框的下方,比如这里的foramt 就是自定义的区域,也被称作AccessoryView。

image(3).png

  • firstBaselineAnchor:是指两个view的文本的首行文本的基线对齐image(4).png

查阅了一些资料发现firstBaselineAnchor 基线对齐本身的开销相对其他的top,bottom 对齐开销要高一些。
所以问题就出在了AccessoryView中的布局规则上。

接着在macos safari 中打开文件选择框,发现cpu 并不高,用instrument 分析macos safari 的accessoryView,会发现,在macOS 26上,safari 使用了centerY 属性来对齐 popupButton、label 以及外层的 stackView(见图 safari on macOS 26.png)。

safari on macOS 26.png

有意思的是,在macOS14上,safari 使用的对齐规则也是基线对齐(last base line),从一定程度说明了,safari 也发现了macOS 26上的性能问题,因此在macOS 26上修改了布局规则。

因此,我们可以考虑采用这种方式,将 firstBaselineAnchor 替换为 centerY 属性。修改后cpu 恢复正常。

给 chromium 提交 CL 并合入https://chromium-review.googlesource.com/c/chromium/src/+/6947045

最后修改:2025 年 12 月 07 日

© 允许规范转载

喜欢我的文章吗?
别忘了点赞或赞赏,让我知道创作的路上有你陪伴。