[Site Isolation] Coalesce frame geometry updates into a single page-level message
Component: WebKit Site Isolation | f4bfa28
LayoutTests/http/tests/site-isolation/do-not-rebroadcast-unchanged-frame-geometry.html
Site isolation 환경에서 각 WebContent process는 자신이 호스팅하지 않는 frame을 RemoteFrame이라는 대리 객체로 갖고 있습니다. 이 frame들의 위치, 크기, visible rect는 layout, IntersectionObserver, throttling 처리에 필요합니다. 한편 local frame의 geometry는 해당 frame을 담당하는 process가 소유하며, 이 값을 UIProcess에 보고합니다. UIProcess는 frame ID를 WebFrameProxy 객체에 매핑하는 신뢰된 broker입니다. 보고받은 geometry는 UIProcess를 거쳐 같은 page의 다른 process들로 중계됩니다.
기존에는 frame마다 broadcastFrameTreeSyncData geometry IPC가 전송되었습니다. 이번 commit에서 이 IPC가 page 단위의 단일 메시지인 WebPageProxy::HandleFrameGeometryUpdates로 변경되었습니다. 전송은 rendering update 시점에 WebPage::broadcastFrameGeometryUpdatesIfNeeded가 담당합니다. 먼저 UIProcess가 geometry를 각 WebFrameProxy에 저장한 뒤 다른 process로 전달하고, 수신 측은 WebPage::frameGeometryChangedInAnotherProcess에서 batch를 적용합니다. 중계 필터링 로직도 송신 측에서 UIProcess로 옮겨졌습니다. viewport 안에 frame이 없는 process에는 main frame scroll 업데이트를 보내지 않는 로직, 그리고 remote 하위 frame이 없는 frame을 건너뛰는 로직이 여기에 해당합니다.
Significance
이번 변경으로 IPC 전송량이 줄어듭니다. 동시에 UIProcess가 모든 frame의 최신 geometry를 보유하게 되는데, 이후 예정된 최적화가 이 정보를 필요로 합니다. 결과적으로 어떤 process가 어떤 frame geometry를 볼지 결정하는 policy 지점은 송신 측 WebProcess가 아니라 UIProcess가 됩니다.
Audit directions
- Batch handler의 검증과 권한.
handleFrameGeometryUpdates가 frame ID를 어떻게 resolve하는지 확인할 필요가 있습니다. 알 수 없는 ID, stale ID, detach된 frame, 중복된 항목, 다른 process 소속 frame이 모두 점검 대상입니다. 또한 compromised WebContent가 다른 site 소유 frame의 geometry를 덮어쓸 수 있는지도 살펴봐야 합니다. 이 경우 해당 frame에 위조된 rect나 viewport info가 전달될 수 있습니다. - 수신 측의 batch 적용.
frameGeometryChangedInAnotherProcess는 vector 전체를 먼저 적용한 뒤, remote IntersectionObserver와 PDF HUD를 한 번만 갱신합니다. 이때 batch 처리 도중 frame이 제거되거나 navigate되는 경우를 점검해야 합니다. loop 전반에 걸친 frame lifetime도 함께 확인할 필요가 있습니다. - 순서가 보장되지 않는 독립 메시지. Geometry는 의도적으로
RemoteLayerTreeCommitBundle밖에서 전송됩니다. commit이 backing store flush에서 block될 수 있기 때문입니다. 그래서RemotePageProxy주입,setDrawingArea, frame tree 변경보다 먼저 도착할 수도, 나중에 도착할 수도 있습니다. 이 경우 캐시된lastSentMainFrameViewportInfo가 stale 상태가 될 가능성이 있습니다. - 신뢰할 수 없는 수치와 필터링. NaN, 매우 크거나 음수인 크기,
LayoutRectoverflow 값이 다른 process의 layout 및 IntersectionObserver 계산으로 흘러 들어갑니다. 한편 위치가 옮겨진 억제 로직 때문에 cross-origin frame의 위치가 노출되거나, 필요한 업데이트가 누락될 가능성도 있습니다.