DSH / Atlas
2026-10-18implementedarchitecture

Frame-forwarding channels with transferable credentials, producer-local handles, covered views, and a memory-sized budget

带可转交凭据、生产者自有句柄、被遮挡视图和按内存定额预算的帧转发通道

A frame-forwarding view authorized one producer process. The Host plugin started the producer, passed it a private endpoint, and called `bind(viewId, pid)`; the receiver accepted only that PID, could not be rebound, and failed the view when the producer disconnected. Replacing a producer therefore meant a new receiver, a new view identifier, and a new renderer consumer: the Office preview's CPU restart rebuilt the wh

English

Problem

A frame-forwarding view authorized one producer process. The Host plugin started the producer, passed it a private endpoint, and called bind(viewId, pid); the receiver accepted only that PID, could not be rebound, and failed the view when the producer disconnected. Replacing a producer therefore meant a new receiver, a new view identifier, and a new renderer consumer: the Office preview's CPU restart rebuilt the whole path, a crashed engine took its view with it, and the parent had to know the child's PID before the child connected. A PID is also a poor authorization identity: the operating system reuses it, it names a process rather than a holder of authority, and a successor process of the same feature cannot inherit it.

Once any process holding a channel's credential may connect a producer, what such a producer can do to the Host matters. On Windows a producer duplicated each frame's NT handle into the receiver's process and sent the resulting value, and the receiver treated whatever value arrived as a handle of its own. A packet with a forged value therefore made the Host open that handle as a texture or, on an error path, close it, whichever Host object it named. The same scheme also required the producer to hold PROCESS_DUP_HANDLE on the Host, which an engine running in a sandbox below the Host's integrity level cannot obtain.

All channels of the window share one byte budget, granted first come, first served. A producer whose view was hidden stopped rendering but kept its idle pooled surfaces and its pending requests, so a visible view could wait behind a hidden one for budget nobody was using. While one view occupied the screen in a slideshow, the views it covered kept rendering frames nobody could see, and nothing told frame forwarding which channel covered the others.

The budget was also a fixed 256 MiB, at most 1 GiB, whatever the machine. A channel streaming 4K frames holds up to three 3840×2160 surfaces of 31.64 MiB each, so two such channels filled it, and on the Windows relay path, which also reserves three target textures and two staging textures per channel, a 4096-pixel-wide slideshow frame exceeded the share one allocation may take.

Decision

Channels and credentials

A receiver is a logical channel with two halves. The Host plugin calls frameForwarding.channel() and receives { tx, rx }: tx is an opaque, serializable credential that any process holding a copy may present, and rx is the receive identity the renderer passes to frameForwarding.connect(rx). close(rx) closes the channel permanently and withdraws the credential, and a channel also closes when the Cordis scope that read the service is disposed. bind, bindProducer, and the receiver's permanent expected PID no longer exist; the OS-reported peer process is checked per physical connection only for packet origin and handle duplication. The credential never reaches a renderer, a log, or a diagnostic.

Connections and handoff

A channel serves one connection at a time and moves Idle → Active(N) → Draining(N) → Idle → Active(N+1); Closed and Failed are reachable from every state. Connection IDs increase and are never reused; ready carries N, and every later packet is checked against it. While N is connected, other candidates are refused as channel-busy, and N is never preempted, even when it stops responding. After N disconnects by goodbye, error, or process exit, N keeps its frames, allocations, budget, relay state, and submitted GPU work until each is released. During that drain one authenticated successor waits for ready within its own deadline and cancellation, and others are refused. Frames and allocations are keyed by connection, delivery IDs stay unique within the channel, credit returns only to the frame's own connection, and a late release of N returns nothing to N+1. GPU work whose completion is unknown keeps its resources and reports drain-blocked; no timeout ends a drain. On macOS each connection has its own Mach ports, delivered in ready; on Windows each connection uses its own pipe instance; a failed handshake closes only its candidate. A producer's close() completes once its own sender is closed, and the successor's ready completes the handoff.

Producers name only their own handles

The hello capability producer-local-handles declares that every handle a producer names belongs to it. On Windows a frame carries a handle value in the producer's process. When a pipe client connects, the receiver opens that process with PROCESS_DUP_HANDLE | SYNCHRONIZE from GetNamedPipeClientProcessId, and it duplicates each frame's value from there. A value that names no handle of a live producer ends that connection as "sent a handle it does not own" without touching any Host handle; a producer that already exited took its handles with it, and its connection ends as lost. A hello that carries a handle is dropped, and the producer side never interprets a received value. macOS keeps Mach port transfer, where the kernel names the right in the receiver.

Compatibility

Channels change no wire protocol version, constant, packet layout, or endpoint prefix; they add hello capability bits that both sides check. The current wire protocol, version 2, sends each packet as a fixed header followed by only the bytes of its text and requires the same capabilities. The hello declares transferable-tx and producer-local-handles. Ready carries the connection ID in its token field and, in ready.stride, unused before, echoes the capabilities the receiver accepted. A receiver refuses a producer without transferable-tx as transferable-tx-required, one without producer-local-handles as producer-local-handles-required, and a producer of another version as protocol-mismatch, naming both versions. A producer refuses a ready without a connection ID or without the producer-local-handles echo, so neither side of a mixed build sends or reads a handle value under the other rule. Build records (the Kit's sdk.json, receipt.json, and prebuild manifests, and DSH's frame-forwarding.json) list capabilities: ["transferable-tx", "producer-local-handles"], and their loaders and verifiers reject artifacts without both, so a matching version number alone never passes a compatibility check. Desktop preinstalls the receiver. The Kit 0.2.3 engine is a protocol 1 producer, which the protocol 2 receiver refuses as protocol-mismatch.

Host and renderer

The Host keeps the renderer's latest viewport per channel, sends it to each new connection, and presents frames only from the current connection, up to the latest viewport's version. The gate opens before the viewport is sent, because the receiver judges a frame in native code, possibly before the Host's JavaScript handles the acknowledgement that preceded it. A viewport request belongs to the connection that received it and reports producer-changed when that connection ends; a timeout fails the request and keeps the channel. Each event-stream subscription starts with a snapshot of every channel's state, then carries states with increasing sequence numbers and producer errors. Frame metadata carries connectionId beside generation, which remains the viewport version. A FrameRx streams the latest frame across producer switches. Frames whose connection state has yet to arrive wait within the channel's frame limit, and the renderer releases frames from earlier connections. Native producers can still use dsh_frame_forwarding_submit for ordered delivery or dsh_frame_forwarding_submit_latest for replaceable frames. ready() resolves once a producer acknowledged the latest viewport.

On invalidated, which Desktop's settlement reports when the document, renderer, or GPU process went away first, the bridge queues the notice, then stops the receiver and the frame's connection before releasing the delivery, so its producer never writes that texture again; the forwarder closes the channel as lost when it handles the notice. A producer disconnect, by contrast, drains and hands over.

Hidden and covered views return their surfaces

A consumer sends its next viewport version with visible: false whenever its view is hidden or covered. The producer SDK's dsh_frame_forwarding_trim deallocates every surface that is neither acquired nor submitted: available surfaces, the queued latest frame, granted allocations not yet created, and pending requests; on Windows it then flushes the producer's D3D11 context, because D3D11 destroys a released texture only at the next flush. The Kit engine trims after acknowledging an invisible viewport, so its allocations return to the shared budget, and its next visible frame requests them again.

The window budget follows physical memory

maxBytes: auto, the default, resolves to half of physical memory and at least 256 MiB when the first channel opens; no budget exceeds physical memory, and a larger byte count is reduced to it with a Host warning. Sizing waits for the first channel because a Host that never loads the receiver, such as the browser worker deployment, cannot read physical memory. The budget is a ceiling, not a reservation: each channel still holds at most maxFrames surfaces, so a larger budget lets more channels hold surfaces at once without enlarging any of them. A producer whose allocation does not fit waits until other channels return surfaces; its channel stays open, and its consumer keeps what it shows and draws a placeholder where content has not arrived.

Fullscreen belongs to frame forwarding

A receive channel shows its consumer's element fullscreen through the document's Fullscreen API with FrameRx.requestFullscreen(element), which the consumer calls before its click handler awaits anything. One channel holds fullscreen at a time. Every other channel learns { active: true, holder: false } and treats its view as covered; the holder learns active: false when the fullscreen ends, including on Escape; closing the holding channel or disposing the Client leaves its fullscreen. Desktop exposes no window control of its own (shared-texture API).

Each document view runs its Host operations in arrival order, and different views run concurrently, so a view that waits for frame surfaces delays only its own later operations. A frame that misses frameTimeoutMs, or the Kit engine's own report that no frame surface became free, does not fail the view: tiles and page previews request their frame again once the late request settles, a slideshow keeps its stream, and the view keeps its retained tiles, page previews, or last slideshow frame, draws a checkerboard where nothing has arrived, and says that it waits for graphics memory until a frame draws.

Alternatives considered

Rebind the receiver to a successor's PID. This keeps the PID as authority, still requires the parent to learn the child's PID before it connects, and needs a new bind call for crash takeover.

Preempt a connected producer after a timeout. A stalled producer may still own GPU work on the channel's textures, so preemption would hand those textures to a successor while they are in use. Only the operating system's disconnect or the producer's own close starts a drain.

Connect the successor at once and keep the old connection's frames separately. Two producers would share one channel's budget and frame limit, and the renderer would interleave their frames. Draining first keeps one producer's resources and credit in flight at a time.

Open a new channel per producer, as before. Every producer switch would replace the renderer's consumer and lose its viewport and stream subscription.

Mark channels with a new wire protocol version. Channels change no packet layout; capability bits that both sides check refuse mixed builds as well, and the frame-forwarding README promises that within a version the wire changes only by such capabilities.

Return invalidated textures through a drain. Desktop cannot observe their remaining references, so a successor could write a texture a stale document still reads; a closed channel is the only state in which releasing them is safe.

Validate the received value before use. The receiver could check that a value names a shared D3D11 texture. That checks the object's type, not its owner: a forged value naming another channel's texture or any other shared object of the Host passes, and error paths still release the value.

Keep producer-side duplication and verify it in the receiver. The receiver cannot tell a value the producer duplicated in from a value it guessed without the producer's handle table, and the producer would still need PROCESS_DUP_HANDLE on the Host, which a sandboxed engine lacks.

A new wire message that pauses covered producers. Viewport visibility already tells a producer to stop rendering, carries a version the Host orders, and reaches each new connection through the viewport replay, so a separate pause message would duplicate it.

Per-channel byte caps or a channel count limit. Trimming covered views and closing channels with the scope that opened them handle the observed contention; on the Windows relay path the budget formula would make a low cap block a 4K slideshow. Deferred until a measurement shows the need.

Fullscreen the document element and keep the slideshow overlay on document.body. The application chrome would then share the fullscreen screen, including the Windows menu and caption controls that need their own fullscreen handling, and frame forwarding could not name the covering view.

Keyboard Lock. Letting a holder keep Escape suits games, not slideshows, and is deferred until a consumer needs it.

Keep a fixed default budget. 256 MiB held two 4K streams on the shared-texture paths and refused a 4096-pixel-wide frame on the relay path, however much memory the machine had.

A quarter of physical memory, the ceiling Chromium sets for a renderer's tile memory. Half lets more views render at once, which suits using whatever the machine has, and still stays below the working set Metal recommends, about two thirds to four fifths of unified memory.

95% or 100% of physical memory. The operating systems' graphics limits are lower: WDDM lets graphics use min(80%, max(RAM − 16 GB, 50%)) of system memory, and Metal's recommended working set is the fraction above. The same memory also holds the engines, Chromium, and other applications. Frame forwarding would never refuse first: exhaustion would surface wherever the operating system fails an allocation, for example in Chromium's GPU process, whose exit closes every channel, and nothing would bound the frame memory producers make the Host and the GPU process hold.

Fail a view whose frame misses its deadline. A missing allocation is usually temporary: hiding, covering, or closing another view frees it, while a failed view waits for the user to retry.

Run every Office operation in one Host queue. A view waiting for frame surfaces would hold every other document's operations for the engine's whole wait, and opening one document would stall the others.

Tell a budget wait from a stalled engine. The receiver does not report a pending grant to the Host, and distinguishing that state would require a new producer-to-Host diagnostic; an engine that stops answering still ends at operationTimeoutMs.

Size the budget from the operating system's GPU budget (DXGI QueryVideoMemoryInfo, Metal recommendedMaxWorkingSetSize). It would follow dedicated video memory, which physical memory does not show, but requires platform-specific native queries in the receiver.

Verification

The Kit's transport tests and DSH's receiver native e2e connect a separate producer process with a copied credential and cover busy refusal, a waiting successor, deadline expiry, crash takeover, IDs reused across connections with late releases, mixed-build refusals in both directions including a producer built without producer-local-handles and a ready without the echo, budget return after repeated handoffs, and a trimmed producer's allocation passing to another channel sharing its budget. On Windows the Kit's tests close the connection of a producer that sends a receiver handle's value while that sentinel handle stays valid, and show the trimmed textures' video memory freed through the shared-texture and relay paths; the serialized native suite passes on macOS arm64, two Windows x64 hardware hosts, and Windows ARM64. The Kit frames e2e hands a real Office engine's channel to a replacement and, after a crash, to a successor, renders two engines on two channels at once, and trims an invisible engine's surfaces. Unit specs cover the Host's viewport replay and connection-bound requests, the renderer's snapshot and sequence handling and early-frame ordering, the wire adapter and receive channel with the single fullscreen holder, coverage events, exits during a pending entry or after Escape, and exits on close and disposal. The service specs cover auto at half of physical memory, its 256 MiB floor, and the refused load of a budget above physical memory.

Consequences

Producer replacement and crash takeover keep the channel, the renderer's consumer, and the viewport, and need no PID: a parent hands over a string. In exchange, every protocol 1 receiver, producer, engine, and build record must be upgraded together, and older builds are refused explicitly: Kit 0.2.2 and earlier producers and receivers cannot interoperate with these sources in either direction, so the Kit, its engines, and Desktop, which compiles the receiver when it packages, upgrade together. A stalled producer that stays connected blocks its channel until it exits or the channel closes, and a successor waits for Desktop and its consumers to release the previous producer's frames. A GPU-process exit closes the channels that had frames on screen, and its consumer must open a new channel instead of continuing on the old one. A producer must keep a sent handle open until the receiver reads the frame, and a producer that exits right after submitting loses that frame with its connection. An engine sandboxed below the Host's integrity level keeps working, since only the Host opens the other process; conversely a producer elevated above the Host, which the Host cannot open, cannot connect, and the receiver closes it during the handshake without a Host diagnostic. A view that becomes visible again waits for an allocation grant before its first frame, and trimming returns frame surfaces only, not an engine's own renderer caches. Escape always leaves fullscreen, and coverage is per document: a fullscreen element of the document covers every receive channel except the holder's. On Windows machines with 32 GB or less, half of physical memory equals the system memory WDDM lets graphics use, so the operating system's limit can be reached there before the budget; a discrete GPU keeps frames in its dedicated memory, which the budget does not see, and WDDM pages rather than fails when that memory runs out.

中文

Problem

帧转发视图只授权一个生产者进程。Host 插件启动生产者,向其传递私有端点,再调用 bind(viewId, pid);接收端只接受该 PID,不能重新绑定,生产者断开时视图随之失败。因此替换生产者意味着新的接收端、新的视图标识和新的渲染端消费者:Office 预览的 CPU 重启要重建整条路径,引擎崩溃会带走其视图,父进程还必须在子进程连接前得知其 PID。PID 也不适合作为授权身份:操作系统会复用 PID,它指代进程而非权限持有者,同一功能的后继进程也无法继承它。

一旦任何持有通道凭据的进程都能连接生产者,这样的生产者能对 Host 做什么就变得重要。在 Windows 上,生产者把每帧的 NT 句柄复制进接收端进程并发送复制后的值,接收端则把收到的任何值都当作自身的句柄。因此,带有伪造值的包会让 Host 把该句柄当作纹理打开,或在出错路径上关闭它,无论它指向 Host 中的哪个对象。这一方案还要求生产者持有 Host 的 PROCESS_DUP_HANDLE 权限,而在低于 Host 完整性级别的沙箱中运行的引擎拿不到该权限。

窗口内所有通道共享一个按先来先得授予的字节预算。视图被隐藏的生产者虽停止渲染,却仍保留其空闲池中的 surface 和尚在申请中的分配,于是可见视图可能排在隐藏视图之后,等待一份无人使用的预算。放映时一个视图占满屏幕,被它遮挡的视图仍在渲染无人可见的帧,帧转发也无从知道是哪个通道遮挡了其他通道。

预算还固定为 256 MiB,最多 1 GiB,与机器无关。传输 4K 帧的通道最多持有三个 3840×2160、每个 31.64 MiB 的 surface,两个这样的通道就能占满预算;在 Windows 中继路径上,每个通道还要预留三个目标纹理和两个暂存纹理,一个 4096 像素宽的放映帧超出了单次分配可占的份额。

Decision

通道与凭据

接收端是一个由两半组成的逻辑通道。Host 插件调用 frameForwarding.channel() 得到 { tx, rx }:tx 是不透明、可序列化的凭据,任何持有副本的进程都可出示;rx 是接收身份,渲染端将其传给 frameForwarding.connect(rx)。close(rx) 永久关闭通道并撤回凭据;读取该服务的 Cordis 作用域销毁时,通道也随之关闭。bind、bindProducer 和接收端永久的预期 PID 已不存在;操作系统报告的对端进程仅按物理连接用于检查数据包来源和句柄复制。凭据从不进入渲染端、日志或诊断信息。

连接与交接

通道同一时间只服务一个连接,状态依次为 Idle → Active(N) → Draining(N) → Idle → Active(N+1);任何状态都可进入 Closed 或 Failed。连接 ID 递增且永不复用;ready 携带 N,之后每个数据包都按其校验。N 在线时,其他候选连接以 channel-busy 被拒绝,N 即使停止响应也不会被抢占。N 因 goodbye、错误或进程退出而断开后,其帧、分配、预算、中继状态和已提交的 GPU 工作一直保留到各自释放。排空期间,一个通过认证的后继在自身截止时间和取消条件内等待 ready,其余候选被拒绝。帧和分配按连接区分,交付 ID 在通道内保持唯一,信用只返还给帧所属的连接,N 迟到的释放不会给 N+1 返还任何东西。完成情况未知的 GPU 工作保留其资源并报告 drain-blocked;不存在结束排空的超时。macOS 上每个连接拥有自己的 Mach 端口,随 ready 交付;Windows 上每个连接使用独立的管道实例;握手失败只关闭该候选连接。生产者的 close() 在本地发送端关闭后完成,后继的 ready 标志交接完成。

生产者只指名自己的句柄

握手能力 producer-local-handles 声明生产者指名的每个句柄都归它所有。在 Windows 上,帧携带的是生产者进程中的句柄值。管道客户端连接时,接收端根据 GetNamedPipeClientProcessId 以 PROCESS_DUP_HANDLE | SYNCHRONIZE 打开该进程,并从那里复制每一帧的值。若值不对应仍在运行的生产者的任何句柄,该连接以“sent a handle it does not own”结束,且不触碰任何 Host 句柄;已退出的生产者带走了自己的句柄,其连接以丢失结束。携带句柄的 hello 会被丢弃,生产者一侧从不解读收到的值。macOS 保留 Mach 端口传递,由内核在接收端中为端口权限命名。

兼容性

通道不改变通信协议的版本、常量、数据包布局或端点前缀,只增加双方都检查的 hello 能力位。当前的通信协议为版本 2,每个数据包由固定的包头加上仅含其文本字节的部分组成,并要求同样的能力。hello 声明 transferable-tx 和 producer-local-handles。ready 在 token 字段中携带连接 ID,并在此前未使用的 ready.stride 中回显接收端接受的能力。接收端以 transferable-tx-required 拒绝不带 transferable-tx 的生产者,以 producer-local-handles-required 拒绝不带 producer-local-handles 的生产者,并以写明双方版本的 protocol-mismatch 拒绝其他版本的生产者。生产者拒绝不含连接 ID 或未回显 producer-local-handles 的 ready,因此混合构建的任一方都不会按另一套规则发送或读取句柄值。构建记录(Kit 的 sdk.json、receipt.json 和预构建清单,以及 DSH 的 frame-forwarding.json)列出 capabilities: ["transferable-tx", "producer-local-handles"],其加载器和校验器拒绝缺少其中任一能力的产物,因此仅版本号相同永远无法通过兼容性检查。Desktop 预装接收器。Kit 0.2.3 引擎是协议 1 的生产者,协议 2 的接收器以 protocol-mismatch 拒绝它。

Host 与渲染端

Host 按通道保存渲染端最新的视口,发送给每个新连接,并且只呈现当前连接 generation 不超过最新视口版本的帧。门控在视口发出之前就已打开,因为接收器在原生代码里判定帧,可能早于 Host 的 JavaScript 处理排在该帧之前的确认。视口请求属于接收它的连接,该连接结束时报告 producer-changed;超时只让该请求失败,通道保留。每个事件流订阅先收到所有通道状态的快照,随后收到带递增序号的状态和生产者错误。帧元数据在 generation(仍为视口版本)旁携带 connectionId。FrameRx 在生产者切换后继续交付最新帧。连接状态尚未到达的帧在通道帧上限内等待,渲染端释放更早连接的帧。原生生产者仍可通过 dsh_frame_forwarding_submit 按序提交帧,或通过 dsh_frame_forwarding_submit_latest 提交可替换的帧。ready() 在生产者确认最新视口后完成。

Desktop 的结算在文档、渲染进程或 GPU 进程先行消失时报告 invalidated;收到它时,桥先把通知排入队列,再停止接收器和该帧所属的连接,然后释放交付,因此其生产者不会再写入该纹理;forwarder 处理该通知后以 lost 关闭通道。相比之下,生产者断开则排空后交接。

隐藏和被遮挡的视图归还 surface

视图被隐藏或遮挡时,消费者以下一个视口版本发送 visible: false。生产者 SDK 的 dsh_frame_forwarding_trim 释放所有既未被获取也未被提交的 surface:可用的 surface、排队中的最新帧、已获批但尚未创建的分配,以及尚在申请中的分配;在 Windows 上它随后刷新生产者的 D3D11 上下文,因为 D3D11 只在下一次刷新时销毁已释放的纹理。Kit 引擎在确认不可见视口后执行收缩,使其分配回到共享预算,下一个可见帧再重新申请。

窗口预算随物理内存确定

默认值 maxBytes: auto 在第一个通道打开时解析为物理内存的一半,且不低于 256 MiB;任何预算都不超过物理内存,更大的字节数降为物理内存并在 Host 日志中警告。预算等到第一个通道才确定,因为从不加载接收器的 Host(例如浏览器 worker 部署)读不到物理内存。预算是上限而非预留:每个通道仍最多持有 maxFrames 个 surface,因此更大的预算让更多通道能同时持有 surface,而不会让任何一个通道变大。分配放不进预算的 producer 会等待其他通道归还 surface;其通道保持打开,它的消费方保留已显示的内容,并在内容尚未到达处绘制占位。

全屏归帧转发所有

接收通道通过文档的 Fullscreen API,以 FrameRx.requestFullscreen(element) 全屏显示其消费者的元素;消费者须在点击处理函数 await 任何东西之前调用它。同一时间只有一个通道持有全屏。其他每个通道收到 { active: true, holder: false },并将其视图视为被遮挡;全屏结束时(包括按 Escape),持有者收到 active: false;关闭持有全屏的通道或销毁 Client 都会退出其全屏。Desktop 自身不暴露任何窗口控制(共享纹理 API)。

每个文档视图的 Host 操作按到达顺序执行,不同视图并发执行,因此等待帧 surface 的视图只会推迟它自己后续的操作。错过 frameTimeoutMs 的帧,或 Kit 引擎自身报告没有空闲的帧 surface,都不会让视图失败:图块和分页预览在迟到的请求结束后重新请求其帧,放映保留其流;视图保留已保存的图块、分页预览或放映的最后一帧,在尚无内容处绘制棋盘格,并提示正在等待图形内存,直到有帧绘制出来。

Alternatives considered

把接收端重新绑定到后继的 PID。 这仍以 PID 作为权限,父进程仍须在子进程连接前得知其 PID,崩溃接管也需要新的绑定调用。

超时后抢占在线的生产者。 停滞的生产者可能仍持有作用于通道纹理的 GPU 工作,抢占会在纹理仍被使用时把它们交给后继。只有操作系统的断开或生产者自身的关闭才开始排空。

立即连接后继,并单独保留旧连接的帧。 两个生产者会共用一个通道的预算和帧上限,渲染端会交错收到双方的帧。先排空保证同一时间只有一个生产者的资源和信用在途。

像以前一样为每个生产者打开新通道。 每次切换生产者都会替换渲染端的消费者,并丢失其视口和流式订阅。

为通道启用新的通信协议版本。 通道不改变数据包布局;双方都检查的能力位同样能拒绝混合构建,帧转发 README 也承诺同一版本内的线上协议只通过这类能力演进。

通过排空归还已失效的纹理。 Desktop 无法观察这些纹理剩余的引用,后继可能写入过期文档仍在读取的纹理;只有通道关闭后释放它们才安全。

使用前校验收到的值。 接收端可以检查该值是否指向共享的 D3D11 纹理。但这只检查对象的类型而非归属:指向另一通道纹理或 Host 中其他共享对象的伪造值仍能通过,出错路径也仍会释放该值。

保留生产者一侧的复制,由接收端验证。 没有生产者的句柄表,接收端无法区分生产者复制进来的值与猜测的值;生产者也仍需持有 Host 的 PROCESS_DUP_HANDLE 权限,而沙箱中的引擎没有该权限。

新增一条暂停被遮挡生产者的线上消息。 视口的可见性已经告诉生产者停止渲染,携带由 Host 排序的版本,并通过视口重放到达每个新连接,因此单独的暂停消息与之重复。

每通道字节上限或通道数上限。 收缩被遮挡的视图、通道随打开它的作用域一起关闭,已能处理观察到的争用;在 Windows 中继路径上,预算公式会让较低的上限卡住 4K 放映。等测量证明需要时再做。

让文档根元素全屏,并把放映浮层保留在 document.body。 这样应用界面会一起占用全屏屏幕,其中包括需要另行处理全屏的 Windows 菜单和标题栏按钮,帧转发也无法指明是哪个视图在遮挡。

Keyboard Lock。 让持有者保留 Escape 适合游戏而不适合放映,等有消费者需要时再做。

保留固定的默认预算。 无论机器有多少内存,256 MiB 在共享纹理路径上只能容纳两路 4K 流,在中继路径上会拒绝 4096 像素宽的帧。

物理内存的四分之一,即 Chromium 为渲染进程 tile 内存设的上限。一半能让更多视图同时渲染,契合尽量使用机器已有资源的目标,并且仍低于 Metal 建议的工作集,约为统一内存的三分之二到五分之四。

物理内存的 95% 或 100%。 操作系统的图形上限更低:WDDM 允许图形使用 min(80%, max(RAM − 16 GB, 50%)) 的系统内存,Metal 建议的工作集即上述比例。同一份内存还要容纳引擎、Chromium 和其他应用。帧转发将永远不会先拒绝:耗尽会出现在操作系统让分配失败的地方,例如 Chromium 的 GPU 进程,其退出会关闭所有通道;producer 让 Host 和 GPU 进程持有的帧内存也将不受任何约束。

帧错过期限时让视图失败。 分配不足通常是暂时的:隐藏、遮挡或关闭另一个视图就能释放它,而失败的视图要等用户重试。

让所有 Office 操作走同一个 Host 队列。 等待帧 surface 的视图会在引擎整个等待期间挡住其他所有文档的操作,打开一个文档也会让其他文档停顿。

区分预算等待与停滞的引擎。 接收器不会向 Host 报告尚未批准的分配,区分这种状态需要新增一项从生产者到 Host 的诊断;停止响应的引擎仍会在 operationTimeoutMs 到期时结束。

按操作系统的 GPU 预算确定预算(DXGI QueryVideoMemoryInfo、Metal recommendedMaxWorkingSetSize)。它能跟随物理内存反映不出的独立显存,但需要接收器调用各平台的原生 API 查询 GPU 预算。

Verification

Kit 的传输测试和 DSH 的接收器原生 e2e 用复制的凭据连接独立的生产者进程,覆盖忙碌拒绝、等待中的后继、截止时间到期、崩溃接管、跨连接复用 ID 及迟到释放、双向的混合构建拒绝(包括不具备 producer-local-handles 的生产者和未回显能力的 ready)、多次交接后的预算归还,以及被收缩的生产者的分配交给共享其预算的另一个通道。在 Windows 上,Kit 的测试会在生产者发送接收端句柄的值时关闭其连接,而该哨兵句柄保持有效,并显示经共享纹理和中继两条路径收缩的纹理释放其显存;串行的原生测试套件在 macOS arm64、两台 Windows x64 硬件主机和 Windows ARM64 上通过。Kit 帧 e2e 把真实 Office 引擎的通道交给替代引擎,并在崩溃后交给后继;它还在两个通道上同时渲染两个引擎,并收缩不可见引擎的 surface。单元测试覆盖 Host 的视口重放和绑定连接的请求、渲染端的快照与序号处理及提前到达帧的排序,以及 wire 适配与接收通道的唯一全屏持有者、遮挡事件、在进入全屏尚未完成或已按 Escape 后的退出,以及关闭和销毁时的退出。服务规格测试覆盖 auto 取物理内存的一半、其 256 MiB 下限,以及超过物理内存的预算被拒绝加载。

Consequences

生产者替换和崩溃接管保留通道、渲染端消费者和视口,且无需 PID:父进程只需交出一个字符串。代价是:协议 1 的所有接收端、生产者、引擎和构建记录必须一起升级,旧构建会被明确拒绝:Kit 0.2.2 及更早的生产者和接收端在两个方向上都无法与这些源码互通,因此 Kit、其引擎以及在打包时编译接收器的 Desktop 必须一起升级。保持连接但停滞的生产者会阻塞其通道,直到它退出或通道关闭;后继要等待 Desktop 及其消费者释放前一个生产者的帧。GPU 进程退出会关闭画面上有帧的通道,消费者须打开新通道,而不能继续使用旧通道。生产者必须让已发送的句柄保持打开,直到接收端读取该帧;提交后立即退出的生产者会连同其连接一起丢失这一帧。在低于 Host 完整性级别的沙箱中运行的引擎依然可用,因为只有 Host 打开另一进程;反过来,权限高于 Host 的 producer 无法被 Host 打开,因而无法连接,接收器会在握手时关闭它,且 Host 不记录诊断。重新可见的视图要等到分配获批后才能出第一帧,收缩只归还帧 surface,不归还引擎自身的渲染缓存。Escape 总会退出全屏;遮挡以文档为范围:文档中的全屏元素会遮挡除持有者以外的所有接收通道。在 32 GB 及以下的 Windows 机器上,物理内存的一半等于 WDDM 允许图形使用的系统内存,因此那里可能先达到操作系统的上限而非预算;独立 GPU 把帧放在其独立显存中,预算看不到这部分内存,显存用尽时 WDDM 会换页而不是失败。