Web平台的新功能 | 主题演讲
本页标题、字幕、摘要和阅读笔记为已保存的 AI 译文,可能有误。时间戳与来源一致,可展开查看原始字幕,并对照原视频核对。
谷歌的2021 Web平台主题演讲涵盖了隐私、应用集成、WebAssembly、图形以及构建更快Web体验的工具。
文字记录来源:YouTube上创作者上传的字幕。Vidleaf添加了AI标点;保留原始措辞和时间戳锚点。原始文字记录可在下方获取。
AI生成的摘要
这场2021 Chrome 主题演讲通过三个主题来呈现网络平台:隐私、更强大的应用和开发者生产力。演讲者讨论了隐私沙盒提案、浏览器与文件和设备的集成、图形、WebAssembly 以及性能改进。他们还将开发者工具和核心网页指标与让应用更快、在浏览器间更一致的工作联系起来。该演讲记录了该活动上宣布的功能、实验和计划。其中的示例有助于解释当时平台的发展方向;对即将发布的版本和试验的引用属于那个历史背景。
要点
- [2:32] 主题演讲围绕隔离和针对广泛追踪的专门替代方案来构建浏览器隐私工作。
- [18:26] WebAssembly 将现有的非 JavaScript 代码引入浏览器应用。
- [26:38] 跨浏览器兼容性被视为网页开发者的持续优先事项。
根据文字记录生成。请对照原始视频核查所链接的段落。简要说明和要点由 Vidleaf 于 2026-10-21 审核。
完整概述
Chrome 负责人 Ben 和 Dion 描述了网络如何从简单的互联文档演变为数十亿人使用的高性能通用计算平台,而疫情加速了在线互动和变革的步伐。会议围绕三个主题组织今年的发展:默认隐私、强大且无缝的网页应用,以及开发者生产力。在隐私方面,它解释了隐私沙盒模型、使 Cookie 仅对设置它们的网站可见的变更(现已在 Chrome、Edge 中强制执行,很快也将在 Firefox 中实施),以及保护隐私的 API 替代方案,例如 Attribution Reporting,它不共享任何用户身份数据并使用差分隐私,因为 Google 准备淘汰第三方 Cookie 并解决其他隐蔽追踪问题。对于网页应用,它涵盖了重新互动功能,如应用快捷方式、Badging API 和即将推出的声明式链接捕获源试用、改进的安装界面、多屏窗口放置 API、文件系统访问 API 以及有望实验的文件处理 API,还有设备 API,包括 Web HID(以 Joy-Con 为例)、Gamepad API 和 Web Serial,Piper Make 使用后者无需安装软件或驱动程序即可对 Raspberry Pi Pico 进行编程。图形和性能方面包括 Maps 倾斜和旋转以及 WebGLOverlayView 的测试版(在尤卡坦半岛上使用 three.js 演示)、实验性的 WebGPU,以及一个 V8 SIMD 源试用,该试用为 Google Meet 的浏览器内媒体处理管道带来了 200% 的提升。第二部分调查了更多收益:由浏览器中的 TensorFlow 提供支持的背景模糊功能、计划面向所有 Chrome 用户的 SIMD、WebAssembly 移植工作(如 Replicache 将 Rust 编译为 WebAssembly)、WebAssembly 线程在 Chrome 88 中登陆 Android 版 Chrome、Chrome DevTools 中改进的 WebAssembly 调试、V8 Sparkplug 编译器、已向部分用户发布的密集计时器节流、content-visibility 支持、Chrome 87 中 Android 上的 BFCache 并计划扩展到桌面端、今年晚些时候推出的用于同站预加载的预渲染 API、滚动到文本扩展、即将推出的文档过渡 API、跨设备一次性密码、核心网页指标和 Lighthouse 工具、专注于 CSS 痛点的 Compat2021 跨浏览器努力,以及 DevTools 更新和扩展。
带时间戳的章节摘要
Chrome 负责人谈网络演进和 I/O 主题
- [0:05] Ben 和 Dion 是 Chrome 团队的负责人,他们多年来一直合作致力于网络平台。
- [0:13] 网站已从简单的互联文档演变为丰富的交互式网页应用,而网络现在是一个高性能、通用的计算平台,全球数十亿人在使用。
- [0:29] 疫情将更多日常互动推向线上,加速了网络的发展,并随着使用量激增引发了改善网络体验的热潮。
- [0:47] 许多计算平台起起落落,而“不进则退”这句老话对任何平台的持续相关性都起着重要作用。
- [1:02] 网络演进的步伐正在加快,因为它必须跟上整个技术和社会的步伐。
- [1:11] 在今年的 Google I/O 上,会议将涵盖最新的网络发展,本次会议总结了今年要记住的关键主题。
- [1:29] 会议涵盖三个主题:为所有用户默认隐私、强大快速无缝的网页应用,以及帮助开发者提高生产力并取得成功。
隐私沙盒和 Cookie 变更
- [1:57] 现代浏览器默认使用沙盒模型隔离每个网站。
- [2:15] Chrome 首先将每个网站隔离到自己的进程中,最近又将每个跨站 iframe 隔离到自己的进程中。
- [2:32] Google 正在通过隐私沙盒将沙盒方法应用于用户数据和追踪,旨在将信息安全地保存在浏览器内。
- [2:50] 隐私沙盒在两年前作为与社区合作的开放倡议宣布,并谨慎地以周全的方式过渡网络生态系统。
- [3:09] 第一步是更改 Chrome 中的 Cookie,使其仅对设置它们的同一网站可见,要求开发者选择加入第三方 Cookie。
- [3:35] 之前广泛的默认 Cookie 可见性通过使用户暴露于跨站请求伪造攻击而造成了安全问题。
- [4:01] 这种保护隐私的默认设置现已在 Chrome、Edge 中强制执行,很快也将在 Firefox 中实施。
- [4:07] Google 正在合作开发一系列 API,作为联合登录、个性化广告和转化跟踪等用例的隐私保护替代方案。
- [5:17] Attribution Reporting API 在网站之间不共享任何用户身份数据;浏览器跟踪广告转化并发送带有时间延迟和噪声的加密报告,这种技术称为差分隐私。
- [6:06] 归因报告(Attribution Reporting)目前作为 Chrome 源试用实验提供,同时还有其他几个 API,今年内还会有更多 API 发布。
- [6:21] Google 正准备逐步淘汰第三方 Cookie,并实施针对其他形式隐蔽追踪的保护措施。
Web 应用操作系统集成进展
- [6:57] Web 已成为一个强大的应用平台,在现代浏览器中提供快速、无缝的体验。
- [7:11] Chromebook 表明,无需操作系统维护专业知识,Web 访问也可以做到经济实惠、安全且简单。
- [7:23] Google 的使命是赋予 Web 实现最先进计算体验所需的能力。
- [7:40] Google 一直致力于让用户能够轻松无缝地重新与 Web 应用互动。
- [8:03] 新的应用快捷方式功能让 Web 应用可以在 Android、Chrome OS、Windows 和 macOS 上提供快捷操作。
- [8:14] Badging API 让 Web 应用可以通过装饰应用图标来提供微妙的重新互动提示。
- [8:24] Chrome 即将推出声明式链接捕获(Declarative Link Capturing)的源试用,该功能可在适当的链接上自动启动已安装的 Web 应用,并能防止多个实例。
- [8:45] Chrome 的 Web 应用安装界面得到改进:桌面端显示带有产品内帮助的地址栏图标,Android 端则有从清单文件填充的更丰富的对话框。
- [9:15] 多屏幕窗口放置 API(Multi-Screen Window Placement API)让 Web 应用可以发现连接的显示器并控制窗口放置,这对演示和视频会议应用很有用。
- [9:36] 文件系统访问 API(File System Access API)让 Web 应用可以读写本地文件系统,Gravit Designer 和 PhotoBee 就在使用该功能。
- [9:54] 新的文件处理 API(File Handling API)将把 Web 应用注册为文件类型处理程序,以便用户可以直接从操作系统文件浏览器中打开文件,希望今年晚些时候能推出实验版本。
用于设备连接的新 Web API
- [10:20] Web 长期以来一直能够与蓝牙 MIDI 设备通信。
- [10:25] 现在有几个新 API 支持更广泛的此类设备。
- [10:35] Web HID 是一个用于使用 HID 协议通信的设备的新 API。
- [10:40] 任天堂的 Joy-Con 控制器就是支持 HID 协议的设备的一个例子。
- [10:48] Web 现已支持行业标准的 Gamepad API,使 Stadia 等应用能够在浏览器中实现毫不妥协的游戏体验。
- [11:01] Web Serial API 为 Web 增加了串行端口支持。
- [11:13] Piper Make 是一个基于块的编辑器,用于对 Raspberry Pi Pico 进行编程,只需插入设备并打开浏览器即可,得益于 Web Serial,无需安装软件或设置驱动程序。
- [11:31] 这些以及其他新的 Web 能力通过浏览器实现了深度集成、无缝的体验。
地图 WebGL 3D 功能测试版
- [11:49] 地图多年前就采用了 WebGL,以实现硬件加速图形和更强大的 UI。
- [11:58] 去年,地图团队通过 Maps JavaScript API 在 Web 应用中提供了 WebGL 加速的地图功能。
- [12:34] 在开发者主题演讲中,宣布了两个新功能的测试版发布:倾斜和旋转,以及 WebGLOverlayView。
- [12:46] 这些功能让开发者首次能够使用与渲染底图相同的 WebGL 上下文,在三维空间中操作地图。
- [13:06] 该演示使用 three.js 在以墨西哥尤卡坦半岛为中心的地图上渲染一个 3D 对象,并使用地图 ID 来实现矢量地图和自定义样式。
- [13:29] WebGLOverlayView 通过扩展 google.maps.WebglOverlayView 实现,并暴露了进入底图 WebGL 渲染上下文生命周期的钩子。
- [13:51] 该演示重点介绍了三个钩子:创建叠加层实例时的 onAdd()、渲染上下文可用后的 onContextRestored(),以及执行渲染的 onDraw()。
- [15:47] 一个带有 fromLatLngAltitude 函数的 transformer 对象会创建投影矩阵,从而省去开发者的矩阵运算。
- [16:30] 倾斜和旋转以及 WebGLOverlayView 是该团队承诺的最新交付成果,未来还计划推出更多功能。
Web 图形与 WebAssembly 性能
- [16:50] WebGL 在几年前推出时,为 Web 带来了全新水平的图形性能。
- [16:56] 他们正与图形和 Web 社区密切合作,开发 WebGPU,这是一个从零开始设计的下一代图形 API,旨在释放 Web 上新的图形性能。
- [17:10] WebGPU 从 Vulcan、Metal 和 Direct 3D 12 等底层 API 中汲取灵感,目前仍处于非常实验性的阶段,但有着令人兴奋的前景。
- [17:22] Web Assembly 提供了一个标准,可将代码编译为快速高效的格式,由 V8 等现代 JavaScript 引擎在浏览器中执行。
- [17:34] 他们最近通过在 V8 中实现对 SIMD 处理器指令的支持,大幅提升了 Web Assembly 的性能,使某些类别的应用能够运行得快得多。
- [17:46] Google Meet 提供了 SIMD 实际应用的有力例证。
SIMD 提升 Google Meet 性能
WebAssembly 移植与 V8 更新
- [18:26] WebAssembly 常被用于将非 JavaScript 代码库引入 Web,以实现新的用例。
- [18:34] Replicache 的开发者将其 Rust 代码编译为 WebAssembly,以便网页开发者能将其集成到 Web 应用中。
- [18:48] V8 在 2019 为 WebAssembly 添加了线程支持,以简化代码移植,但该功能仅对桌面操作系统启用。
- [18:57] 自88年一月的 Chrome 起,Android 版 Chrome 获得了 WebAssembly 线程支持。
- [19:06] V8 在 Chrome DevTools 中通过断点和变量检查增强了 WebAssembly 调试功能。
- [19:25] V8 团队也一直在努力从其引擎中挖掘更多 JavaScript 性能。
V8 编译器与 Chrome 性能特性
- [19:31] V8 不仅解释 JavaScript,还会即时编译代码以实现更高效的执行。
- [19:38] 该团队实现了一个名为 Sparkplug 的新编译器。
- [19:49] 今年早些时候,Chrome 向部分用户推出了密集计时器节流功能。
- [19:57] 密集计时器节流会检测标签页是否已在后台超过五分钟,并且只要该标签页未在播放音频或视频,就会降低基于计时器的 JavaScript 在该标签页上执行的频率。
- [20:10] Chrome 推出了对名为 content-visibility 的新 CSS 属性的支持。
- [20:17] 将元素的 content-visibility 设置为 auto,可让浏览器在该元素树的内容当前未显示在用户屏幕上时跳过渲染这些内容。
- [20:29] 这可以为内容繁重的网站带来显著的速度提升。
Chrome 即时导航与预渲染
- [20:51] 去年十一月发布的 Chrome 87 为 Android 版 Chrome 添加了往返缓存(BFCache)。
- [21:00] BFCache 会在导航离开后将某些网页保留在内存中,因此后退或前进时会立即显示该页面。
- [21:11] 移动端每五次导航中就有一次是通过历史记录栈向后或向前移动。
- [21:21] Chrome 的 BFCache 目前已在 Android 上可用,但存在一些限制,并计划很快将其扩展到 Chrome 桌面版。
- [21:38] 预渲染会在用户点击链接之前加载网页资源并渲染 DOM,但由于副作用以及可能跨站点泄露用户信息,很难正确实现。
- [22:19] 新的预渲染 API 将让开发者能在今年晚些时候试验同站点预加载。
- [22:36] 去年二月在 Chrome 80 中加入的滚动到文本功能,可让浏览器将视口定位到特定文本元素并高亮显示。
- [22:53] 滚动到文本 API 的一个可滚动到图像的版本即将推出,其他元素类型也正在探索中。
- [22:59] 新的文档过渡 API 即将登陆 Chrome,作为实验支持元素之间的图形过渡。
Web 上的跨设备一次性密码
核心 Web 指标与开发者工具
- [23:54] Google 正在努力让 Web 对开发者更友好,并与更广泛的生态系统合作,以解决该平台最突出的痛点。
- [24:03] web.dev 提供详细的教程、最新新闻,以及 Lighthouse 网站审计工具的访问入口。
- [24:18] Lighthouse 提供一份全面的报告,涵盖性能、可访问性和 SEO 等类别,帮助改进网站。
- [24:35] 三项 Lighthouse 性能指标(称为核心 Web 指标)对用户体验的影响尤为显著。
- [24:44] 核心 Web 指标共同衡量网站显示关键内容的速度、首次交互的响应速度,以及布局偏移的程度。
- [25:03] 意大利出版商 GEDI 通过使用品牌化占位符预留广告空间,并将部分 JavaScript 推迟到页面可见后执行,使其移动端文章页面的跳出率改善了 8%。
- [25:41] Shopify 和 Wix 在其管理控制台中实现了性能仪表板,WordPress 社区则推出了图像和 iframe 的懒加载。
- [25:56] Google 更新了其 WordPress 的 Site Kit 插件,增加了核心 Web 指标测量支持和具体的改进建议。
- [26:07] Google 搜索宣布,核心 Web 指标很快将成为搜索结果中页面排名方式的一部分。
跨浏览器兼容性与 CSS 复兴
- [26:38] 开发者们一直强调跨浏览器兼容性的重要性。
- [26:42] 今年他们宣布参与一项名为 Compat2021 的跨行业合作。
- [26:49] Compat2021 旨在解决由网页开发者投票选出的前五大浏览器兼容性痛点,而这些痛点恰好都与 CSS 相关。
- [27:00] CSS 正迎来一场令人兴奋的复兴,CSS Flexbox 和 Grid 被开发者视为页面布局的重大改进而广泛采用。
- [27:13] 多年来从 Sass 等 CSS 框架中获得的经验(如嵌套)正被融入平台本身。
- [27:22] 容器查询这一最受期待的 CSS 功能,将让样式规则自然地限定在局部上下文中,而非全局生效,从而实现更模块化、更可复用的样式表。
Chrome DevTools 更新与扩展
- [27:37] Chrome 内置的开发者工具是其最受欢迎的功能之一,也是强大的 Web 开发副驾驶。
- [27:48] 在过去一年中,DevTools 获得了多项改进,包括新的颜色选择器、改进的 PWA 警告和 linting、Core Web Vitals 叠加层、专用的 CSS Flexbox 调试、丢帧可视化,以及对 CSS 和 JavaScript 的支持。
- [28:09] DevTools 也是一个支持扩展的平台。
- [28:14] Angular DevTools Chrome 扩展为 Angular 应用提供专门的调试和性能分析支持。
- [28:25] 观众可前往 Chrome DevTools 会议环节,深入了解这些新功能。
- [28:33] 网络正以根本性的方式演进,通过保护用户隐私的新 API 实现默认私密。
Web 平台的进步与生态系统支持
[0:05] -我是 Ben。-我是 Dion。我们是 Chrome 团队的负责人。[Dion] 我们两人多年来一直合作开发 Web 平台。看着网站从简单的互联文档演变为如今丰富的交互式 Web 应用,这很有趣。网络已成为一个高性能、通用的计算平台,被全球数十亿人使用。[Dion] 过去一年,随着疫情将我们更多的日常互动推向线上,网络的发展加速了,使用量激增,从而引发了改进 Web 体验的热潮。
[0:40] 对我们来说,这强化了网络的重要性,以及我们所有人需要共同努力使其变得更好的必要性。过去几十年里,我们见证了许多计算平台的兴衰。有一点非常清楚:那句老话“不进则退”对任何平台的持续相关性都起着重要作用。如今,网络多年来已经发生了巨大演变。展望未来,我认为演进的步伐正在加快,因为它必须如此,才能总体上跟上技术和社会的发展。因此,在今年的 Google I/O 上,我们有许多会议环节将让你了解网络的一些最新发展。
[1:19] 在本次会议中,我们将简要总结我们认为今年你应该牢记的关键主题。我们还会告诉你可以在哪里了解更多并深入探索。我们将从隐私开始,解释网络如何演进,以默认为所有用户提供私密浏览体验。接下来,我们将介绍网络如何赋能新一代强大、快速、无缝的 Web 应用和出色的用户体验。最后,我们将总结我们正在做的工作,以帮助开发者在网络上高效且成功地开展工作。
[1:52] 那么让我们从隐私开始,我们将通过讨论沙盒来展开。现代浏览器围绕沙盒这一隐喻构建。你访问的每个网站默认都与系统的其余部分隔离,包括与其他网站和其他打开的标签页隔离,就像我们被虚拟墙壁包围一样,如同花园中的沙盒。Chrome 从最早的日子起就在浏览器沙盒模型上进行了创新,首先是将每个网站隔离到其自己的进程中。
[2:23] 最近,在此基础上进一步扩展,将网页上的每个跨站 iframe 隔离到其自己的进程中。我们对用户数据和跟踪采取同样的方法,构建一种隐私沙盒,力求在你的浏览器内保证你所有信息的安全与可靠,从而形成一个默认让你的身份和活动保持私密的网络。两年前,我们宣布了隐私沙盒计划,这是一项开放倡议,与社区合作将这一愿景变为现实,同时谨慎地以深思熟虑、审慎的方式帮助网络生态系统过渡到新模式。
[3:07] 我们想介绍一下我们的进展。我们的第一步是在两年前的 Google I/O 上宣布的,即改变 Chrome 中 cookie 的行为,将其从默认跨网站可见改为仅对设置它们的同一网站可见。在此变更之前,并不清楚 cookie 是用于第一方还是第三方用途,浏览器需要观察 cookie 在现实中的使用方式来推断其用途。这也造成了安全问题,因为这种广泛的默认可见性使用户面临跨站请求伪造攻击,攻击基于第三方观察这些 cookie 中的信息。
[3:48] 现在,开发者需要选择加入才能跨网站使用 cookie,即所谓的第三方 cookie。反过来,浏览器便可以非常直接地禁用此类 cookie。这种保护隐私的默认行为现已在 Chrome、Edge 中强制执行,并且很快将在 Firefox 中实施。接下来,我们一直在与生态系统合作开发一系列新 API,为当今依赖第三方 cookie 的用例(如联合登录、个性化广告和转化跟踪)提供保护隐私的替代方案。
[4:23] 为了说明这些 API 如何应对这一挑战,让我们仔细看看其中之一:归因报告 API。任何网络业务的一个关键方面是如何扩大用户受众,而这通常涉及通过广告来增加流量。在这些广告支出的另一端,网络上的内容发布者往往依赖广告收入来维持其商业模式。了解有多少用户实际点击了广告,以及这些用户随后是否采取了诸如订阅新闻通讯或完成购买之类的行动,是这个模式的重要组成部分。
[5:01] 传统上,这种衡量是通过第三方 Cookie 跨网站跟踪用户点击前后的行为来完成的。那么,我们如何在不跟踪用户的情况下做到这一点呢?归因报告应运而生。使用这个提议的 API,网站之间不会共享任何可识别用户身份的数据。相反,是由浏览器来跟踪广告转化。之后,浏览器会针对每个转化事件向广告主发送一份加密报告。
[5:34] 但它会为这些报告增加时间延迟和噪声,以进一步遏制识别用户的尝试。这种技术被广泛称为差分隐私。这种方法使双方仍然能够衡量其广告活动的效果,了解广告能够驱动哪些行为,并且是在不跨网站跟踪用户的情况下做到这一点。归因报告是 Privacy Sandbox 项目中的众多新 API 提案之一。
[6:06] 它今天已可作为一个 Chrome 源试用实验使用,同时还有其他几个 API,我们将在今年全年发布更多。在我们与整个生态系统的各位合作,将这些新 API 引入网络平台的同时,我们也在推进淘汰第三方 Cookie 的准备工作,并实施针对其他形式隐蔽跟踪的保护措施。关于如何处理你自己的 Cookie,我们今天在技术会议中提供了更多细节。
[6:36] 因此,Privacy Sandbox 项目代表着网络平台的一次重大演进,在默认保护隐私的同时,也保留了关键的网络用例。对网络来说如此巨大而根本的变革需要时间,但我们致力于这项工作及其将为全球网络用户带来的益处。网络已经发展成为一个强大的应用平台,使任何拥有现代浏览器的人都能获得加载快速、运行流畅的行业领先体验。
[7:11] 而像 Chromebook 这样的设备表明,网络访问可以变得经济实惠、安全且简单,无需成为维护底层操作系统的专家。多年来,我们一直致力于确保网络具备将最先进的计算体验带到该平台所需的所有能力。自上次在 I/O 与各位交流以来,网络已经获得了一系列重要的新能力。我们想为您重点介绍其中的几项。我们一直在努力的一个领域是让用户能够轻松无缝地重新使用网络应用。
[7:47] 几年来,无论是在移动端还是桌面端,都可以轻松地将网络应用作为图标添加到原生启动器中,这是我最喜欢的平台功能之一。我们想谈谈我们如何深化了网络应用与底层操作系统之间的这种集成。借助新的应用快捷方式功能,网络应用可以在支持此功能的操作系统上提供快速操作,例如 Android、Chrome OS、Windows 和 macOS。而借助 Badging API,网络应用可以通过装饰应用的图标,向用户发出一个微妙的提示,表明有重新参与的机会。
[8:24] 很快,我们将推出另一个新 API——声明式链接捕获的 Chrome 源试用实验,它使已安装的网络应用能够在用户点击适当的链接时自动启动。这还可以防止同一应用的多个实例打开,这样你就不会出现 10 个标签页中都是同一个网络应用的情况。我们最近还改进了 Chrome 的网络应用安装界面。在桌面端,我们现在会显示一个多功能框图标,并提供产品内帮助来向用户解释此功能。
[8:57] 而在 Android 上,我们让对话框看起来更丰富、对用户更熟悉,并且让开发者可以轻松地用网络应用清单文件中指定的自定义图像和文本填充对话框。这些就是我们改进网络与操作系统启动集成的方式。我们还在添加其他操作系统集成,例如多屏窗口放置 API,它允许网络应用发现所有连接的显示器,并控制窗口在这些屏幕上的放置位置。
[9:29] 如今,对于基于网络的演示和视频会议应用来说,这实际上是一个相当方便的功能。现在,网络应用终于可以使用文件系统访问 API 读写用户的本地文件系统,使 Gravit Designer 和 PhotoBee 等应用能够提供更加无缝的用户体验,将状态持久化到磁盘并处理现有文件。我们还在开发一个新的文件处理 API,它将允许网络应用注册为文件类型处理程序,使用户能够直接从操作系统文件浏览器在网络应用中打开文件。
[10:08] 我们希望在今年晚些时候发布此 API 的实验版本。现在让我们谈谈外围设备;比如专用键盘、游戏控制器、数码钢琴、耳机等等。如今,网络已经能够与 MIDI 设备上的蓝牙通信有一段时间了。但几个新 API 现在支持更广泛的此类设备集合。其中许多设备使用 HID 协议进行通信。网络现在在 Web HID 中为此提供了 API。
[10:40] Nintendo 的 Joy-Con 控制器就是支持此协议的设备的一个例子。对于游戏手柄式控制器,行业标准的 Gamepad API 现在也已获得 Web 支持,这使得在浏览器中通过 Stadia 等应用实现毫不妥协的游戏体验成为可能。你还可以用游戏手柄来有型地操控 Chrome 恐龙。Web 现在也通过 Web Serial API 支持串口。这实际上开启了我最喜欢的新用例之一:Piper Make。
[11:13] 这是一个基于块的编辑器,可让你对 Raspberry Pi Pico 进行编程。你只需将设备插入任何电脑,打开浏览器,就可以开始了。无需安装软件或折腾驱动程序,这一切都归功于 Web Serial。现在,借助这些及其他新的 Web 能力,你可以通过浏览器为世界各地的用户带来深度集成、无缝的体验。Google Maps 在我们心中占有特殊的地位,因为它在 15 年前首次推出时就是一个极具影响力的 Web 应用。
[11:46] Maps 持续在 Web 上创新。几年前,他们采用了 WebGL,实现了硬件加速图形,并在此过程中交付了强大得多的 Maps UI。去年,Maps 团队让这些相同的 WebGL 加速地图能力可以通过 Maps JavaScript API 在你的 Web 应用中使用。今年,该团队有新的东西要分享。请和我一起欢迎该团队的工程负责人 Travis McPhail,他将告诉我们更多相关信息。
[12:18] 我们不断惊叹于你运用自己的技能、创造力以及 Google 对现实世界的知识,构建出令人难以置信的丰富体验,真正重新构想了地图。正是本着这种精神,今天在开发者主题演讲中,我们宣布了两项新功能的测试版发布,它们让你对底图拥有前所未有的控制力:倾斜和旋转,以及 WebGLOverlayView。借助这些功能,你可以首次在三个维度上操作地图,同时利用我们用于渲染底图的同一 WebGL 上下文的能力。
[12:57] 有史以来第一次,你不仅可以在 地图之上 构建,还可以 与地图一起 构建。让我们快速看看它是如何工作的。为简便起见,我使用 three.js——一个流行的 Web 图形库——在地图上渲染一个 3D 对象。我搭建了一个基础 Web 应用,它会加载以墨西哥尤卡坦半岛某地点为中心的地图。我还使用了一个地图 ID,以便使用矢量地图并应用一些自定义样式。
[13:29] 我需要做的第一件事是通过扩展 google.maps.WebglOverlayView 来实现 WebGLOverlayView。WebGL 叠加层暴露了一组钩子,可接入底图 WebGL 渲染上下文的生命周期。今天,我们会尽可能保持简单,只关注其中三个。第一个是 onAdd(),在创建叠加层实例时调用。第二个是 onContextRestored(),在渲染上下文可用后调用。
[14:01] 第三个是 onDraw(),地图以及你指定的任何其他内容实际上就是在这里渲染的。在 onAdd() 中,我将设置场景所需的一切,且这些内容不需要立即访问渲染上下文。我首先创建一个新的 three.js 场景。我还创建一个表示场景视口的相机。在本例中,是透视相机。接下来,场景至少需要一个光源,以便任何渲染的对象在场景中被照亮。
[14:35] 在本例中,使用环境光来均匀照亮场景中的所有对象。现在,我准备使用 GLTFLoader 添加我的 3D 对象。对象加载后,我会对其进行缩放和旋转,以便正确渲染。然后我将其添加到场景中。在 onContextRestored() 中,我配置 three.js 的 WebGLRenderer,将地图的渲染上下文和视口信息传递给它。对象渲染后,我还想让相机动起来,为用户提供对象的动态视图。
[15:13] 我在渲染器的 setAnimationLoop 函数中调用了 moveCamera。我还在每一帧中稍微增加倾斜、朝向和缩放,以形成漂亮的下旋运动。好了。该渲染了。three.js 相机需要一个投影矩阵,这样它才知道如何将地图 3D 世界中的纬度和经度坐标渲染为屏幕的 2D 坐标。我不知道你怎么想,但矩阵变换可不是我心目中的愉快时光。
[15:47] 因此,为了替你省去大量数学运算,我们交给你一个 transformer 对象,它带有 fromLatLngAltitude 函数,可为你创建这个矩阵。我将希望模型出现的经纬度坐标传递给它,并将返回值设置为 camera.projectionMatrix。剩下的就是清除 GL 状态,通过在 WebGLOverlayView 实例上调用 requestRedraw() 告诉 WebGLOverlayView 我要重绘,然后渲染场景。
[16:18] 最后,我创建我的类的一个实例,并设置我想要应用到的地图实例。这就是结果。几分钟编码能做到这样还不错,对吧?倾斜和旋转以及 WebGLOverlayView 只是我们兑现对你承诺的最新方式。我们还有更多计划,我们迫不及待想看到你想出的所有方式,再次重新构想地图,并向我们展示下一步。交回给你,Dion。谢谢,Travis。
[16:50] 几年前 WebGL 问世时,它为 Web 带来了全新水平的图形性能。我们目前正与图形和 Web 社区密切合作,推进 WebGPU——这一全新的下一代图形 API,它从底层设计开始就是为了在 Web 上解锁全新水平的图形性能。WebGPU 从 Vulcan、Metal 和 Direct 3D 12 等底层 API 中汲取灵感,目前仍非常实验性,但为未来带来了令人兴奋的前景。
[17:22] 另一项关键的性能技术是 Web Assembly,它提供了一种标准,可将代码编译为快速高效的格式,并能由现代 JavaScript 引擎(如 V8)在浏览器中执行。我们最近通过在 V8 中实现对 SIMD 处理器指令的支持,为 Web Assembly 带来了重大的性能提升,这使得某些类别的应用能够运行得更快。Google Meet 提供了一个 SIMD 实际应用的强大示例。与任何视频会议应用一样,Meet 必须密切关注其性能预算。
[17:55] 在对视频进行处理以增强效果与保持流畅、低延迟的流之间存在着持续的张力。利用 V8 的 SIMD 实验性源试用,Meet 团队在其浏览器内媒体处理管线上实现了 200% 的性能提升。这反过来又为他们提供了预算,能够为大多数用户启用由浏览器中的 TensorFlow 驱动的背景模糊功能。我们计划在未来几个月内向所有 Chrome 用户发布 SIMD。
[18:26] 现在,Web Assembly 也经常被用来将非 JavaScript 代码库带到 Web 上,为它们解锁新的用例。例如,离线优先同步引擎 Replicache 背后的开发者能够将其 Rust 代码编译为 Web Assembly,使 Web 开发者能够无缝地将其整合到他们的 Web 应用中。为了简化代码移植,V8 早在 2019 就为 Web Assembly 添加了线程支持。但当时仅对桌面操作系统启用。
[18:57] 我们很高兴地告诉大家,自今年一月的 Chrome 88 起,Android 版 Chrome 已获得 Web Assembly 线程支持。我们还增强了 V8 的 Web Assembly 调试体验,在 Chrome DevTools 中直接支持断点和变量检查。我们非常期待看到大家利用这个可在客户端或服务器上运行的通用运行时构建出什么——它运行迅捷、性能卓越。这就是 Web Assembly。V8 团队也一直在努力从其引擎中压榨出更多的 JavaScript 性能。
[19:31] 因此,除了解释 JavaScript 之外,V8 还会即时编译代码以实现更高效的执行。团队已经实现了一个全新的编译器,名为 Sparkplug。当然,有时提高代码执行性能的最佳方法是完全不执行任何代码。本着这种精神,今年早些时候,我们向部分用户发布了一项新的 Chrome 功能,称为密集计时器节流,该功能会检测浏览器标签页是否已在后台超过五分钟,并且只要该标签页没有播放任何音频或视频,Chrome 就会降低在该标签页上执行基于计时器的 JavaScript 代码的频率。
[20:10] 我们还通过发布对名为 content-visibility 的新 CSS 属性的支持,将这一概念应用于 CSS。当您将元素上的此属性设置为 auto 时,您就是在授予浏览器权限,如果该元素树的内容当前未在用户显示器上可见,则跳过渲染这些内容,这可以为内容繁重的网站带来显著的提速。现在,Web 平台上正在发生大量的创新,以使您的 Web 应用能够实现显著更快的运行时性能。
[20:40] 除了为扩展 Web 的能力和性能所做的工作外,平台也在不断演进,为用户提供即时、无缝的体验。在去年十一月发布的 Chrome 87 中,我们为 Android 版 Chrome 添加了所谓的往返缓存,简称 BFCache。BFCache 会在你离开某些网页后将其保留在内存中。因此,如果用户点击后退或前进,页面会立即显示。事实证明,移动端每五次导航中就有一次正是如此——在历史记录栈中后退或前进。
[21:18] 因此,此功能带来了非常大的影响。虽然目前 Chrome 的 BFCache 实现已在 Android 上可用,但它确实有一些限制。我们计划很快将其扩展到 Chrome 桌面平台。我们扩展即时体验的另一种方式是重新审视预渲染页面的概念。预渲染是一种在用户点击链接之前加载网页所有资源甚至渲染 DOM 的技术。这样它就可以真正即时地显示。
[21:48] 现在,这很难做到位,因为预加载这些页面也可能导致副作用,如果页面执行诸如退出登录之类的操作,或者页面播放音频,那么它也可能以神秘的方式开始播放。此外,如果跨站点进行,它可能会泄露一些用户信息。但是,当预渲染正确完成时,它为用户提供了这种强大的、即时的点击体验。因此,我们正在研究新的预渲染方法,这些方法是私密且安全的。其中一种涉及新的预渲染 API,它将使开发者能够在今年晚些时候在同一个站点预加载上进行实验。
[22:26] 过渡是用户体验的另一个重要方面,确保用户能够在浏览 Web 时切换上下文,并直接到达他们想去的地方。一个有趣、简单却影响巨大的功能是滚动到文本,它于去年二月被添加到 Chrome 80 中。通过在 URL 末尾添加一种新型表达式,浏览器可以将视口定位到特定文本元素并以某种方式高亮显示它。我们很快将发布此 API 的一个版本,可滚动到图像,我们也在探索其他元素类型。
[22:59] 随着即将作为实验性功能登陆 Chrome 的全新文档过渡 API,我们还在构建对元素之间多种图形过渡的支持,使用户在您的 Web 应用各状态之间切换时能够感受到无缝体验。我们也在努力让 Web 上的安全性更加无缝。有一个功能让我尤其兴奋,那就是面向 Web 的跨设备一次性密码。一次性密码是某些网站可以发送给您用于登录的数字验证码。
[23:31] 此功能使您能够在 Android 手机上接收这些一次性密码之一,然后将其自动传输到运行在其他设备(例如笔记本电脑)上的 Chrome 浏览器。所有这些新的 Web 能力都令人兴奋。但随着 Web 演进速度的加快,我们作为 Web 开发者在跟踪一切方面所面临的复杂性也在增加。我们正在努力让 Web 对开发者更友好,并与更广泛的生态系统合作,以了解和解决平台最主要的痛点。
[24:03] 要了解我们最新的 Web 开发建议,请访问 web.dev。该网站包含关键主题的详细教程、最新新闻,并且还提供对我们 Lighthouse 网站审计工具的访问。现在,借助 Lighthouse,您可以获得一份关于如何改进您网站的全面报告,涵盖性能、无障碍性和 SEO 等多个类别。我们会持续更新 Lighthouse 指南,以尽可能为您提供最佳的洞察。
[24:35] 我们发现 Lighthouse 的三项性能指标对用户体验的影响尤为显著。我们将其称为 Core Web Vitals(核心 Web 指标)。它们共同衡量网站显示关键内容的速度、网站对首次交互的响应速度,以及网站布局的偏移程度。整个 Web 上的网站都在将 Core Web Vitals 作为性能的北极星,并报告了令人鼓舞的结果。例如,意大利出版商 GEDI 发现其移动端文章页面的跳出率改善了 8%。
[25:13] 他们通过在页面的广告位中实现品牌化占位符来为广告预留空间,从而改善了布局稳定性,然后通过将部分 JavaScript 代码的加载推迟到页面可见之后,改善了感知的页面加载速度。Web 内容和商务平台也在投资 Core Web Vitals,以改善其所有托管网站的性能。例如,Shopify 和 Wix 在其管理控制台中实现了仪表板,将性能置于网站所有者的首要位置。
[25:49] WordPress 社区也发布了面向性能的附加功能,例如图像和 iframe 的延迟加载。我们还更新了 Site Kit——Google 面向 WordPress 的官方插件——使其支持测量 Core Web Vitals,并且它还会向开发者提供具体的改进建议。Google 搜索也已宣布,Core Web Vitals 很快将成为页面在搜索结果中排名方式的一部分。我们认为这尤其令人兴奋,因为它放大了 Core Web Vitals 对您——开发者——的好处。
[26:21] 这项投资不仅会为您的用户带来更好的体验,还会帮助他们通过这种方式找到您的网站。我们花了大量时间倾听开发者的意见,既包括小型聚会,也包括大规模开发者调查。我们一直听到的一个共同主题是跨浏览器兼容性对开发者的重要性。因此今年,我们最近宣布参与一项名为 Compat2021 的跨行业努力,该计划旨在修复由 Web 开发者投票选出的前五大浏览器兼容性痛点,而令人惊讶的是,这些痛点全都与 CSS 相关。
[27:00] 说到 CSS,我们正在这一领域看到一场令人兴奋的复兴。我们甚至拥有自己的现代版禅意花园。CSS Flexbox 和 Grid 已被开发者接受为创建页面布局的重大改进,而多年来从 Sass 等 CSS 框架中获得的经验正被融入平台,例如嵌套。再加上容器查询——我认为这是你们对 CSS 最强烈要求的功能——您将能够创建更加模块化和可复用的样式表,方法是让规则自然地限定在其本地上下文中,而不是如此全局地起作用。
[27:37] 现在,Chrome 最受欢迎的功能之一是其内置开发者工具套件,它为您提供了一个极其强大的工具包,可以作为您的 Web 开发副驾驶。在过去一年中,我们通过大量新改进增强了 DevTools,包括新的颜色选择器、改进的 PWA 警告和 lint 检查、Core Web Vitals 叠加层、专用的 CSS Flexbox 调试、丢帧可视化、对 CSS 和 JavaScript 的支持等等。
[28:09] 而且 DevTools 也是一个平台,因为它支持扩展。新扩展示例之一是 Angular DevTools Chrome 扩展,它提供专门针对 Angular 应用的调试和性能分析支持。所以请查看我们的 Chrome DevTools 会议,深入了解所有这些内容,并进一步了解我们新的 DevTools 功能。Web 正在以根本性的方式演进,因此它不会消亡。它正通过保护用户隐私的新 API 默认变得私密,并且它还在不断获得强大的新能力,拓宽平台上的可能性,从而提供更好的用户体验。
[28:51] 最后,随着网络不断发展,我们致力于在生态系统中与您合作,确保您拥有取得成功所需的所有工具和指导。您可以通过查看今年 I/O 上的许多其他会议来深入了解网络平台上的这些改进,我们今天已经重点介绍了其中许多会议。感谢您的时间,我们期待看到您利用现代网络演进后的能力构建出什么。如果您在 I/O 周期间观看此内容,请到 Adventure 来找我们。谢谢。
查看英文原始字幕
[0:05] -I’m Ben. -And I’m Dion. We’re leaders on the Chrome team. [Dion] The two of us have been working together on the web platform for many years. It’s been fun to watch as websites have evolved from simple connected documents to today's rich interactive web apps. The web has become a high performance, general purpose computing platform used by billions of people all across the globe. [Dion] The web’s growth has accelerated in the last year as the pandemic has pushed more of our daily interactions online, triggering a rush to improve web experiences as usage spikes.
[0:40] And for us, this reinforces the importance of the web and the need for all of us to work together to make it better. Now we’ve seen many computing platforms rise and fall over the past decades. One thing is really clear: the old adage evolve or die plays a major role in the ongoing relevance of any platform. Now, the web has evolved a great deal over the years. And looking forward, I think the pace of evolution is accelerating. because it kind of has to to keep pace with tech and society generally. So at Google I/O this year, we have a number of sessions that will bring you up to speed on some of the latest developments in the web.
[1:19] In this session, we’ll give you a quick summary of what we think are the key themes that you should keep in mind this year. And we’ll point you to where you can learn more and go deeper. We're going to start with privacy, explaining how the web is evolving to enable a private browsing experience for all users by default. Next we’ll cover how the web is enabling a new generation of powerful, fast, and seamless web apps and a fantastic user experience. And finally, we’ll summarize the work we’re doing to help developers be productive and successful with the web.
[1:52] So let’s get started with privacy, and we'll do that by talking about sandboxes. Modern browsers are built around the metaphor of a sandbox. Each website you visit is isolated by default from the rest of your system, including from websites and other open tabs just as though we’re surrounded by virtual walls like those of a sandbox in a garden. Now Chrome’s innovated with the browser sandbox model from its earliest days, first by isolating each website into its own process.
[2:23] And more recently, expanding on that to isolate each cross-site iframe on a webpage into its own process. We’re taking this same approach with user data and tracking, building a sort of privacy sandbox that seeks to keep all of your information safe and secure within your browser, resulting in a web where your identity and activity are private by default. We announced the Privacy Sandbox effort two years ago, as an open initiative, a collaboration with the community to bring this vision to life while also being careful to help transition the web ecosystem to a new model in a thoughtful, deliberate way.
[3:07] We’d like to give an update on our progress. Our first step, announced at Google I/O two years ago, was changing the behavior of cookies in Chrome, moving them from being visible across websites by default to being visible only to the same website that set them. Before this change, it wasn’t really clear whether a cookie was intended for first-party or third-party use and browsers needed to observe how cookies were used in the wild to infer their purpose. This also created a security problem because this wide default visibility of cookies exposed users to cross-site request forgery attack based on third parties observing the information in these cookies.
[3:48] Now, developers are required to opt in to use cookies across sites as so-called third-party cookies. And in turn, browsers could then disable such cookies in a very straightforward manner. This privacy-preserving default behavior is now enforced in Chrome, Edge, and, very soon, Firefox. Next we’ve been collaborating with the ecosystem on a new family of APIs that provide privacy-preserving alternatives to use cases that today rely on third-party cookies, such as federated login, personalized ads, and conversion tracking.
[4:23] To clarify how these APIs are approaching this challenge, let’s take a closer look at one of them: the Attribution Reporting API. So a key aspect of any web business is how you grow your user audience, and that often involves advertising to increase traffic. On the other side of those ad dollars, content publishers on the web often rely on revenue from advertisements to make their business model work. Finding out how many users actually clicked on the ad and whether those users subsequently did something like sign up for a newsletter or complete a purchase, is an important part of this model.
[5:01] Traditionally, this measurement is performed by tracking the user from before and after the click across websites with a third-party cookie. So how can we do this in a way that doesn’t involve tracking that user? Well, enter Attribution Reporting. Using this proposed API, no user-identifying data is shared between the sites. Instead, it’s the browser that keeps track of the ad conversion. Later, the browser sends an encrypted report to the advertiser for each of these conversion events.
[5:34] But it adds time delays and noise to these reports to further stifle attempts to identify users. This technique is broadly known as differential privacy. This approach enables both parties to still be able to measure the effectiveness of their ad campaigns and to understand what behavior the ads are able to drive and to do so without tracking the user across sites. Now Attribution Reporting is one of many new API proposals in the Privacy Sandbox project.
[6:06] It’s available for use as a Chrome origin trial’s experiment today, along with several other APIs, And we’ll ship more throughout the course of the year. As we work with all of you across the ecosystem to bring these new APIs to the web platform, we’re also moving forward with preparations to phase out third-party cookies and implementing protection against other forms of covert tracking. And we’ve got more details on what to do with your own cookies today in the technical sessions.
[6:36] So the Privacy Sandbox project represents a substantial evolution of the web platform, enabling privacy by default while also preserving critical web use cases. A change this large and fundamental to the web will take time, but we’re committed to this work and the benefits it will bring to web users globally. The web has evolved into a powerful application platform, enabling anyone with a modern browser to get access to category-leading experiences that load fast and run seamlessly.
[7:11] And devices like Chromebooks show how access to the web could be made affordable, safe, and simple with no need to be an expert at maintaining the underlying operating system. For years, we’ve been on a mission to ensure the web has all of the capabilities needed to bring state-of-the-art computing experiences to the platform. And since we last spoke to you at I/O, the web’s gained a significant array of new capabilities. We'd like to highlight a few of these for you. One area we’ve been working on has been making it easy for users to seamlessly re-engage with web apps.
[7:47] It has been possible for a few years to easily add web apps as icons to native launchers across both mobile and desktop, and it’s one of my favorite platform features. We want to talk about how we’ve deepened this integration between web apps and the underlying OS. With the new app shortcuts feature, web apps can expose quick actions on operating systems that support this feature, such as Android, Chrome OS, Windows, and macOS. And with the Badging API, web apps can give the user a subtle prompt that there’s an opportunity to re-engage by decorating the app’s icon.
[8:24] Soon, we'll be shipping a Chrome origin trial experiment of another new API, Declarative Link Capturing, that enables installed web apps to launch automatically when the user clicks on an appropriate link. This can also prevent multiple instances of the same app from opening so you don’t have like 10 tabs with the same web app in it. We’ve also recently improved Chrome’s web app installation UI. On desktop, we now show an omnibox icon and provide in-product help to explain this feature to users.
[8:57] And on Android, we’ve made the dialogue look richer and more familiar to users, and we’ve made it easy for developers to populate the dialogue with custom images and texts that are specified in the web app’s manifest file. So those are ways that we’re improving the web’s integration with OS launches. We're also adding other OS integrations, such as the Multi-Screen Window Placement API, which allows web apps to discover all of the connected displays and control where the window is placed on those screens.
[9:29] This is actually a pretty handy feature these days for web-based presentation and video conferencing apps. Now web apps can finally read and write to the user's local file system using the File System Access API, enabling apps like Gravit Designer and PhotoBee to provide a much more seamless user experience, persisting state to disk and working with existing files. We’re also working on a new File Handling API that would allow web applications to be registered as file type handlers, enabling users to open files directly in a web app from OS file browsers.
[10:08] We hope to ship an experimental release of this API later this year. Now let’s talk about peripheral devices; things like special-purpose keyboards, game controllers, digital pianos, headsets, and more. Now, the web’s had the ability to communicate with Bluetooth on MIDI devices for a while. But several new APIs now enable support for a broader collection of these devices. Many of these, communicate using the HID protocol. The web now has an API for this in Web HID.
[10:40] Nintendo’s Joy-Con controller is an example of a device that supports this protocol. For gamepad style controllers, the industry standard Gamepad API is now supported by the web as well, and this enables uncompromising gameplay with apps like Stadia in the browser. And you can also use a gamepad to control the Chrome dino in style. The web also now supports serial ports with the Web Serial API. This actually unlocks one of my favorite new use cases: Piper Make.
[11:13] It’s a block-based editor that allows you to program a Raspberry Pi Pico. All you do is simply plug in the device to any computer, open a browser, and off you go. No need to install software or mess with drivers, all thanks to Web Serial. Now with these and other new web capabilities, you can bring deeply integrated, seamless experiences to users everywhere right through the browser. Google Maps holds a special place in our hearts as a singularly influential web app when it first launched over 15 years ago.
[11:46] Maps continues to innovate on the web. Several years ago, they embraced WebGL, enabling hardware-accelerated graphics and delivered a much more powerful Maps UI in the process. Last year, the Maps team enabled those same WebGL-accelerated map capabilities to be used in your web app via the Maps JavaScript API. This year, the team has something new to share. Join me in welcoming Travis McPhail, the team’s engineering lead, who will tell us more about it.
[12:18] We’re constantly amazed by all the ways you’ve used your skill, your creativity, and Google’s knowledge of the real world to build an unbelievable variety of experiences that have truly re-imagined the map. And it's in that spirit today, during the developer keynote, we announced the beta release of two new features that give you unprecedented control of the base map: tilt and rotation, and WebGLOverlayView. With these features, you can manipulate the map in three dimensions for the first time while taking advantage of the power of the same WebGL context we use to render the base map.
[12:57] For the first time ever, you can build not just on top of the map, but you can build with it. Let's take a quick look at how it works. To make things easy, I’m using three.js, a popular web graphics library, to render a 3D object on the map. I've set up a basic web app that loads the map centered on a location in the Yucatán Peninsula of Mexico. And I'm using a map ID so that I can use the vector map and apply some custom styling.
[13:29] The first thing I need to do is implement WebGLOverlayView by extending google.maps.WebglOverlayView. The WebGL overlay exposes a set of hooks into the life cycle of the WebGL rendering context of the base map. For today, we'll keep things as simple as possible and focus on just three of them. The first, onAdd(), is called when the overlay instance is created. The second, onContextRestored(), is called once the rendering context is available.
[14:01] And the third, onDraw(), is what the map and anything else you specify is actually rendered. In onAdd(), I’m going to set up everything that the sscene needs that doesn’t require immediate access to the rendering context. I start by creating a new three.js scene. I also create a camera that represents the view port of the scene. In this case, a perspective camera. Next, the scene needs at least one light source so that any rendered objects are illuminated in the scene.
[14:35] For this example, ambient light is used to equally illuminate all objects in our scene. Now I’m ready to add my 3D object using the GLTFLoader. Once the object is loaded, I scale and rotate it. to have it rendered just right. Then I add it to the scene. In onContextRestored(), I configure the three.js WebGLRenderer, passing it the map’s rendering context and information about the viewport. Once the object renders, I also want to animate the camera to give my users a dynamic view of the object.
[15:13] I called moveCamera in the setAnimationLoop function of the renderer. I also increment tilt, heading, and zoom just a little bit in each frame to create a nice downward spiral motion. All right. Time to render. The three.js camera needs a projection matrix so that it knows how to render latitude and longitude coordinates in the 3D world of the map to the 2D coordinates of the screen. Now, I don’t know about you, but matrix transforms are not my idea of a good time.
[15:47] So, to save you a bunch of math, we hand you a transformer object that has the fromLatLngAltitude function which creates this matrix for you. I pass it the lat-long coordinates where I want the model to appear, and I set the return value as a camera.projectionMatrix. All that’s left is to clear the GL state, tell WebGLOverlayView I want to redraw by calling requestRedraw() on the WebGLOverlayView instance and render the scene.
[16:18] And finally, I create an instance of my class and set the map instance I want it applied to. And this is the result. Not too bad for a few minutes of coding, right? Tilt and rotation and WebGLOverlayView are just the latest way we're delivering on our commitment to you. We have a lot more planned, and we can’t wait to see all the ways you’ll come up with to reimagine the map all over again and show us what’s next. Back to you, Dion. Thanks, Travis.
[16:50] WebGL brought whole new level of graphics performance to the web when it became available several years ago. We are currently working closely with the graphics and web communities on WebGPU, the new next-generation graphics API, designed from the ground up to unlock a whole new level of graphics performance on the web. Taking inspiration from low-level APIs like Vulcan, Metal, and Direct 3D 12, WebGPU is still very experimental that holds exciting promise for the future.
[17:22] Another key performance technology is Web Assembly, which provides a standard for compiling code to a fast and efficient format that can be executed in the browser by modern JavaScript engines like V8. We recently gave Web Assembly a major performance boost by implementing support for SIMD processor instructions in V8, which enables certain classes of apps to run much faster. Google Meet provides a powerful example SIMD in action. Like any video conferencing app, Meet has to pay careful attention to their performance budget.
[17:55] And there’s a constant tension between processing the video in order to enhance it and maintaining a smooth, low-latency stream. Using V8′s experimental origin trial of SIMD, the Meet team achieved a 200% performance gain on their in-browser media processing pipeline. And this in turn, gave them the budget to enable a background blur feature for most of their users that was powered by TensorFlow in the browser. We’re planning to ship SIMD to all Chrome users in the coming months.
[18:26] Now, Web Assembly is also frequently used to bring non-JavaScript codebases to the web, unlocking them for new use cases. For example, the developers behind the offline-first sync engine, Replicache, were able to compile their Rust code to Web Assembly, enabling web developers to seamlessly incorporate it into their web app. To ease with code porting, V8 added threading support to Web Assembly back in 2019. But it was only enabled for desktop operating systems.
[18:57] We’re pleased to share today that Chrome for Android gained Web Assembly threads as of Chrome 88 in January of this year. We’ve also enhanced V8′s Web Assembly debugging experience with support for breakpoints and variable inspection right there in Chrome DevTools. We’re so excited to see what you deliver with a universal runtime that works on client or server is san bugs, and wicked fast. That's Web Assembly. The V8 team has also been hard at work at squeezing even more JavaScript performance out of its engine.
[19:31] So in addition to interpreting JavaScript, V8 also compiles code on the fly for more efficient execution. And the team has implemented a whole new compiler called Sparkplug. Of course, sometimes the best way to improve code execution performance is to not execute any code at all. In this spirit, earlier this year, we shipped a new Chrome feature to some users called intensive timer throttling that detects when a browser tab has been in the background for more than five minutes and as long as the tab isn’t playing any audio or video, Chrome slows down how frequently it executes timer-based JavaScript code on that tab.
[20:10] We've also applied this concept with CSS by shipping support for a new CSS property called content-visibility. When you set this property to auto on an element, you’re giving the browser permission to skip rendering the contents of that element tree if it isn’t currently visible on the user’s display, and this can lead to a dramatic speed boost for content-heavy sites. Now, there’s a ton of innovation happening on the web platform to enable significantly faster runtime performance of your web apps.
[20:40] In addition to the work happening to expand the power and performance of the web, the platform’s also evolving to deliver an instant and seamless experience for users. In Chrome 87, released in November last year, we added a so-called back/forward cache to Chrome on Android, or BFCache for short. BFCache keeps some web pages loaded in memory after you’ve navigated away from them. So if a user clicks back or forward, the page is displayed instantly. And it turns out, one in five navigations on mobile are doing exactly that, moving backwards or forward through the history stack.
[21:18] So this feature drives a really big impact. While today, Chrome’s BFCache implementation is available on Android, it does have some limitations. We are planning to expand it to the Chrome desktop platform soon. Another way we’re expanding instant experiences is by revisiting the notion of pre-rendering pages. Pre-rendering is the technique of loading all of a webpage’s resources and even rendering the DOM before the user clicks on a link So it can be displayed truly instantly.
[21:48] Now this is hard to get right because pre-loading these pages can also cause side effects, if the page does something like sign out or if the page plays audio, then it can also start playing in a mysterious way. Also, it can leak some user information if it's done across sites. But when pre-rendering is done right, it provides this powerful, instant click-through experience for the user. So, we’re working on new approaches to pre-rendering that are private and safe. One of these involves a new pre-rendering API that would enable developers to experiment with this on same site pre-loading later this year.
[22:26] And transitions are another important aspect of the user experience, ensuring that users are able to shift their context as they navigate the web and get right to where they want to go. One fun, simple feature with a big impact is scroll to text, added to Chrome 80 in February of last year. By adding a new type of expression to the end of your URL, browsers can position the viewport to a specific text element and highlight it in some way. Soon we’ll be shipping a version of this API that scrolls to images, and we're exploring other element types too.
[22:59] With the new document transition APIs that are coming to Chrome soon as experiments, we’re also building in support for a number of graphical transitions between elements, enabling the user to perceive a seamless experience as they move between states of your web app. We're also working to make security more seamless on the web. One feature I’m particularly excited about is cross-device one-time passwords for the web. One-time passwords are these numeric codes that some sites can send you to log in.
[23:31] This feature enables you to receive one of these one-time passwords on your Android phone, and then have that automatically transferred to your Chrome browser running on some other device like a laptop. All of these new web capabilities are exciting. But as the pace of web evolution accelerates, so too does the complexity we face as web developers in keeping track of everything. We’re working to make the web easier for developers and partnering with the broader ecosystem to understand and address the platform's top pain points.
[24:03] To understand our latest recommendations for web development, visit web.dev. The site includes detailed tutorials on key topics, the latest news, and it also provides access to our Lighthouse website auditing tool. Now, with Lighthouse, you get a comprehensive report on how to improve your website, across a variety of categories such as performance, accessibility, and SEO. We continually update Lighthouse guidance to give you the very best insights we can.
[24:35] We found that three of Lighthouse’s performance metrics are particularly impactful on the user experience. We call these Core Web Vitals. And collectively, they measure how fast a site displays key content, how responsive the site is for the first interaction, and how much the site’s layout shifts around. Sites across the web were using Core Web Vitals as a North Star for performance and are reporting encouraging results. For example, the Italian publisher GEDI saw an 8% improvement in the bounce rate on their mobile article pages.
[25:13] They did this by implementing a branded placeholder in order to reserve space for ads in their ad slots on the page, which improved their layout stability, and then by deferring loading of some their JavaScript code until after the page was visible, they improved the perceived page loading speed. Web content and commerce platforms. are also investing in Core Web Vitals to improve the performance of all of their hosted sites. For example, Shopify and Wix implemented dashboards in their admin console that puts performance front and center for site owners.
[25:49] The WordPress community has also shipped performance-oriented additions, such as lazy loading for images and iframes. We’ve also updated Site Kit, Google’s official plugin for WordPress, with support for measuring Core Web Vitals, and it also makes specific improvement recommendations to developers. Google Search has also announced that Core Web Vitals will soon be a part of how pages are ranked in search results. We think this is particularly exciting, as it magnifies the benefit of Core Web Vitals to you, the developer.
[26:21] The investment will not only give your users a better experience, but it will help them find your site through such. We spent a good amount of time listening to developers, both in small gatherings and through scaled developer surveys. One of the common themes we consistently hear is the importance to developers of cross-browser compatibility. So this year, we recently announced our participation in a cross-industry effort called Compat2021, which aims to fix the top five browser compatibility pain points as voted on by web developers, which, shockingly, all happen to be CSS related.
[27:00] And speaking of CSS, we’re seeing an exciting renaissance in this area. We even have our own modern-day zen garden. CSS Flexbox and Grid have been embraced by developers as major improvements for creating page layouts, and learnings from years of CSS frameworks like Sass are being baked into the platform, such as nesting. And along with container queries, which is your most requested feature, I think, for CSS, you will be able to create style sheets that are more modular and reusable by enabling rules that are scoped naturally to their local context versus acting so globally.
[27:37] Now, one of Chrome’s most popular features is its suite of built-in developer tools, which give you an incredibly powerful toolkit that can function as your web development copilot. Over the past year, we’ve enhanced DevTools with a bevy of new improvements ranging from a new color picker, improved warnings and linting of PWAs, a Core Web Vitals overlay, dedicated CSS Flexbox debugging, dropped frame visualization, support for CSS and JavaScript, and much more.
[28:09] And DevTools is also a platform because it supports extensions. And one example of a new extension is the Angular DevTools Chrome extension, which provides debugging and performance profiling support that’s specific to Angular apps. So check out our Chrome DevTools session to deep dive into all of this and learn more about our new DevTools features. The web is evolving in fundamental ways so it doesn’t become extinct. It’s becoming private by default with new APIs that protect user privacy, and it also continues to gain powerful new capabilities that broaden what’s possible on the platform, providing for better user experiences.
[28:51] Lastly, we’re committed to partnering with you in the ecosystem as the web evolves to make sure that you’ve got all of the tools and guidance for success. You can dive deeper into many of these improvements across the web platform by checking out a number of other sessions, many of which we’ve highlighted today, at this year’s I/O. Thanks for your time, and we look forward to seeing what you build with the evolved capabilities of the modern web. And if you’re watching this during I/O Week, come find us in Adventure. Thanks.
在Vidleaf工作台中打开
搜索转录文本,选择行,复制带时间戳的引文,翻译。
署名
“网络平台的新动态 | 主题演讲”,作者 Chrome for Developers(https://www.youtube.com/@chromedevs),依据 CC BY 3.0 许可(https://creativecommons.org/licenses/by/3.0/)。源视频:https://www.youtube.com/watch?v=0UiaD059eqM。本页面是视频的文字转录,添加了段落分隔和时间戳;创作者与 Vidleaf 无关联,也不为其背书。Vidleaf 添加了 AI 标点和 AI 生成的摘要;原始措辞仍可在本页面上查看。
您是创作者或权利持有人吗?请求更正或移除:copyright@vidleaf.app(参见关于这些页面)。
最后更新于