Platform/GFX/APZ: Difference between revisions

From MozillaWiki
< Platform‎ | GFX
Jump to navigation Jump to search
Line 89: Line 89:
If you have questions about anything APZ-related, please add them here, and somebody watching this page will try to answer it.
If you have questions about anything APZ-related, please add them here, and somebody watching this page will try to answer it.


; What platforms is APZ currently enabled on? [2013-10-28] : APZ is currently enabled in the B2G (browser content only) and on Firefox Metro (when running in metro mode).
; What platforms is APZ currently enabled on? [2013-10-28] : APZ is currently enabled in the B2G (browser content only) and on Firefox Metro (when running in metro mode). As of December 20, 2013, APZ is enabled on all Gaia apps on B2G on developer builds only.

Revision as of 19:11, 20 December 2013

Introduction

The Async Pan/Zoom module (APZ)1 is a platform component that allows panning and zooming to be performed asynchronously (on the compositor thread rather than the main thead).

For zooming, this means that the APZ reacts to a pinch gesture immediately and instructs the compositor to scale the already-rendered layers at whatever resolution they have been rendered (so e.g. text becomes more blurry as you zoom in), and meanwhile sends a request to Gecko to re-render the content at a new resolution (with sharp text and all).

For panning, this means that the APZ asks Gecko to render a portion of a scrollable layer, called the "display port", that's larger than the visible portion. It then reacts to a pan gesture immediately, asking the compositor to render a different portion of the displayport (or, if the displayport is not large enough to cover the new visible region, then nothing in the portions it doesn't cover - this is called checkerboarding), and meanwhile sends a request to Gecko to render a new displayport. (The displayport can also be used when zooming out causes more content of a scrollable layer to be shown than before.)

1. This module used to be called Async Pan/Zoom Controller (APZC), but this was changed to avoid confusion because there is a class called AsyncPanZoomController of which there are now multiple instances.

Supported platforms

The APZ module is currently enabled on B2G and Metro. Fennec has a Java implementation of asynchronous panning and zooming, but the plan is to port Fennec to use the APZ module as well.

The APZ module relies on OMTC, so a prerequisite for porting it to a platform is for OMTC to work on that platform.

AsyncPanZoomControllers

Inside the APZ module, every scrollable layer has an AsyncPanZoomController (APZC). Scrollable layers roughly correspond to the root document, documents in iframes, and overflow:scroll elements. See OMTC for more information about layers.

The APZCs are arranged in a tree whose structure reflects the structure of the layer tree containing the layers that they correspond to, except that the APZC tree only has nodes for scrollable layers, while the layer tree has nodes for all layers. The APZC tree is managed by a class called APZCTreeManager. The APZCTreeManager is the interface through which the outside world interacts with the APZ module - there is no access to the APZCs directly, but the APZCTreeManager provides methods that operate on a specific APZC in the tree. These methods identify an APZC using three integer identifiers, grouped in a structure called ScrollableLayerGuid. The three identifiers are:

  1. A layers id, which identifies the layer tree that the scrollable layer belongs to. Layers ids are maintained by the compositor, with CompositorParent::RootLayerTreeId() returning the layers id for the root layer tree, and CompositorParent::AllocateLayerTreeId() allocating a layers id for a new layer tree.
  2. A pres shell id, which is a temporal identifier that correponds to the document that contains the scrollable layer, which may change over time. The pres shell id can be obtained using nsIDOMWindowUtils::GetPresShellId().
  3. A scroll id, which identifies the actual scroll frame. The scroll id is called a view id in Gecko code, and can be obtained using nsIDOMWindowUtils::GetViewId().

Interactions with other components

The APZ interacts with the following other platform components:

Compositor

The compositor creates and stores the APZCTreeManager, and interacts with it in the following ways:

  • When the compositor receives an update to the layer tree, it propagates this update to the APZCTreeManager by calling APZCTreeManager::UpdatePanZoomControllerTree(). This function updates the tree of APZCs to reflect the tree of scrollable layers in the updated layer tree.
  • Every time the compositor composites a frame, it queries each APZC for its current async transform (see AsyncPanZoomController::SampleContentTransformForFrame()). The APZC modifies this transform as the user pans and zooms.
  • APZCs can schedule a composite by calling CompositorParent::ScheduleRenderOnCompositorThread().

Widget code

The widget code is a platform-specific component of a browser implementation that interfaces with the native widget implementation. It corresponds roughly to the following pieces of code:

The widget code interacts with the APZ in the following ways:

  • forwards relevant input events to the APZ (APZCTreeManager::ReceiveInputEvent())
  • notifies the APZ about Gecko events that are relevant to it, such as:
    • a reflow that causes a change in the dimensions of a scrollable layer (APZCTreeManager::UpdateCompositionBounds())
    • a scrollTo performed by content (APZCTreeManager::UpdateScrollOffset())
    • a request to zoom in to a rectangle (APZCTreeManager::ZoomToRect())

In addition, the widget code provides APZ with an interface for interacting with Gecko, called GeckoContentController. The implementation of this interface is different for each platform. It may even be different for different APZCs within one platform (for example, in the B2G browser, APZCs representing scrollable elements in content processes use the RemoteContentController implementation, while those representing scrollable elements in the parent process will use a different implementation (currently being developed in bug 912657)).

GeckoContentController allows the APZ to do the following:

  • request a repaint (GeckoContentController::RequestContentRepaint())
  • request handling of various gestures, such as single taps, double taps, and long taps (GeckoContentController::HandleSingleTap() etc.)
  • fire async scroll events (GeckoContentController::SendAsyncScrollDOMEvent())
  • schedule arbitrary actions to be performed on the Gecko thread (GeckoContentController::PostDelayedTask())

Threads and processes

When OMTC is enabled on a platform (which is a requirement for using the APZC), the compositor runs on its own thread, called the compositor thread. APZCs and the APZCTreeManager can be thought of as living on the compositor thread, although they can be used in certain ways by other threads (usually the Gecko thread, or the platform UI thread if there is one). APZCTreeManager.h documents which APZCTreeManager methods can be called on which threads.

On B2G, there are not only multiple threads but also multiple processes, as each app (or in the case of the browser, each tab) has its own process. In this setup, only the parent process has a compositor thread, and all APZCs live in the parent process, even ones corresponding to layers from a child thread.

Main APZ projects on the horizon

Full Query
ID Priority Summary Status Assigned to
775452 -- Support multiple asynchronously-panned subframes RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
814435 -- Display scroll bars when async pan and zoom is turned on RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
898444 -- Figure out why overflow:scroll elements aren't scrolling properly RESOLVED Robert O'Callahan (:roc) (email my personal email if necessary)
907179 -- Tune APZC displayport heuristics RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
907754 -- Pages with iframes that are less than screen width are not rendering correctly RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
909881 -- Zoom constraints from child processes sent to the root could get dropped RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
909887 -- Homescreen renders at 1.5 scale when APZC is turned on RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
915872 -- Homescreen doesn't render background layer when APZC is turned on RESOLVED
916125 -- When displayports are set on elements, their layers are not always clipped correctly RESOLVED Timothy Nikkel (:tnikkel)
916185 -- Various gaia apps don't set a meta-viewport tag VERIFIED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
929728 -- Add a setting to enable APZC in all of gaia RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
933264 -- In some cases with the displayport set, the clip on a scrollframe isn't correct RESOLVED Timothy Nikkel (:tnikkel)
938312 -- Wrong orientation when starting browser in landscape mode RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
940036 -- 3rd party gaia apps should set a meta-viewport tag RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
940691 -- Contacts app with APZ on lets you pan to the settings pane VERIFIED Botond Ballo [:botond]
941215 -- E-mail with APZ on lets you pan out and mixes up touch events RESOLVED Botond Ballo [:botond]
941294 -- SMS with APZ on can mess up the "No messages start communicating now" page RESOLVED
942726 -- Activate APZ for all Gaia apps for non-user build. RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
942752 -- Tab active state is sometimes triggers on some parts of the screen while panning RESOLVED
942754 -- Double-Tap to zoom is not disabled even with user-scalable=no RESOLVED Botond Ballo [:botond]
942760 -- Click target seems off by a few hundred pixels RESOLVED Botond Ballo [:botond]
942799 -- <meta name="viewport" content="height=device-height"> is not respected on B2G RESOLVED Botond Ballo [:botond]
942850 -- Panning the 'New Contact' panel of the contacts app is very slow RESOLVED
942854 -- [Calendar] Scrolling the week view results into results into overlapping artifacts RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
942856 -- [Gaia] Sometimes the blue highlights shown on a touch does not appear anymore RESOLVED
942863 -- [Messaging] The messages list content can not be scrolled to the end when APZ enabled RESOLVED Julien Wajsberg [:julienw] (PTO -> Aug 14)
942929 -- Long pressing an element without any contextmenu does not trigger a click RESOLVED Dale Harvey (:daleharvey)
943831 -- Apps can be size incorrectly, ignoring the viewport rules RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
943846 -- Scrolling quickly sometimes results into a white screen RESOLVED Chris Lord [:cwiiis]
943858 -- [SMS] Thread list starts scrolled to the top RESOLVED
943882 -- APZC can overscroll content RESOLVED Benoit Girard (:BenWa)
944511 -- Gallery app initial size is wrong under APZC after restart RESOLVED
944759 -- Use a viewport with device-height RESOLVED
944898 -- [Music] With APZ turned on clicks on the music app seems wrong RESOLVED
946172 -- [Dialer] Call screen is broken with APZ turned on RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
946339 -- Tap and hold does not highlight the targeted element RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
946408 -- Input fields are not scrollable with APZC enabled RESOLVED Botond Ballo [:botond]
946545 -- White out occurs after scrolling for a long time in Settings with APZ turned on VERIFIED
946999 -- [Homescreen] With APZ turned on the homescreen is not rendered until you touch the screen in certain conditions RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
947354 -- enabling APZ in Gaia on Nexus 4 makes many core apps have incorrect resolution RESOLVED
947552 -- [Music][APZ] Shuffle button in the Music App doesn't seem to function with APZ turned on in content VERIFIED
948001 -- [Settings] With APZ turned on the wifi panel is sometimes shown instead of the main panel at startup RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
948396 -- [Calendar] Can not scroll anymore the week/day view once the new event has been opened with APZ turned on RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
949404 -- [keyboard] With APZ turned on and multiple APZCs the app is not correctly repainted when the keyboard is dismissed RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
950300 -- The main panel of the solitary view of "12 Games in 1" is pannable while playing RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
950487 -- Overzoom when rotating an application from portrait to landscape RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
950488 -- Application is not repainted correctly when an element is going fullscreen RESOLVED Benoit Girard (:BenWa)
950489 -- While changing the range of an input type range the page is moving as well RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
950993 -- position:fixed CSS rule fails to keep marketplace header at top of browser RESOLVED Chris Lord [:cwiiis]
951113 -- Application is not repainted correctly when the keyboard is dismissed once the screen is off RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
951290 -- [B2G] [Browser] The first swipe after zooming has no effect RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
951298 -- placing 5 icons in the dock and then going in and out of edit mode on the homescreen will chop the 5th icon RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
951308 -- [B2G][Gallery] Turning on APZ and zooming all the way in while on the list view in the gallery causes the phone to restart RESOLVED
951321 -- [B2G][Messages] Create New Message button gets selected but does not open New Message page RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
951342 -- [APZ] Can't scroll in content when trying to compose an email with more than 6 lines of text. RESOLVED
951357 -- [APZ] e-mail body display iframe panning can overlap the footer toolbar RESOLVED Botond Ballo [:botond]
951375 -- [FTE] Cannot pan the First time Experience page RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
951458 -- [B2G][Settings]Settings App launches on Wi-Fi page. RESOLVED
957188 -- [APZC] The click events are lost in some situations RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
957790 -- B2G: Settings app can be zoomed-in during startup RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
957925 P1 [LowMemory] Gallery app scroll shows stutter if enable APZ for all Apps RESOLVED Sotaro Ikeda [:sotaro]
958208 -- [B2G][FTU]Unable to scroll in the FTU RESOLVED Botond Ballo [:botond]
958245 -- [APZ][email] email compose content iframe no longer scrolls VERIFIED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
958650 -- [B2G][Contacts] Deselect and Select All buttons disappear when user is scrolling contacts list during import RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
959144 -- Can not scroll calendar app after looking at an event RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
959198 -- [APZC] Keyboard disappears after typing first letter RESOLVED Botond Ballo [:botond]
959199 -- [APZC-only] Calling "preventDefault" on the contextmenu event does not prevent the click event. RESOLVED Dale Harvey (:daleharvey)
960120 -- [APZC] Can not scroll contacts tab of Dialer app RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
960163 -- [B2G][Homescreen] Pressing and holding app icon on homescreen intermittently fails to allow user to move app (APZ active) RESOLVED
961047 -- Ensure all mozbrowser iframes use APZ when APZ is enabled. RESOLVED Vivien Nicolas (:vingtetun) (:21) - (NOT reading bugmails, needinfo? please)
962791 -- [B2G][Core][Layout] Cancel button disappears while reseting data with APZ enabled RESOLVED Timothy Nikkel (:tnikkel)
964421 -- [B2G][Everything.me]Moving apps up and down from the top of a collection scrolls the collections page. RESOLVED Doug Sherk (:drs) (inactive)
964981 -- [B2G][Contacts] Scrolling in detail view of a contact with an image produces graphical issues showing layer below RESOLVED Etienne Segonzac (:etienne)
964997 -- homescreen is rendered incorrectly when try to scroll more with APZC is enabled RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
966397 -- [B2G][Marketplace][Preview Page] App page preview images do not show full screen other than the first and last RESOLVED Robert O'Callahan (:roc) (email my personal email if necessary)
966476 -- Settings app is killed when showing the passcode panel with the Hardware Composer turned on RESOLVED
966507 -- [B2G][Wikipedia] Changing the font size results in a blank article page VERIFIED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
969483 -- [B2G][Contacts]User is unable to scroll in the Add Contact menu after opening phone label menu and pressing Done RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
972091 -- [B2G][Contacts] Header bar, search bar and all contacts can be completely missing on the main contacts' view window VERIFIED Cristian Rodriguez (:crdlc)
975033 -- [B2G][Marketplace] Wikipedia displays black screen overlaying content VERIFIED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
980041 -- [B2G] Taking the phone in and out of standby with the keyboard up will hide messages RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
980679 -- [B2G][Youtube] The screen will jump up and down when scrolling through the Youtube app VERIFIED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
982888 -- [Buri] Email content cannot be scrolled in some HTML format with embedded images (note: iframe with transform: scale() applied) RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
987771 -- [B2G] Taking the phone in and out of standby with the keyboard up will hide messages RESOLVED Kartikaya Gupta (email:kats@mozilla.staktrace.com)
996991 P1 [Email] OOM Crash on displaying and/or scrolling a long text/html email that triggers newsletter mode VERIFIED Andrew Sutherland [:asuth] (he/him)

85 Total; 0 Open (0%); 75 Resolved (88.24%); 10 Verified (11.76%);


  • Make APZ work well for Metro - bug 886321
  • Implement support for Fennec-like dynamic toolbar on B2G - bug 860812
  • Improve hit detection for the different touch-sensitive regions - bug 928833
  • Switch Fennec over from the Java version to the C++ APZ - bug 776030

FAQ

If you have questions about anything APZ-related, please add them here, and somebody watching this page will try to answer it.

What platforms is APZ currently enabled on? [2013-10-28]
APZ is currently enabled in the B2G (browser content only) and on Firefox Metro (when running in metro mode). As of December 20, 2013, APZ is enabled on all Gaia apps on B2G on developer builds only.