Closed Bug 1612440 Opened 5 years ago Closed 4 years ago

Send transactions directly to the scene builder thread when possible

Categories

(Core :: Graphics: WebRender, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
82 Branch
Tracking Status
firefox82 --- fixed

People

(Reporter: nical, Assigned: nical)

References

(Blocks 1 open bug)

Details

(Whiteboard: wr-planning)

Attachments

(17 files, 3 obsolete files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review

Currently transactions that trigger scene building first go through the render backend, then some resources are collected (font, blobs) and sent to the scene builder. If the render backend is busy this delays the scene being processed, causing extra latency for layout transactions.

With ipc_channel removed, we can move the few hash maps on that store data we send to the scene builder, keep them at the API level instead and send messages directly to the scene builder. It should make things simpler (no need to remember which data is pre/post scene building on the render backend, everything is post-scene building) and reduce latency in some cases.

Blocks: 1626626
Depends on: 1627299

This is a small preliminary refactoring that will be needed to let the api talk to the scene builder thread.

Assignee: nobody → nical.bugzilla
Status: NEW → ASSIGNED
Whiteboard: wr-planning

Now that the capture code is gone, we don't use these serde implementations. They get in the way of changing the way transactions are represented so I'd like to remove a bunch of them for now.

The goal is to move this code out of the render backend to avoid requiring the messages to transit through this thread. Other similar changes are in progress.

Keywords: leave-open
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a307cb281ea1 Don't implement Serialize/Deserialize in some parts of th API. r=gw https://hg.mozilla.org/integration/autoland/rev/d3387bfa2b02 Wrap the shared font instance map to a type exposed in the api crate. r=gw

DocumentView has a mix of members that affect scene building and memebers that change frame to frame. These need to be updated at different rates and more importantly follow the respective flow of scene and frame transactions, which wasn't done properly before this change.

Depends on D71781

The information comes with SetDisplayList messages but was applied before scene building instead of during scene swap, which breaks the transaction model and looks like a bug.

Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7675477d0507 Move some scene-related transaction handling code to the scene builder thread. r=gw https://hg.mozilla.org/integration/autoland/rev/4933e4b66edb Separate scene and frame related data in DocumentView. r=gw
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2f1096e3894c Discard the SpatialTree's frame state after scene swap. r=gw

Turns out we sometimes send transactions that don't change anything (for example in reftests we continuously set the quality setting to the same value) which can trigger unnecessary scene building. In reftests this causes us to build a scene after removing font instances that it refers to.

This requires pulling FrameBuilderConfig and a few other types along which isn't very satisfying but oh well.

This patch separates SceneBuilderRequest into two enums: One we'll be able to send from the api, and containing types that shouldn't move to the webrender_api crate. For example LoadScene depends on the Scene struct and at this point a quarter of webrender's types would need to move to webrender_api.
This solution is a bit iffy but I'm not sure how to better do this. If we don't need strict ordering, moving to crossbeam's queue which support select would let us at least avoid sending dummy BackendMessage to instruct the scene builder thread to look into the other queue.
This patch should not change the current behavior except for one (important) detail: all messages that use BackendSceneBuilderMessage have to go through the low priority scene queue instead of the high priority one. This affects the capture stuff, I think that it's still correct but I'm not familiar enough with it to be sure.

https://github.com/servo/webrender/pull/3936 adds the Serialize/Deserialize that allow Servo to build with the master revision of the webrender git repository. This will shortly be broken again by https://phabricator.services.mozilla.com/D72397 if that revision lands and syncs upstream.

This prevents the request from racing ahead of the AddFontInstance message which follows the transaction through the scene builder thread and silently returning zero-sized glyphs.

Attachment #9144064 - Attachment description: Bug 1612440 - Forward glyph dimension requests through the scene builder thread. r=gw → Bug 1612440 - Forward glyph dimension and index equests through the scene builder thread. r=gw

One of the last steps towards letting the api send scene building requests directly. I'll clean up the names after everything is in place.

Depends on D72614

This change allows the api to talk directly to the scene builder thread. This avoids unpredictable and sometimes large latency caused by scene builder requests sitting in a busy render backend's event loop.

Depends on D72906

Depends on D74297

Depends on D74299

Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c48d5a53322b Remove ApiMsg::UpdateResources. r=gw https://hg.mozilla.org/integration/autoland/rev/0b8fcf1dfe42 Make send_transaction take &mut self. r=gw https://hg.mozilla.org/integration/autoland/rev/a9a32798b174 Renamed clone_sender into create_sender. r=gw https://hg.mozilla.org/integration/autoland/rev/30b5173170a4 Add BlobImageHandler::create_similar. r=gw
Attachment #9143660 - Attachment is obsolete: true
Attachment #9142445 - Attachment is obsolete: true
Regressions: 1634186
Attachment #9143574 - Attachment is obsolete: true
Attachment #9144064 - Attachment description: Bug 1612440 - Forward glyph dimension and index equests through the scene builder thread. r=gw → Bug 1612440 - Forward glyph dimension and index requests through the scene builder thread. r=gw
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0794b8100c6c Forward glyph dimension and index requests through the scene builder thread. r=gw https://hg.mozilla.org/integration/autoland/rev/871a79b86792 Simplify the SetDisplayList message. r=gw https://hg.mozilla.org/integration/autoland/rev/eb730f48c250 Move some types to webrender_api. r=gw
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/60280b67c95d Use a single shared font instance map in various place. r=gw
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a9eaeeec4148 Move blob and font resources to the RenderApi. r=gw
Regressions: 1640103

== Change summary for alert #26001 (as of Wed, 20 May 2020 03:49:19 GMT) ==

Improvements:

3% raptor-tp6-yahoo-mail-firefox-cold fcp linux64-shippable-qr opt 334.50 -> 324.75

For up to date results, see: https://treeherder.mozilla.org/perf.html#/alerts?id=26001

Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8990e5bd9960 Merge the webrender::Transaction and webrender_api::TransactionMsg structs. r=gw https://hg.mozilla.org/integration/autoland/rev/1981a4af9b8e Separate SceneBuilderRequest in two. r=gw,aosmond
Regressions: 1640402
No longer regressions: 1640402
Regressions: 1654013
Depends on: 1662827
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/07e83df29896 Send some messages directly to the scene builder thread. r=gw
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Keywords: leave-open
Resolution: --- → FIXED

oops.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Status: REOPENED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch

== Change summary for alert #26927 (as of Mon, 14 Sep 2020 10:58:35 GMT) ==

Improvements:

8% displaylist_mutate windows10-64-shippable-qr opt e10s stylo 2,785.92 -> 2,559.58
6% displaylist_mutate windows10-64-shippable-qr opt e10s stylo 2,747.33 -> 2,574.94
4% displaylist_mutate linux64-shippable-qr opt e10s stylo 2,962.74 -> 2,854.00

For up to date results, see: https://treeherder.mozilla.org/perf.html#/alerts?id=26927

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: