2017-10-27 16:10:06 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2016-06-10 22:27:24 -04:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "GPUProcessHost.h"
|
2016-06-10 22:37:03 -04:00
|
|
|
#include "chrome/common/process_watcher.h"
|
2020-04-05 03:50:33 +00:00
|
|
|
#include "gfxPlatform.h"
|
2022-02-07 16:44:18 +00:00
|
|
|
#include "mozilla/dom/ContentParent.h"
|
2020-04-05 03:50:33 +00:00
|
|
|
#include "mozilla/gfx/GPUChild.h"
|
2016-06-10 22:27:24 -04:00
|
|
|
#include "mozilla/gfx/Logging.h"
|
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
|
|
|
#include "mozilla/layers/SynchronousTask.h"
|
2017-04-24 09:46:09 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
2019-07-26 01:10:23 +00:00
|
|
|
#include "mozilla/StaticPrefs_layers.h"
|
2019-01-11 22:51:48 +00:00
|
|
|
#include "VRGPUChild.h"
|
2021-06-09 04:56:48 +00:00
|
|
|
#include "mozilla/ipc/ProcessUtils.h"
|
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
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
# include "mozilla/java/GeckoProcessManagerWrappers.h"
|
|
|
|
#endif
|
2016-06-10 22:27:24 -04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
2016-09-21 21:24:44 +12:00
|
|
|
using namespace ipc;
|
|
|
|
|
2016-06-10 22:27:24 -04:00
|
|
|
GPUProcessHost::GPUProcessHost(Listener* aListener)
|
|
|
|
: GeckoChildProcessHost(GeckoProcessType_GPU),
|
|
|
|
mListener(aListener),
|
|
|
|
mTaskFactory(this),
|
2016-06-10 22:37:03 -04:00
|
|
|
mLaunchPhase(LaunchPhase::Unlaunched),
|
2016-07-17 21:24:28 -07:00
|
|
|
mProcessToken(0),
|
2016-07-17 21:24:28 -07:00
|
|
|
mShutdownRequested(false),
|
|
|
|
mChannelClosed(false) {
|
2016-06-10 22:27:24 -04:00
|
|
|
MOZ_COUNT_CTOR(GPUProcessHost);
|
|
|
|
}
|
|
|
|
|
|
|
|
GPUProcessHost::~GPUProcessHost() { MOZ_COUNT_DTOR(GPUProcessHost); }
|
|
|
|
|
2018-05-08 10:31:52 -04:00
|
|
|
bool GPUProcessHost::Launch(StringVector aExtraOpts) {
|
2016-06-10 22:27:24 -04:00
|
|
|
MOZ_ASSERT(mLaunchPhase == LaunchPhase::Unlaunched);
|
|
|
|
MOZ_ASSERT(!mGPUChild);
|
Bug 1373739 - Make headless compositing Windows-compatible, in addition to Linux. r=dvander
To make the HeadlessCompositorWidget work under Windows as well as Linux, I had
to change the way that I hooked it into the existing CompositorWidget system.
Under GTK, the CompositorWidgetInitData and CompositorWidgetDelegate types
provided the information needed by the headless compositor widget already (the
widget client size). On Windows, however, the definitions of these types
differ, and the client size information is simply retrieved from the platform
APIs when needed.
After this patch, CompositorWidgetDelegate is renamed to
PlatformCompositorWidgetDelegate, and a new base class called
CompositorWidgetDelegate is added with "AsPlatformSpecificDelegate()" and
"AsHeadlessCompositorWidget()" methods. In non-headless mode, widgets use
AsPlatformSpecificDelegate() to access the Windows- and GTK-specific delegate
APIs. In headless mode, AsHeadlessCompositorWidget() is used to access the
singular CompositorWidget implementation for headless. Meanwhile, the
CompositorWidgetInitData IPDL type is made into a union which always contains a
headless-specific HeadlessCompositorWidgetInitData struct and under GTK and
Windows also contains an {X11,Win}CompositorWidgetInitData struct.
This also includes a small patch to ensure that the GPU process and
hardware-accelerated compositing are always disabled under headless mode. These
features weren't activated by default in the Linux environments I tested in, but
did end up activating (and then promptly crashing Firefox) when I tested on
Windows.
MozReview-Commit-ID: CocPoHBDV7H
--HG--
extra : rebase_source : 4581fa63aa3a9f32a8dc2672015a35b9be01b20f
2017-07-06 17:45:34 -07:00
|
|
|
MOZ_ASSERT(!gfxPlatform::IsHeadless());
|
2016-06-10 22:27:24 -04:00
|
|
|
|
2022-02-07 16:44:18 +00:00
|
|
|
mPrefSerializer = MakeUnique<ipc::SharedPreferenceSerializer>(
|
|
|
|
dom::ContentParent::ShouldSyncPreference);
|
2019-05-26 02:33:12 +00:00
|
|
|
if (!mPrefSerializer->SerializeToSharedMemory()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mPrefSerializer->AddSharedPrefCmdLineArgs(*this, aExtraOpts);
|
|
|
|
|
2017-06-19 13:12:00 -04:00
|
|
|
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
|
2019-02-09 20:13:30 +02:00
|
|
|
mSandboxLevel = Preferences::GetInt("security.sandbox.gpu.level");
|
2017-04-24 09:46:09 -07:00
|
|
|
#endif
|
|
|
|
|
2016-06-10 22:27:24 -04:00
|
|
|
mLaunchPhase = LaunchPhase::Waiting;
|
2016-10-20 11:33:40 -04:00
|
|
|
mLaunchTime = TimeStamp::Now();
|
|
|
|
|
2018-05-08 10:31:52 -04:00
|
|
|
if (!GeckoChildProcessHost::AsyncLaunch(aExtraOpts)) {
|
2016-06-10 22:27:24 -04:00
|
|
|
mLaunchPhase = LaunchPhase::Complete;
|
2019-05-25 10:12:49 +00:00
|
|
|
mPrefSerializer = nullptr;
|
2016-06-10 22:27:24 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GPUProcessHost::WaitForLaunch() {
|
|
|
|
if (mLaunchPhase == LaunchPhase::Complete) {
|
|
|
|
return !!mGPUChild;
|
|
|
|
}
|
|
|
|
|
2019-07-22 02:10:14 +00:00
|
|
|
int32_t timeoutMs =
|
|
|
|
StaticPrefs::layers_gpu_process_startup_timeout_ms_AtStartup();
|
2016-06-10 22:27:24 -04:00
|
|
|
|
2017-06-19 13:12:00 -04:00
|
|
|
// If one of the following environment variables are set we can effectively
|
|
|
|
// ignore the timeout - as we can guarantee the compositor process will be
|
|
|
|
// terminated
|
|
|
|
if (PR_GetEnv("MOZ_DEBUG_CHILD_PROCESS") ||
|
|
|
|
PR_GetEnv("MOZ_DEBUG_CHILD_PAUSE")) {
|
|
|
|
timeoutMs = 0;
|
|
|
|
}
|
|
|
|
|
2016-06-10 22:27:24 -04:00
|
|
|
// Our caller expects the connection to be finished after we return, so we
|
|
|
|
// immediately set up the IPDL actor and fire callbacks. The IO thread will
|
|
|
|
// still dispatch a notification to the main thread - we'll just ignore it.
|
|
|
|
bool result = GeckoChildProcessHost::WaitUntilConnected(timeoutMs);
|
|
|
|
InitAfterConnect(result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPUProcessHost::OnChannelConnected(int32_t peer_pid) {
|
|
|
|
MOZ_ASSERT(!NS_IsMainThread());
|
|
|
|
|
|
|
|
GeckoChildProcessHost::OnChannelConnected(peer_pid);
|
|
|
|
|
|
|
|
// Post a task to the main thread. Take the lock because mTaskFactory is not
|
|
|
|
// thread-safe.
|
|
|
|
RefPtr<Runnable> runnable;
|
|
|
|
{
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
runnable =
|
|
|
|
mTaskFactory.NewRunnableMethod(&GPUProcessHost::OnChannelConnectedTask);
|
|
|
|
}
|
|
|
|
NS_DispatchToMainThread(runnable);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPUProcessHost::OnChannelError() {
|
|
|
|
MOZ_ASSERT(!NS_IsMainThread());
|
|
|
|
|
|
|
|
GeckoChildProcessHost::OnChannelError();
|
|
|
|
|
|
|
|
// Post a task to the main thread. Take the lock because mTaskFactory is not
|
|
|
|
// thread-safe.
|
|
|
|
RefPtr<Runnable> runnable;
|
|
|
|
{
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
runnable =
|
|
|
|
mTaskFactory.NewRunnableMethod(&GPUProcessHost::OnChannelErrorTask);
|
|
|
|
}
|
|
|
|
NS_DispatchToMainThread(runnable);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPUProcessHost::OnChannelConnectedTask() {
|
|
|
|
if (mLaunchPhase == LaunchPhase::Waiting) {
|
|
|
|
InitAfterConnect(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPUProcessHost::OnChannelErrorTask() {
|
|
|
|
if (mLaunchPhase == LaunchPhase::Waiting) {
|
|
|
|
InitAfterConnect(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-17 21:24:28 -07:00
|
|
|
static uint64_t sProcessTokenCounter = 0;
|
|
|
|
|
2016-06-10 22:27:24 -04:00
|
|
|
void GPUProcessHost::InitAfterConnect(bool aSucceeded) {
|
|
|
|
MOZ_ASSERT(mLaunchPhase == LaunchPhase::Waiting);
|
|
|
|
MOZ_ASSERT(!mGPUChild);
|
|
|
|
|
|
|
|
mLaunchPhase = LaunchPhase::Complete;
|
2019-05-26 02:33:12 +00:00
|
|
|
mPrefSerializer = nullptr;
|
2016-06-10 22:27:24 -04:00
|
|
|
|
|
|
|
if (aSucceeded) {
|
2016-07-17 21:24:28 -07:00
|
|
|
mProcessToken = ++sProcessTokenCounter;
|
2016-06-10 22:37:03 -04:00
|
|
|
mGPUChild = MakeUnique<GPUChild>(this);
|
2020-02-06 22:41:56 +00:00
|
|
|
DebugOnly<bool> rv = mGPUChild->Open(
|
2021-06-22 18:17:23 +00:00
|
|
|
TakeInitialPort(), base::GetProcId(GetChildProcessHandle()));
|
2016-06-10 22:27:24 -04:00
|
|
|
MOZ_ASSERT(rv);
|
2016-06-26 23:33:20 -07:00
|
|
|
|
|
|
|
mGPUChild->Init();
|
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
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
nsCOMPtr<nsIEventTarget> launcherThread(GetIPCLauncher());
|
|
|
|
MOZ_ASSERT(launcherThread);
|
|
|
|
layers::SynchronousTask task(
|
|
|
|
"GeckoProcessManager::GetCompositorSurfaceManager");
|
|
|
|
|
|
|
|
launcherThread->Dispatch(NS_NewRunnableFunction(
|
|
|
|
"GeckoProcessManager::GetCompositorSurfaceManager", [&]() {
|
|
|
|
layers::AutoCompleteTask complete(&task);
|
|
|
|
mCompositorSurfaceManager =
|
|
|
|
java::GeckoProcessManager::GetCompositorSurfaceManager();
|
|
|
|
}));
|
|
|
|
|
|
|
|
task.Wait();
|
|
|
|
#endif
|
2016-06-10 22:27:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mListener) {
|
|
|
|
mListener->OnProcessLaunchComplete(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-08 19:08:17 +00:00
|
|
|
void GPUProcessHost::Shutdown(bool aUnexpectedShutdown) {
|
2016-06-10 22:37:03 -04:00
|
|
|
MOZ_ASSERT(!mShutdownRequested);
|
|
|
|
|
2016-06-10 22:27:24 -04:00
|
|
|
mListener = nullptr;
|
2016-06-10 22:37:03 -04:00
|
|
|
|
|
|
|
if (mGPUChild) {
|
|
|
|
// OnChannelClosed uses this to check if the shutdown was expected or
|
|
|
|
// unexpected.
|
|
|
|
mShutdownRequested = true;
|
|
|
|
|
2021-12-08 19:08:17 +00:00
|
|
|
if (aUnexpectedShutdown) {
|
|
|
|
mGPUChild->OnUnexpectedShutdown();
|
|
|
|
}
|
|
|
|
|
2016-07-17 21:24:28 -07:00
|
|
|
// The channel might already be closed if we got here unexpectedly.
|
|
|
|
if (!mChannelClosed) {
|
2019-01-11 22:51:48 +00:00
|
|
|
if (VRGPUChild::IsCreated()) {
|
|
|
|
VRGPUChild::Get()->Close();
|
|
|
|
}
|
2018-09-25 21:48:55 +00:00
|
|
|
mGPUChild->SendShutdownVR();
|
2016-07-17 21:24:28 -07:00
|
|
|
mGPUChild->Close();
|
|
|
|
}
|
2017-04-06 16:56:46 -07:00
|
|
|
|
|
|
|
#ifndef NS_FREE_PERMANENT_DATA
|
2016-06-10 22:37:03 -04:00
|
|
|
// No need to communicate shutdown, the GPU process doesn't need to
|
|
|
|
// communicate anything back.
|
|
|
|
KillHard("NormalShutdown");
|
|
|
|
#endif
|
|
|
|
|
2016-07-17 21:24:28 -07:00
|
|
|
// If we're shutting down unexpectedly, we're in the middle of handling an
|
|
|
|
// ActorDestroy for PGPUChild, which is still on the stack. We'll return
|
|
|
|
// back to OnChannelClosed.
|
|
|
|
//
|
|
|
|
// Otherwise, we'll wait for OnChannelClose to be called whenever PGPUChild
|
|
|
|
// acknowledges shutdown.
|
2016-06-10 22:37:03 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-10 22:27:24 -04:00
|
|
|
DestroyProcess();
|
|
|
|
}
|
|
|
|
|
2016-06-10 22:37:03 -04:00
|
|
|
void GPUProcessHost::OnChannelClosed() {
|
2017-10-23 16:18:24 -04:00
|
|
|
mChannelClosed = true;
|
|
|
|
|
|
|
|
if (!mShutdownRequested && mListener) {
|
2016-06-10 22:37:03 -04:00
|
|
|
// This is an unclean shutdown. Notify our listener that we're going away.
|
2017-10-23 16:18:24 -04:00
|
|
|
mListener->OnProcessUnexpectedShutdown(this);
|
|
|
|
} else {
|
|
|
|
DestroyProcess();
|
2016-06-10 22:37:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Release the actor.
|
2018-05-30 21:15:35 +02:00
|
|
|
GPUChild::Destroy(std::move(mGPUChild));
|
2016-06-10 22:37:03 -04:00
|
|
|
MOZ_ASSERT(!mGPUChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPUProcessHost::KillHard(const char* aReason) {
|
|
|
|
ProcessHandle handle = GetChildProcessHandle();
|
Bug 1658474 - Remove the blocking mode of IPC's KillProcess function. r=mccr8,media-playback-reviewers,alwu,bryce
`base::KillProcess`, with the `wait` parameter set to true, does a
bounded blocking wait for the process to exit by polling and sleeping in
a loop, with ad-hoc parameters. The only user of that case is the Gecko
Media Plugin code, which doesn't actually need it as discussed in bug
(comments 4-6); also, currently it's blocking the IPC I/O thread in the
parent process, which is not good for browser responsiveness.
Accordingly, this patch deletes that code and removes the parameter.
Differential Revision: https://phabricator.services.mozilla.com/D136662
2022-02-02 21:50:01 +00:00
|
|
|
if (!base::KillProcess(handle, base::PROCESS_END_KILLED_BY_USER)) {
|
2016-06-10 22:37:03 -04:00
|
|
|
NS_WARNING("failed to kill subprocess!");
|
|
|
|
}
|
|
|
|
|
|
|
|
SetAlreadyDead();
|
|
|
|
}
|
|
|
|
|
2016-07-17 21:24:28 -07:00
|
|
|
uint64_t GPUProcessHost::GetProcessToken() const { return mProcessToken; }
|
|
|
|
|
2016-10-31 15:44:40 -04:00
|
|
|
void GPUProcessHost::KillProcess() { KillHard("DiagnosticKill"); }
|
|
|
|
|
2021-12-08 19:08:17 +00:00
|
|
|
void GPUProcessHost::CrashProcess() { mGPUChild->SendCrashProcess(); }
|
|
|
|
|
2016-06-10 22:27:24 -04:00
|
|
|
void GPUProcessHost::DestroyProcess() {
|
|
|
|
// Cancel all tasks. We don't want anything triggering after our caller
|
|
|
|
// expects this to go away.
|
|
|
|
{
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
mTaskFactory.RevokeAll();
|
|
|
|
}
|
|
|
|
|
2020-07-02 22:59:24 +00:00
|
|
|
GetCurrentSerialEventTarget()->Dispatch(
|
2019-02-05 00:15:20 +00:00
|
|
|
NS_NewRunnableFunction("DestroyProcessRunnable", [this] { Destroy(); }));
|
2016-06-10 22:27:24 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
java::CompositorSurfaceManager::Param
|
|
|
|
GPUProcessHost::GetCompositorSurfaceManager() {
|
|
|
|
return mCompositorSurfaceManager;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-06-10 22:27:24 -04:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|