mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
2cf59fe695
In bug 1762424 we introduced a rendering path on Android using the SurfaceControl API, in order to work around a bug preventing recovery from a GPU process crash. However, the initial implementation caused this bug: repeatedly sending the same SurfaceControl objects over AIDL to the GPU process resulted in them being leaked, eventually causing severe display issues. Not only were we duplicating the SurfaceControl for each widget, but each time a widget was resized too. This patch reworks our usage of the SurfaceControl API to avoid ever having to send them cross-process. Instead, we create a single child SurfaceControl object for each SurfaceControl that is attached to a widget. (Typically there will be a single one shared between all widgets, changing only when the app is paused and resumed, which is much fewer than one per widget per resize.) In the parent process we obtain the Surfaces that will be rendered in to from the child SurfaceControls, and only send those Surfaces to the GPU process. Thankfully unlike SurfaceControls, sending Surfaces cross-process does not cause leaks. When the GPU process dies we simply destroy all of the child SurfaceControls, and recreate them again on-demand. Differential Revision: https://phabricator.services.mozilla.com/D147437
55 lines
1.8 KiB
C++
55 lines
1.8 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* 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 "CompositorWidgetParent.h"
|
|
#include "mozilla/Unused.h"
|
|
#include "mozilla/java/GeckoServiceGpuProcessWrappers.h"
|
|
#include "mozilla/widget/PlatformWidgetTypes.h"
|
|
|
|
namespace mozilla {
|
|
namespace widget {
|
|
|
|
CompositorWidgetParent::CompositorWidgetParent(
|
|
const CompositorWidgetInitData& aInitData,
|
|
const layers::CompositorOptions& aOptions)
|
|
: AndroidCompositorWidget(aInitData.get_AndroidCompositorWidgetInitData(),
|
|
aOptions) {
|
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_GPU);
|
|
}
|
|
|
|
CompositorWidgetParent::~CompositorWidgetParent() = default;
|
|
|
|
nsIWidget* CompositorWidgetParent::RealWidget() { return nullptr; }
|
|
|
|
void CompositorWidgetParent::ObserveVsync(VsyncObserver* aObserver) {
|
|
if (aObserver) {
|
|
Unused << SendObserveVsync();
|
|
} else {
|
|
Unused << SendUnobserveVsync();
|
|
}
|
|
mVsyncObserver = aObserver;
|
|
}
|
|
|
|
RefPtr<VsyncObserver> CompositorWidgetParent::GetVsyncObserver() const {
|
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_GPU);
|
|
return mVsyncObserver;
|
|
}
|
|
|
|
mozilla::ipc::IPCResult CompositorWidgetParent::RecvNotifyClientSizeChanged(
|
|
const LayoutDeviceIntSize& aClientSize) {
|
|
NotifyClientSizeChanged(aClientSize);
|
|
return IPC_OK();
|
|
}
|
|
|
|
void CompositorWidgetParent::OnCompositorSurfaceChanged() {
|
|
java::GeckoServiceGpuProcess::RemoteCompositorSurfaceManager::LocalRef
|
|
manager = java::GeckoServiceGpuProcess::RemoteCompositorSurfaceManager::
|
|
GetInstance();
|
|
mSurface = manager->GetCompositorSurface(mWidgetId);
|
|
}
|
|
|
|
} // namespace widget
|
|
} // namespace mozilla
|