← All reports

[Remote Snapshotting] Serialize fonts, gradients, filters and graphics state by value

Component: WebCore Display Lists | f59de9b

Source/WebCore/platform/graphics/displaylists/DisplayList.cpp

+RefPtr<const DisplayList> DisplayList::createResolvingResources(Vector<Item>&& items, std::span<const Ref<const FontBase>> fonts, std::span<const Ref<const DisplayList>> displayLists)
+{
+ for (auto& item : items) {
+ bool isValid = WTF::switchOn(item,
+ [&](DrawDisplayList& item) {
+ if (item.isResolved())
+ return true;
+ if (item.displayListIndex() >= displayLists.size())
+ return false;
+ item.setDisplayList(displayLists[item.displayListIndex()].copyRef());
+ return true;
+ },
+ [&](DrawGlyphs& item) {
+ if (item.glyphs().size() != item.advances().size())
+ return false;
+ ...
+ if (item.fontIndex() >= fonts.size())
+ return false;
+ item.setFont(fonts[item.fontIndex()].copyRef());
+ return true;
+ },
+ ...
+ if (!isValid || !isResolved(item))
+ return nullptr;
+ }
+ return create(WTF::move(items));
+}

Remote snapshotting has the GPU process record page content as a display list and ship it to the print process, which replays it to produce PDF output. The GPU process renders web content that may include cross-origin iframes, so the serialized list can carry data derived from untrusted pages. Fonts, nested display lists and web font data are shared objects, so they are deduplicated into index tables and referenced by index inside items; the receiver rebuilds the tables (fonts first, then display lists bottom-up) and patches real objects back into the items.

DisplayListData now encodes fonts, web font data, gradients, graphics state, control parts, system images and filters by value. DrawGlyphs and DrawDisplayList can hold an index instead of a Font or nested DisplayList, and the decoder resolves these from the font, web-font and bottomUpDisplayLists tables, failing if any item remains unresolved. Items needing images, pattern brushes, the ARKit badge, and filters with a source image or FEImage still fail to encode.

GPU process                                   Print process
  encode: webFontData[] ─► fonts[] ─► bottomUpDisplayLists[]
                    │ IPC
                    ▼
  decode: parse webFontData ─► create Fonts ─► create nested DLs
          ─► create outer DL, replace indices with objects
          ─► any item still isResolved()==false ─► decode FAILS

This is a new cross-process decoder in the print process that parses web font bytes and index-linked object graphs received from the GPU process. The GPU-to-print channel goes from carrying plain-value items to a much larger surface.