Commit Graph
19 Commits
Author SHA1 Message Date
Jamie Nicol 329cb92b40 Bug 1824083 - Remove previous attempts to detect and work around invalid Surface bug. r=gfx-reviewers,geckoview-reviewers,nical,m_kato
The detection is inadequate and the workaround does not work on all
versions of Android. Later patches in this series will replace this
with something better.

Differential Revision: https://phabricator.services.mozilla.com/D176719
2023-05-10 15:50:21 +00:00
Sandor Molnar 62ec74fbb0 Backed out 4 changesets (bug 1824083) for causing build bustages in include/mozilla/webrender/RenderCompositorOGLSWGL.h CLOSED TREE
Backed out changeset 7c1be037e345 (bug 1824083)
Backed out changeset bf5c5929ef7b (bug 1824083)
Backed out changeset 6fad491b84be (bug 1824083)
Backed out changeset 57ae9c87c467 (bug 1824083)
2023-05-10 18:01:13 +03:00
Jamie Nicol 56d69e9b99 Bug 1824083 - Remove previous attempts to detect and work around invalid Surface bug. r=gfx-reviewers,geckoview-reviewers,nical,m_kato
The detection is inadequate and the workaround does not work on all
versions of Android. Later patches in this series will replace this
with something better.

Differential Revision: https://phabricator.services.mozilla.com/D176719
2023-05-10 14:44:50 +00:00
Jamie Nicol 493df65b62 Bug 1797055 - Force crash early if compositor is resumed with abandoned Surface. r=geckoview-reviewers,m_kato
In bug 1772839 we were seeing a large number of crashes due to
encountering a webrender error after exhausting all fallback
configurations. At least in some cases, this was due to the compositor
being resumed with an Android Surface that was already in an abandoned
state, meaning we can never succeed in creating an EGL Surface.

We added a check for this condition, and a workaround, to the
GeckoView java code. However, we are still seeing crash reports
matching this signature. To help determine whether these are also due
to the Surface being abandoned, or due to some other reason, this
patch adds a deliberate crash much earlier in the pipeline if we
detect an abandoned Surface.

Differential Revision: https://phabricator.services.mozilla.com/D160042
2022-10-27 08:01:28 +00:00
Jamie Nicol 0a6558c241 Bug 1783542 - Use widget size from ResumeAndResize rather than querying native window. r=gfx-reviewers,aosmond
On Android we have until now determined the compositor widget's size
by querying the values from the ANativeWindow. However, since bug
1780093 landed we can now switch between which Surface we are
rendering in to, and as a result we appear to be using the wrong size
some of the time.

This patch is a speculative attempt to fix this, by using the size
passed to ResumeAndResize() (which itself comes from the Surface's
surfaceChanged() callback) rather than querying the window.

Differential Revision: https://phabricator.services.mozilla.com/D154909
2022-08-18 12:16:46 +00:00
Jamie Nicol 14534b96fc Bug 1778651 - Add gfxCriticalNote for negative ANativeWindow size r=gfx-reviewers,geckoview-reviewers,aosmond,owlish
One possible cause of the failures to create an EGLSurface we are
seeing in bug 1772839 is that the Surface's underlying BufferQueue has
already been abandoned. In such circumstances,
ANativeWindow_getWidth/Height will return a negative value. If this
occurs, ensure we annotate crash reports via gfxCriticalNote. This
will allow us to determine whether the crashes we are seeing are
indeed due to an abandoned BufferQueue, or some other reason.

Differential Revision: https://phabricator.services.mozilla.com/D151360
2022-07-08 15:19:14 +00:00
Jamie Nicol e9e9894140 Bug 1766127 - Allow AndroidCompositorWidget::mClientSize to be updated from main thread. r=agi,gfx-reviewers,lsalzman
On Android we have long since calculated the compositor widget size
from the Surface rather than using the main thread widget size. This
is to avoid a trip via the main thread in response to a
ResumeAndResize event on the UI thread.
AndroidCompositorWidget::mClientSize therefore gets calculated when
the compositor is resumed.

However, it is possible in some circumstances for the compositor to
receive a display list prior to it being resumed. In this bug's case,
SyncResumeAndResize is getting called before the UI thread has been
notified that the compositor has been initialized. It therefore cannot
resume the compositor, and we instead resume the compositor on the
subsequent NotifyCompositorCreated call. This starts a race between
the main thread paint and NotifyCompositorCreated being scheduled on
the UI thread then resuming the compositor via
PUiCompositorController. If we receive
WebRenderBridgeParent::RecvSetDisplayList prior to
UiCompositorControllerParent::RecvResumeAndResize, then
AndroidCompositorWidget::mClientSize will be zero. This results in us
setting zero-sized webrender scene rect, leading to webrender exiting
early during rendering, resulting in a black screen.

To fix this, allow the main thread to set the AndroidCompositorWidget
size, in addition to the UI thread being able to set it. We do so by
adding a NotifyClientSizeChanged method to
PlatformCompositorWidgetDelegate, called from
nsWindow::OnSizeChanged. The cross-process implementation of this uses
an IPDL call on PCompositorWidget, which shares a top-level protocol
with PWebRenderBridge, meaning calls are guaranteed to occur in
order. This means a resize event on the main thread is guaranteed to
set the CompositorWidget size before the display list from the
subsequent paint is received.

Differential Revision: https://phabricator.services.mozilla.com/D144594
2022-04-25 18:20:55 +00:00
Jamie Nicol b9e045253b Bug 1758217 - Clamp maximum size of AndroidCompositorWidget. r=gfx-reviewers,nical
In bug 1756700 we added size constraints to the size of the android
nsWindow. This avoided hitting webrender's window_size_sanity_check
assertion during the geckoview giantScreenshot test when initializing
the webrender renderer.

However, the sanity check occurs whenever the webrender document size
is updated, which can occur when a new display list is sent in
addition to renderer initialization. In
WebrenderBridgeParent::SetDisplayList we take the window size from
CompositorWidget::GetClientSize rather than
nsWindow::GetClientSize. On Android, AndroidCompositorWidget
calculates its size directly from the Surface/ANativeWindow to avoid
having to pass through the main thread when a ResumeAndResize message
is sent from the UI thread to the compositor thread. This means the
nsWindow size constraints have no effect on the compositor widget
size.

This patch additionally clamps the max size of
AndroidCompositorWidget, meaning we never send too large a size to
webrender and therefore avoid the assertion.

Differential Revision: https://phabricator.services.mozilla.com/D140492
2022-03-08 21:00:30 +00:00
Jamie Nicol 099bd22c56 Bug 1749745 - Initialize AndroidCompositorWidget with initial size. r=aosmond,geckoview-reviewers,agi
Since bug 1747116 landed, if the compositor is reinitialized whilst
the Android Surface is invalid, we avoid crashing when querying the
window size and instead keep the compositor in a paused state.
However, in this case we will believe the widget size is 0x0 until the
compositor is eventually resumed. If webrender receives a display list
during this time, it will set an empty view rect. This means when the
compositor is subsequently resumed webrender believes it has nothing
to render, and we get stuck in a state where nothing is ever rendered
to the screen.

This patch initializes the AndroidCompositorWidget with an initial
size, which avoids the problem.

Differential Revision: https://phabricator.services.mozilla.com/D135711
2022-01-12 16:43:51 +00:00
Jamie Nicol 06424a0346 Bug 1747116 - Guard against null native window in AndroidCompositorWidget r=gfx-reviewers,geckoview-reviewers,aosmond,m_kato
If AndroidCompositorWidget's surface reference points to a surface
that has been destroyed, we can end up with a null ANativeWindow
pointer. This can result in crashes when using it to query the window
size.

This patch makes it so that we use the native window to query the size
only when the surface has changed rather than for every call to
GetClientSize(). This allows us to guard against a null pointer in a
single place. If we have a null pointer then return false from
OnCompositorSurfaceChanged(). CompositorBridgeParent::ResumeComposition()
will handle that by not resuming the compositor, like it already does
if WebRenderBridgeParent::Resume() fails.

Additonally, when we receive a pause event from GeckoView ensure that
we always set the mCompositorPaused flag to true, even if the
UiCompositorController is null. This avoids a possible cause of the
situation described above - if we receive a pause event (eg the app is
minimised) during compositor reinitialization (while the
UiCompositorController is temporarily null) we would not set that flag
to true, and would therefore resume compositing in to an invalid
surface.

Depends on D135117

Differential Revision: https://phabricator.services.mozilla.com/D135118
2022-01-07 10:25:53 +00:00
Jamie Nicol a76b0bdd13 Bug 1741156 - Initial GPU process implementation on Android. r=aosmond,agi
Declare a GPU process and corresponding Service in the
AndroidManifest. This is of a new class GeckoServiceGpuProcess which
inherits from GeckoServiceChildProcess, and provides a binder
interface ICompositorSurfaceManager which allows the parent process to
set the compositor Surface for a given widget ID, and the compositor
in the GPU process to look up the Surface for a widget ID. The
ICompositorSurfaceManager interface is exposed to the parent process
through a new method getCompositorSurfaceManager() in the
IChildProcess interface.

Add a new connection type for GPU processes to GeckoProcessManager,
along with a function to look up the GPU process connection and fetch
the ICompositorSurfaceManager binder. When the GPU process is launched
we store the returned binder in the GPUProcessHost, and when each
widget's compositor is created we store a reference to the binder in
the UiCompositorControllerChild.

Each nsWindow is given a unique ID, and whenever the Surface changes
due to an Android resume event, it sends the new surface for that ID
to the GPU process (if enabled) by calling
ICompositorSurfaceManager.onSurfaceChanged().

Stop inheriting AndroidCompositorWidget from InProcessCompositorWidget
and instead inherit from CompositorWidget directly. This class holds a
reference to the Surface that will be rendered in to. The
CompositorBridgeParent notifies the CompositorWidget whenever it has
been resumed, allowing it to fetch the new Surface. For the
cross-process CompositorWidgetParent implementation it fetches that
Surface from the CompositorSurfaceManagerService, whereas the
InProcessAndroidCompositorWidget can read it directly from the real
widget.

AndroidCompositorWidget::GetClientSize() can now calculate its size
from the Surface, rather than racily reading the value from the
nsWindow. This means RenderCompositorEGL and RenderCompositorOGLSWGL
can now use GetClientSize() again rather than querying their own size
from the Surface.

With this patch, setting layers.gpu-process.enabled to true will cause
us to launch a GPU process and render from it. We do not yet
gracefully recover from a GPU process crash, nor can we render
anything using SurfaceTextures (eg video or webgl). Those will come in
future patches.

Differential Revision: https://phabricator.services.mozilla.com/D131231
2021-11-29 20:52:31 +00:00
sotaro fa9fbb4325 Bug 1717572 - Remove gfxUtils::ConvertBGRAtoRGBA() call in AndroidCompositorWidget::EndRemoteDrawingInRegion() r=lsalzman,gfx-reviewers
gfxUtils::ConvertBGRAtoRGBA() could be removed. BGRA->RBGA conversion could be done by DrawTargetSkia::CopySurface() in RenderCompositorSWGL::CommitMappedBuffer(). Though DrawTargetCairo::CopySurface() does not do the conversion.

On Android, RenderCompositorSWGL is not expected to be used on release. It is only for testing for now.

Differential Revision: https://phabricator.services.mozilla.com/D118449
2021-06-22 23:22:50 +00:00
Lee Salzman 09c77bf86b Bug 1690216 - Clarify that StartRemoteDrawingInRegion does not actually modify the region. r=mattwoodrow
It caused us substantial confusion investigating this bug under the belief that
StartRemoteDrawingInRegion may have been modifying the dirty region. None of our
existing widget code anymore uses the API in this way, so it makes sense to just
force this dirty region to be const so that we no longer support the assumption
and alleviate confusion in the future about how our widget code actually behaves.

Depends on D106246

Differential Revision: https://phabricator.services.mozilla.com/D106247
2021-02-24 18:34:52 +00:00
sotaro a9e7314f2c Bug 1691895 - Make RenderCompositorSWGL work on android r=geckoview-reviewers,mattwoodrow,agi
Partial present is not supported yet with RenderCompositorSWGL on Android.

Differential Revision: https://phabricator.services.mozilla.com/D104654
2021-02-16 22:30:47 +00:00
Sylvestre Ledru e5a134f73a Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset
2018-11-30 11:46:48 +01:00
Randall Barker c955f482b1 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
This version of the Dynamic Toolbar moves the animation of the toolbar
from the Android UI thread to the compositor thread. All animation for
showing and hiding the toolbar are done with the compositor and a static
snapshot of the real toolbar.

MozReview-Commit-ID: BCe8zpbkWQt
2017-04-20 15:15:14 -07:00
Randall Barker 13a12ef164 Bug 1329362 - part 2, Add accessor functions for EGLNativeWindowType, ANativeWindow, and EGLSurface to AndroidCompositorWidget r=dvander,kats 2017-01-27 09:32:24 -08:00
Kartikaya Gupta 88d479e33e Bug 1311030 - Remove more code unused since the deletion of JPZ. r=snorp
MozReview-Commit-ID: 1p8aWShTrQf
2016-10-18 12:34:25 -04:00
Jim Chen e32ed5b400 Bug 1306083 - 1. Use AndroidCompositorWidget to access GeckoLayerClient; r=kats
Add AndroidCompositorWidget to act as the intermediary between gfx code
and GeckoLayerClient, in place of AndroidBridge. AndroidCompositorWidget
currently inherits from InProcessCompositorWidget, but when Android
eventually supports OOP compositing, it will be made to inherit from
CompositorWidget directly.
2016-10-03 12:26:00 -04:00