Skip to content
Dzmitry Malyshau edited this page Dec 10, 2018 · 2 revisions

This page contains references to our Mozlando discussions, serving as a context for further work as well as establishing some of the decisions we made.

Agenda: https://public.etherpad-mozilla.org/p/mozlando-gfx-agenda

Meta-issue for performance ideas: https://github.com/servo/webrender/issues/3390

Blob re-coordination

Major steps:

  1. introduce infinite blob space with a stable-ish origin, so that we avoid re-rasterizing tiles upon changing the boundaries
  2. snap dirty regions to tile boundaries
  3. push/pop layer of Moz2D (TODO: clarify, since I don't remember what this was for)

Threading model and that nasty blob crash

Bug in question: https://bugzilla.mozilla.org/show_bug.cgi?id=1492241

@nical explained the threading model with the focus on blobs, and we found the case triggering our crash: blob image rasterizer from a low-priority scene build overriding the one of the high-priority. This is separate from the bug @aosmond and @kvark found (where there is a rasterizer but no actual blob images).

Key takeaways:

  1. Everything is synchronized at the scene builder thread/queue. Low-priority thread only does blob rasterization.
  2. The whole idea of "missed blob images" should not exist. It's only there because at this moment Gecko's logic for image culling doesn't exactly match WR's. When they become matching, we'll not need to synchronize the blob image rasterizer at all.
  3. We should always be going through the scene builder thread if there is a new rasterizer (https://github.com/servo/webrender/pull/3387)
  4. A solution to the main crash could be to store a blob image rasterizer per WR pipeline, given that: - the same pipeline will never be processed in both high and low priority paths - a blob image is only going to be accessed from one pipeline

We brainstormed a bit on how a more flexible taskgraph-like model could look like, as opposed to the current hardcoded threading model, but there are no concrete plans about this.

Problems with rayon

@nical showed us what's wrong with rayon and shared the idea on how we can improve the thread utilization when using it. The gist of it is that the dispatcher thread should be work-stealing like all the worker threads, and the complication is that API changes are required.

Mix-blend mode performance

@gw3583 explained how the current implementation of mix-blend modes is bad for our render/compositor times. Together with @kvark they developed a solution that fits into the existing render task graph model (removing all the hacks we have currently in) and works similarly to the plane ordering picture splits.

Perspective scrolling

@emilio walked @kvark through the logic of perspective transformation and how it interacts with scrolling (hints: it's difficult). With help from @mattwoodrow we found out a missing piece and figured a rough plan on how to make perspective play well with scrolling.

The missing piece was flattening out the transformation on stacking contexts that aren't preserving 3D (https://github.com/servo/euclid/pull/310). The solution, given that piece in place, would be to keep both flattened and unflattened transormations when we traverse the spatial node tree, so that we can compute the scrolling offsets correctly.

Clip-scroll tree post-mortem

We revised the architectural decisions made earlier on how the clipping and scrolling should be organized. We came up with the following failures:

  1. (by @kvark) The edge cases were not collectively understood: each of us had a glimpse of idea, but we should have gathered the edge cases first and write them as reftests before brainstorming solutions.
  2. (by @gw3583) The existing Gecko implementation wasn't considered enough. Gecko had already clips and scrolls split, and we should have payed more attention to understanding it.
  3. (by @mstange) We underestimated the cost of API mismatches between Gecko and WR. The harsh reality is that we are translating the models every single scene build, and costs us a lot.

Gecko to WebRender logic

@staktrace showed us how Gecko generates WR display lists and how we pass the blob data across the process boundary.

WebRender architecture

@gw3583 walking us through the stages of processing the data that WebRender has, from display lists to the screen.

Gecko APZ hookup

@staktrace explained how async pan/zoom controller interacts with webrender, and how it does hit testing.

WebRender API Roadmap

Given the explanation of what Gecko does prior to WebRender DL formation by @mattwoodrow, we discussed this in group, and @kvark drew a roadmap of how WR API could evolve in the years to come.

Rough steps:

  1. Separate clipping from scrolling (https://github.com/servo/webrender/pull/3251)
  2. Turn image masks into filters (idea by @mstange)
  3. Rewrite WR API to accept 3 trees instead of a single display list:
    • spatial tree (reference, scroll and sticky frames)
    • clip tree (tree of clip nodes, with a clip chain defined by a path to the tree root)
    • item tree (with nodes being the stacking contexts only, and leafs being items)
  4. Generate the clip tree from Gecko's clip tree (as opposed to Gecko DL's traverse)
  5. Generate the spatial tree from either Gecko's frame tree or the async-scroll roots
  6. Possibly, avoid building Gecko's display lists at all