Platform/GFX/OffMainThreadCompositing: Difference between revisions

From MozillaWiki
< Platform‎ | GFX
Jump to navigation Jump to search
No edit summary
Line 25: Line 25:


==Current status==
==Current status==
=== Features ===
* Only scrolling is asynchronous/off main thread. All other features require further work.
=== Operating systems ===
* Android and B2G: Released. We continue to iron out OMTC bugs as the test base expands, but we are already quite high-quality.
* OS X: {{bug|756601}} Alpha quality. We began development of OMTC on this platform, but we haven't worked on it much since then. It pretty much works but is disabled by default.
* Linux: {{bug|722012}} In initial implementation stages. We're still sorting out basic issues with X and GL, as we don't support OMTC with BasicLayers yet.
* BasicLayers (software only): {{bug|703484}} In initial implementation stages. Marco Castelluccio, a volunteer contributor, is working through implementing off-main-thread BasicLayers, which also involves making our Cairo library thread-safe.
* Windows:
** Direct3D 10: {{bug|756606}} Work in progress; has some fundamental problems with textures which require the layers refactoring.
** Direct3D 9: {{bug|756608}} Work in progress; but, in theory, should be fairly straightforward (there are already shadow layers implemented, but I don't think they are used anywhere).
==Future Work==
===WebGL===
===WebGL===
The WebGL streaming buffer project helped improve our WebGL compositing performances.
WebGL optimizations can be made to avoid synchonization between the the cpu and the gpu.
Even though there is stil some work in progress, most of the work has landed already.
* Sharing WebGL backing textures between threads {{bug|728524}} lets us avoid reading back.
* Double-buffering WebGL {{bug|716859}} lets us hand off a texture to the compositor, then go back to drawing to the WebGL context.
* Not using glFinish() to synchronize between threads {{bug|697831}} (most likely using the ARB_sync extension) will let us hand those textures off faster.
 
'''Assignee''': Jeff Giblert, Cody Brocious (Daeken)<br>
'''Assignee''': Jeff Giblert, Cody Brocious (Daeken)<br>
'''Status''': Mostly done
'''Status''': Mostly done
===Video===
The video pipeline can now decode and composite video frames without touching the content thread (async-video). To improve performances and audio/video synchronization, there is some work in adding synchronization logic on the compositor side.
* Asynchronous video composition (already landed) is {{bug|706172}}
'''Assignee''': Nicolas Silva (nical)<br>
'''Status''': async-video done, improvements planned.


===CSS Animations===
===CSS Animations===
Line 58: Line 34:
* Asynchronous CSS animation is {{bug|706179}}
* Asynchronous CSS animation is {{bug|706179}}


'''Assignee''': David Zbarsky (dzbarsky)
'''Assignee''': Used to be David Zbarsky (dzbarsky), nobody at the moment.
'''Status''': Being worked
'''Status''': enabled on B2G, disabled on other platforms, on hold.


===Plugins===
===Plugins===
Plugins are already drawn asynchronously (at least on OS X), similarly to how HTML5 video works. Publishing those plugin "frames" to the compositor is directly analagous.
Plugins are already drawn asynchronously (at least on OS X), similarly to how HTML5 video works. Publishing those plugin "frames" to the compositor is directly analagous.
Plugins now work with OMTC when APZ is disabled, but windowed plugin need some more work to play well with APZ (and e10s?).
* {{bug|706499}}
* {{bug|706499}}


'''Assignee''': UNASSIGNED<br>
'''Assignee''': UNASSIGNED<br>
'''Status''': No work done
'''Status''': APZ+ windowed plugins need some work.


===Animated images===
===Animated images===
Line 74: Line 51:
* {{bug|717872}}
* {{bug|717872}}


'''Assignee''': Joe Drew <br>
'''Assignee''': Nobody
'''Status''': Work in progress
'''Status''': On hold.


===Off-main-thread layers implementations===
===Off-main-thread layers implementations===
Features listed above won't work off the main thread unless we have a layers implementation that knows how to draw off the main thread.
Features listed above won't work off the main thread unless we have a layers implementation that knows how to draw off the main thread.


==== Layers refactoring ====
==== B2G ====
The layers system has been heavily refactored to more easily facilitate OMTC on all platforms.


The biggest changes are to the compositing side, and to how textures/buffers/handles are passed between the drawing and compositing components. The aim is for most OMTC code to be backend-independent. Compositing is done by a Compositor class (rather than the ShadowLayerManager, which still have responsibility for managing the shadow layer tree). There are backend-specific compositor sub-classes, but the shadow layer tree and it's manager are backend-independent. Buffers/textures are handled by TextureClient/TextureHost pairs which have backend-specific subclasses and handle all inter-thread communication. The layer classes can then be agnostic about backend and IPC mechanism.
OMTC, OMTA, APZ, tiling and async-video are enabled. GL backend only.


The [https://wiki.mozilla.org/Gecko:Overview#Graphics Gecko overview] wiki page contains good documentation about the current (post refactoring) layers system.
'''Assignee''': Sotaro Ideka/Nicolas Silva
'''Status''': Shipped


==== Android ====
==== Android ====


'''Assignee''': Benoit Girard/Ali Juma<br>
OMTC, APZ, tiling and async-video are enabled, OMTA is disabled. GL backend only.
 
'''Assignee''': Benoit Girard
'''Status''': Shipped
'''Status''': Shipped


==== Mac OS X ====
==== Mac OS X ====


'''Assignee''': UNASSIGNED<br>
{{bug|756601}} OMTC, tiling and async-video are enabled, OMTA and APZ are disabled (work in progress). Mostly the GL backend, and to a lesser extent basic backend.
'''Status''': Beta quality
 
'''Assignee''': Matt Woodrow
'''Status''': Shipped


==== Linux ====
==== Linux ====
{{bug|722012}} Mostly works, one reftest failure to figure out before we can enable OMTC and async-video (work in progress). Linux will use basic layers by default at least for some time, the GL backend can be enabled through a pref.


'''Assignee''': Nicolas Silva<br>
'''Assignee''': Nicolas Silva<br>
'''Status''': In development, testable but buggy not optimized.
'''Status''': In development.


==== Direct3D 9 ====
==== Windows ====


'''Assignee''': Nick Cameron<br>
OMTC and async-video enabled, tiling, OMTA and APZ are disabled (work in progress). Windows users get the d3d11, d3d9 or basic backend depending on the OS and driver versions.
'''Status''': In development


==== Direct3D 10 ====
'''Assignee''': Bas Schouten/Nicolas Silva <br>
'''Status''': Shipped


'''Assignee''': Bas Schouten<br>
==== Basic backend (Software-only) ====
'''Status''': Alpha quality


==== Basic (Software-only) ====
This layers implementation is used when we have no hardware-accelerated layers backend; for example, when we're on a system with too-old or buggy drivers.
This layers implementation is used when we have no hardware-accelerated layers backend; for example, when we're on a system with too-old drivers.


'''Assignee''': Marco Castelluccio <br>
'''Assignee''': Marco Castelluccio/Nicolas Silva <br>
'''Status''': In development
'''Status''': Shipped


=Tracking bug=
=Tracking bug=

Revision as of 13:51, 6 October 2014

Current status

Shipped on all platforms except Linux (almost there on Linux as of Oct 6th 2014).

Goals

The main goal is to improve responsiveness. this architecture has the following advantages over our on-the-main-thread approach:

  • Reduce main thread contention
  • Asynchronous scrolling
  • Preventing tearing
  • Asynchronous video
  • Asynchronous CSS animation

Design

Gfx layers class diagram

The content thread(s) renders web content into intermediate surfaces (layers) and sends these updates to the compositor thread through layers transactions. We call client layers the layers on the content side, and host layers the ones on the compositor side. Layer classes are mostly responsible for defining the shape of the layer tree and own Compositable objects that are responsible for the logic of how to transfer and composite the rendered web content (for instance handling tiling, double buffering, etc.). There are client and host implementations for compositables as well. For compositables to remain backend-independent, we abstract the backend specific code out behin the texture abstraction (also split between the client and host instances), which handles the lifetime of the unerlying shared texture data and provides access read/write access to it through Moz2D and TextureSource (the latter is how textures interact with the Compositor API). Layers transaction makes sure that all of the editions applied to the client layer tree during a transaction are applied "at once" in the host layer tree so that we always composite content in a coherent state. The communication mechanism is based on IPDL, which abstracts out cross-thread and cross-process communication. e10s uses the same code as regular OMTC, except that the content and compositor threads are now in separate processes.

Plan

Our highest priority platform for this project has been mobile platforms, but we want to extend this to all supported platforms: Mac, Windows (D3D9 + D3D10), Linux, and software-only (BasicLayers; possibly, there is ongoing discussion as to whether this is the best use of resources to improve the experience for 'low-end' users).

Current status

WebGL

WebGL optimizations can be made to avoid synchonization between the the cpu and the gpu. Assignee: Jeff Giblert, Cody Brocious (Daeken)
Status: Mostly done

CSS Animations

Currently CSS animations are driven by the main thread. It'd be better if the style and layout code could assign attributes to relevant layers that would then be interpolated using specified functions on the compositor thread.

Assignee: Used to be David Zbarsky (dzbarsky), nobody at the moment. Status: enabled on B2G, disabled on other platforms, on hold.

Plugins

Plugins are already drawn asynchronously (at least on OS X), similarly to how HTML5 video works. Publishing those plugin "frames" to the compositor is directly analagous. Plugins now work with OMTC when APZ is disabled, but windowed plugin need some more work to play well with APZ (and e10s?).

Assignee: UNASSIGNED
Status: APZ+ windowed plugins need some work.

Animated images

Animated images are drawn using the main thread, but at least conceivably we could publish all the frames to the compositor and have the compositor know how to animate the images.

This could help us to animate throbbers, etc, but we don't currently have any layers support at all for animated images, so it will be more work for potentially less gain.

Assignee: Nobody Status: On hold.

Off-main-thread layers implementations

Features listed above won't work off the main thread unless we have a layers implementation that knows how to draw off the main thread.

B2G

OMTC, OMTA, APZ, tiling and async-video are enabled. GL backend only.

Assignee: Sotaro Ideka/Nicolas Silva Status: Shipped

Android

OMTC, APZ, tiling and async-video are enabled, OMTA is disabled. GL backend only.

Assignee: Benoit Girard Status: Shipped

Mac OS X

bug 756601 OMTC, tiling and async-video are enabled, OMTA and APZ are disabled (work in progress). Mostly the GL backend, and to a lesser extent basic backend.

Assignee: Matt Woodrow Status: Shipped

Linux

bug 722012 Mostly works, one reftest failure to figure out before we can enable OMTC and async-video (work in progress). Linux will use basic layers by default at least for some time, the GL backend can be enabled through a pref.

Assignee: Nicolas Silva
Status: In development.

Windows

OMTC and async-video enabled, tiling, OMTA and APZ are disabled (work in progress). Windows users get the d3d11, d3d9 or basic backend depending on the OS and driver versions.

Assignee: Bas Schouten/Nicolas Silva
Status: Shipped

Basic backend (Software-only)

This layers implementation is used when we have no hardware-accelerated layers backend; for example, when we're on a system with too-old or buggy drivers.

Assignee: Marco Castelluccio/Nicolas Silva
Status: Shipped

Tracking bug

The tracking bug is bug 598873. Tree view: [1]

Development

Development is happening on mozilla-central.

Test cases

http://people.mozilla.com/~ajuma/omtc/