зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1755381) for causing gtest failures on TestMediaDataDecoder.cpp. CLOSED TREE
Backed out changeset 255cda33f56e (bug 1755381) Backed out changeset 2c55863fbccc (bug 1755381)
This commit is contained in:
Родитель
889568f158
Коммит
e0e7542556
|
@ -48,7 +48,6 @@
|
||||||
#include "SandboxHal.h"
|
#include "SandboxHal.h"
|
||||||
#include "SourceSurfaceRawData.h"
|
#include "SourceSurfaceRawData.h"
|
||||||
#include "mozilla/ipc/URIUtils.h"
|
#include "mozilla/ipc/URIUtils.h"
|
||||||
#include "gfxConfig.h"
|
|
||||||
#include "gfxPlatform.h"
|
#include "gfxPlatform.h"
|
||||||
#include "gfxPlatformFontList.h"
|
#include "gfxPlatformFontList.h"
|
||||||
#include "mozilla/AutoRestore.h"
|
#include "mozilla/AutoRestore.h"
|
||||||
|
@ -3054,8 +3053,6 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
|
||||||
std::move(vrBridge), std::move(videoManager),
|
std::move(vrBridge), std::move(videoManager),
|
||||||
namespaces);
|
namespaces);
|
||||||
|
|
||||||
InitSurfaceAllocator();
|
|
||||||
|
|
||||||
gpm->AddListener(this);
|
gpm->AddListener(this);
|
||||||
|
|
||||||
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
|
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
|
||||||
|
@ -3228,28 +3225,6 @@ void ContentParent::OnCompositorUnexpectedShutdown() {
|
||||||
Unused << SendReinitRendering(std::move(compositor), std::move(imageBridge),
|
Unused << SendReinitRendering(std::move(compositor), std::move(imageBridge),
|
||||||
std::move(vrBridge), std::move(videoManager),
|
std::move(vrBridge), std::move(videoManager),
|
||||||
namespaces);
|
namespaces);
|
||||||
|
|
||||||
InitSurfaceAllocator();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentParent::InitSurfaceAllocator() {
|
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
|
||||||
nsCOMPtr<nsIEventTarget> launcherThread(GetIPCLauncher());
|
|
||||||
MOZ_ASSERT(launcherThread);
|
|
||||||
|
|
||||||
auto selector = java::GeckoProcessManager::Selector::New(
|
|
||||||
java::GeckoProcessType::CONTENT(), OtherPid());
|
|
||||||
|
|
||||||
bool gpuProcessEnabled = gfx::gfxConfig::IsEnabled(gfx::Feature::GPU_PROCESS);
|
|
||||||
|
|
||||||
launcherThread->Dispatch(NS_NewRunnableFunction(
|
|
||||||
"ContentParent::InitSurfaceAllocator()",
|
|
||||||
[selector = java::GeckoProcessManager::Selector::GlobalRef(selector),
|
|
||||||
gpuProcessEnabled]() {
|
|
||||||
java::GeckoProcessManager::SetChildProcessSurfaceAllocator(
|
|
||||||
selector, gpuProcessEnabled);
|
|
||||||
}));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentParent::OnCompositorDeviceReset() {
|
void ContentParent::OnCompositorDeviceReset() {
|
||||||
|
|
|
@ -722,11 +722,6 @@ class ContentParent final
|
||||||
void OnVarChanged(const GfxVarUpdate& aVar) override;
|
void OnVarChanged(const GfxVarUpdate& aVar) override;
|
||||||
void OnCompositorUnexpectedShutdown() override;
|
void OnCompositorUnexpectedShutdown() override;
|
||||||
|
|
||||||
// Sets the SurfaceAllocator the content process should use to allocate
|
|
||||||
// Surfaces on Android. Ideally this should be done in (Re)InitRendering,
|
|
||||||
// but unfortunately we must go via Java and AIDL rather than IPDL.
|
|
||||||
void InitSurfaceAllocator();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* A map of the remote content process type to a list of content parents
|
* A map of the remote content process type to a list of content parents
|
||||||
|
|
|
@ -92,8 +92,6 @@ GPUProcessManager::GPUProcessManager()
|
||||||
mUnstableProcessAttempts(0),
|
mUnstableProcessAttempts(0),
|
||||||
mTotalProcessAttempts(0),
|
mTotalProcessAttempts(0),
|
||||||
mDeviceResetCount(0),
|
mDeviceResetCount(0),
|
||||||
mAppInForeground(true),
|
|
||||||
mNeedsRenderingReinit(false),
|
|
||||||
mProcess(nullptr),
|
mProcess(nullptr),
|
||||||
mProcessToken(0),
|
mProcessToken(0),
|
||||||
mProcessStable(true),
|
mProcessStable(true),
|
||||||
|
@ -132,16 +130,6 @@ GPUProcessManager::Observer::Observe(nsISupports* aSubject, const char* aTopic,
|
||||||
mManager->OnXPCOMShutdown();
|
mManager->OnXPCOMShutdown();
|
||||||
} else if (!strcmp(aTopic, "nsPref:changed")) {
|
} else if (!strcmp(aTopic, "nsPref:changed")) {
|
||||||
mManager->OnPreferenceChange(aData);
|
mManager->OnPreferenceChange(aData);
|
||||||
} else if (!strcmp(aTopic, "application-foreground")) {
|
|
||||||
mManager->mAppInForeground = true;
|
|
||||||
if (mManager->mNeedsRenderingReinit) {
|
|
||||||
if (!mManager->mProcess && gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
|
|
||||||
mManager->LaunchGPUProcess();
|
|
||||||
}
|
|
||||||
mManager->ReinitializeRendering();
|
|
||||||
}
|
|
||||||
} else if (!strcmp(aTopic, "application-background")) {
|
|
||||||
mManager->mAppInForeground = false;
|
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -150,9 +138,6 @@ void GPUProcessManager::OnXPCOMShutdown() {
|
||||||
if (mObserver) {
|
if (mObserver) {
|
||||||
nsContentUtils::UnregisterShutdownObserver(mObserver);
|
nsContentUtils::UnregisterShutdownObserver(mObserver);
|
||||||
Preferences::RemoveObserver(mObserver, "");
|
Preferences::RemoveObserver(mObserver, "");
|
||||||
nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService();
|
|
||||||
obsServ->RemoveObserver(mObserver, "application-foreground");
|
|
||||||
obsServ->RemoveObserver(mObserver, "application-background");
|
|
||||||
mObserver = nullptr;
|
mObserver = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,9 +174,6 @@ void GPUProcessManager::LaunchGPUProcess() {
|
||||||
mObserver = new Observer(this);
|
mObserver = new Observer(this);
|
||||||
nsContentUtils::RegisterShutdownObserver(mObserver);
|
nsContentUtils::RegisterShutdownObserver(mObserver);
|
||||||
Preferences::AddStrongObserver(mObserver, "");
|
Preferences::AddStrongObserver(mObserver, "");
|
||||||
nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService();
|
|
||||||
obsServ->AddObserver(mObserver, "application-foreground", false);
|
|
||||||
obsServ->AddObserver(mObserver, "application-background", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the Vsync I/O thread so can use it as soon as the process launches.
|
// Start the Vsync I/O thread so can use it as soon as the process launches.
|
||||||
|
@ -281,13 +263,6 @@ bool GPUProcessManager::MaybeDisableGPUProcess(const char* aMessage,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GPUProcessManager::EnsureGPUReady() {
|
bool GPUProcessManager::EnsureGPUReady() {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
|
||||||
|
|
||||||
// Launch the GPU process if it is enabled but hasn't been (re-)launched yet.
|
|
||||||
if (!mProcess && gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
|
|
||||||
LaunchGPUProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mProcess && !mProcess->IsConnected()) {
|
if (mProcess && !mProcess->IsConnected()) {
|
||||||
if (!mProcess->WaitForLaunch()) {
|
if (!mProcess->WaitForLaunch()) {
|
||||||
// If this fails, we should have fired OnProcessLaunchComplete and
|
// If this fails, we should have fired OnProcessLaunchComplete and
|
||||||
|
@ -569,9 +544,9 @@ void GPUProcessManager::DisableWebRender(wr::WebRenderError aError,
|
||||||
const nsCString& aMsg) {
|
const nsCString& aMsg) {
|
||||||
if (DisableWebRenderConfig(aError, aMsg)) {
|
if (DisableWebRenderConfig(aError, aMsg)) {
|
||||||
if (mProcess) {
|
if (mProcess) {
|
||||||
DestroyRemoteCompositorSessions();
|
RebuildRemoteSessions();
|
||||||
} else {
|
} else {
|
||||||
DestroyInProcessCompositorSessions();
|
RebuildInProcessSessions();
|
||||||
}
|
}
|
||||||
NotifyListenersOnCompositeDeviceReset();
|
NotifyListenersOnCompositeDeviceReset();
|
||||||
}
|
}
|
||||||
|
@ -637,7 +612,7 @@ void GPUProcessManager::OnInProcessDeviceReset(bool aTrackThreshold) {
|
||||||
// Normally nsWindow::OnPaint() already handled it.
|
// Normally nsWindow::OnPaint() already handled it.
|
||||||
gfxWindowsPlatform::GetPlatform()->HandleDeviceReset();
|
gfxWindowsPlatform::GetPlatform()->HandleDeviceReset();
|
||||||
#endif
|
#endif
|
||||||
DestroyInProcessCompositorSessions();
|
RebuildInProcessSessions();
|
||||||
NotifyListenersOnCompositeDeviceReset();
|
NotifyListenersOnCompositeDeviceReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +624,7 @@ void GPUProcessManager::OnRemoteProcessDeviceReset(GPUProcessHost* aHost) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroyRemoteCompositorSessions();
|
RebuildRemoteSessions();
|
||||||
NotifyListenersOnCompositeDeviceReset();
|
NotifyListenersOnCompositeDeviceReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,41 +670,40 @@ void GPUProcessManager::OnProcessUnexpectedShutdown(GPUProcessHost* aHost) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUProcessManager::HandleProcessLost() {
|
void GPUProcessManager::HandleProcessLost() {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
|
||||||
|
LaunchGPUProcess();
|
||||||
|
}
|
||||||
|
|
||||||
// The shutdown and restart sequence for the GPU process is as follows:
|
// The shutdown and restart sequence for the GPU process is as follows:
|
||||||
//
|
//
|
||||||
// (1) The GPU process dies. IPDL will enqueue an ActorDestroy message on
|
// (1) The GPU process dies. IPDL will enqueue an ActorDestroy message on
|
||||||
// each channel owning a bridge to the GPU process, on the thread owning
|
// each channel owning a bridge to the GPU process, on the thread
|
||||||
// that channel.
|
// owning that channel.
|
||||||
//
|
//
|
||||||
// (2) The first channel to process its ActorDestroy message will post a
|
// (2) The first channel to process its ActorDestroy message will post a
|
||||||
// message to the main thread to call NotifyRemoteActorDestroyed on the
|
// message to the main thread to call NotifyRemoteActorDestroyed on
|
||||||
// GPUProcessManager, which calls OnProcessUnexpectedShutdown if it has
|
// the GPUProcessManager, which calls OnProcessUnexpectedShutdown if
|
||||||
// not handled shutdown for this process yet. OnProcessUnexpectedShutdown
|
// it has not handled shutdown for this process yet.
|
||||||
// is responsible for tearing down the old process and deciding whether
|
|
||||||
// or not to disable the GPU process. It then calls this function,
|
|
||||||
// HandleProcessLost.
|
|
||||||
//
|
//
|
||||||
// (3) We then notify each widget that its session with the compositor is now
|
// (3) We then notify each widget that its session with the compositor is
|
||||||
// invalid. The widget is responsible for destroying its layer manager
|
// now invalid. The widget is responsible for destroying its layer
|
||||||
// and CompositorBridgeChild. Note that at this stage, not all actors may
|
// manager and CompositorBridgeChild. Note that at this stage, not
|
||||||
// have received ActorDestroy yet. CompositorBridgeChild may attempt to
|
// all actors may have received ActorDestroy yet. CompositorBridgeChild
|
||||||
// send messages, and if this happens, it will probably report a
|
// may attempt to send messages, and if this happens, it will probably
|
||||||
// MsgDropped error. This is okay.
|
// report a MsgDropped error. This is okay.
|
||||||
//
|
//
|
||||||
// (4) At this point, the UI process has a clean slate: no layers should
|
// (4) At this point, the UI process has a clean slate: no layers should
|
||||||
// exist for the old compositor. We may make a decision on whether or not
|
// exist for the old compositor. We may make a decision on whether or
|
||||||
// to re-launch the GPU process. Or, on Android if the app is in the
|
// not to re-launch the GPU process. Currently, we do not relaunch it,
|
||||||
// background we may decide to wait until it comes to the foreground
|
// and any new compositors will be created in-process and will default
|
||||||
// before re-launching.
|
// to software.
|
||||||
//
|
//
|
||||||
// (5) When we do decide to re-launch, or continue without a GPU process, we
|
// (5) Next we notify each ContentParent of the lost connection. It will
|
||||||
// notify each ContentParent of the lost connection. It will request new
|
// request new endpoints from the GPUProcessManager and forward them
|
||||||
// endpoints from the GPUProcessManager and forward them to its
|
// to its ContentChild. The parent-side of these endpoints may come
|
||||||
// ContentChild. The parent-side of these endpoints may come from the
|
// from the compositor thread of the UI process, or the compositor
|
||||||
// compositor thread of the UI process, or the compositor thread of the
|
// thread of the GPU process. However, no actual compositors should
|
||||||
// GPU process. However, no actual compositors should exist yet.
|
// exist yet.
|
||||||
//
|
//
|
||||||
// (6) Each ContentChild will receive new endpoints. It will destroy its
|
// (6) Each ContentChild will receive new endpoints. It will destroy its
|
||||||
// Compositor/ImageBridgeChild singletons and recreate them, as well
|
// Compositor/ImageBridgeChild singletons and recreate them, as well
|
||||||
|
@ -742,15 +716,15 @@ void GPUProcessManager::HandleProcessLost() {
|
||||||
// (b) [CONTENT] BrowserChild::ReinitRendering
|
// (b) [CONTENT] BrowserChild::ReinitRendering
|
||||||
// (c) [CONTENT] BrowserChild::SendEnsureLayersConnected
|
// (c) [CONTENT] BrowserChild::SendEnsureLayersConnected
|
||||||
// (d) [UI] BrowserParent::RecvEnsureLayersConnected
|
// (d) [UI] BrowserParent::RecvEnsureLayersConnected
|
||||||
// (e) [UI] RemoteLayerTreeOwner::EnsureLayersConnected
|
// (e) [UI] RenderFrame::EnsureLayersConnected
|
||||||
// (f) [UI] CompositorBridgeChild::SendNotifyChildRecreated
|
// (f) [UI] CompositorBridgeChild::SendNotifyChildRecreated
|
||||||
//
|
//
|
||||||
// Note that at step (e), RemoteLayerTreeOwner will call
|
// Note that at step (e), RenderFrame will call GetLayerManager
|
||||||
// GetWindowRenderer on the nsIWidget owning the tab. This step ensures
|
// on the nsIWidget owning the tab. This step ensures that a compositor
|
||||||
// that a compositor exists for the window. If we decided to launch a new
|
// exists for the window. If we decided to launch a new GPU Process,
|
||||||
// GPU Process, at this point we block until the process has launched and
|
// at this point we block until the process has launched and we're
|
||||||
// we're able to create a new window compositor. Otherwise, if
|
// able to create a new window compositor. Otherwise, if compositing
|
||||||
// compositing is now in-process, this will simply create a new
|
// is now in-process, this will simply create a new
|
||||||
// CompositorBridgeParent in the UI process. If there are multiple tabs
|
// CompositorBridgeParent in the UI process. If there are multiple tabs
|
||||||
// in the same window, additional tabs will simply return the already-
|
// in the same window, additional tabs will simply return the already-
|
||||||
// established compositor.
|
// established compositor.
|
||||||
|
@ -761,34 +735,10 @@ void GPUProcessManager::HandleProcessLost() {
|
||||||
// exists, and that the tab can forward layers.
|
// exists, and that the tab can forward layers.
|
||||||
//
|
//
|
||||||
// (8) Last, if the window had no remote tabs, step (7) will not have
|
// (8) Last, if the window had no remote tabs, step (7) will not have
|
||||||
// applied, and the window will not have a new compositor just yet. The
|
// applied, and the window will not have a new compositor just yet.
|
||||||
// next refresh tick and paint will ensure that one exists, again via
|
// The next refresh tick and paint will ensure that one exists, again
|
||||||
// nsIWidget::GetWindowRenderer. On Android, we called
|
// via nsIWidget::GetLayerManager.
|
||||||
// nsIWidgetListener::RequestRepaint back in step (3) to ensure this
|
RebuildRemoteSessions();
|
||||||
// tick occurs, but on other platforms this is not necessary.
|
|
||||||
|
|
||||||
DestroyRemoteCompositorSessions();
|
|
||||||
|
|
||||||
// On Android we want to avoid restarting the GPU process immediately if it
|
|
||||||
// was killed and the app is in the background. Just set the flag saying we
|
|
||||||
// need to reinitialize once the app is foregrounded again, and return early.
|
|
||||||
// If the GPU process has been disabled we can continue re-initializing
|
|
||||||
// immediately.
|
|
||||||
if (!mAppInForeground && gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
|
|
||||||
mNeedsRenderingReinit = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Launch the process if it is enabled and hasn't already been relaunched.
|
|
||||||
if (!mProcess && gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
|
|
||||||
LaunchGPUProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
ReinitializeRendering();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GPUProcessManager::ReinitializeRendering() {
|
|
||||||
mNeedsRenderingReinit = false;
|
|
||||||
|
|
||||||
// Notify content. This will ensure that each content process re-establishes
|
// Notify content. This will ensure that each content process re-establishes
|
||||||
// a connection to the compositor thread (whether it's in-process or in a
|
// a connection to the compositor thread (whether it's in-process or in a
|
||||||
|
@ -806,7 +756,7 @@ void GPUProcessManager::ReinitializeRendering() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUProcessManager::DestroyRemoteCompositorSessions() {
|
void GPUProcessManager::RebuildRemoteSessions() {
|
||||||
// Build a list of sessions to notify, since notification might delete
|
// Build a list of sessions to notify, since notification might delete
|
||||||
// entries from the list.
|
// entries from the list.
|
||||||
nsTArray<RefPtr<RemoteCompositorSession>> sessions;
|
nsTArray<RefPtr<RemoteCompositorSession>> sessions;
|
||||||
|
@ -821,7 +771,7 @@ void GPUProcessManager::DestroyRemoteCompositorSessions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUProcessManager::DestroyInProcessCompositorSessions() {
|
void GPUProcessManager::RebuildInProcessSessions() {
|
||||||
// Build a list of sessions to notify, since notification might delete
|
// Build a list of sessions to notify, since notification might delete
|
||||||
// entries from the list.
|
// entries from the list.
|
||||||
nsTArray<RefPtr<InProcessCompositorSession>> sessions;
|
nsTArray<RefPtr<InProcessCompositorSession>> sessions;
|
||||||
|
@ -1325,9 +1275,7 @@ class GPUMemoryReporter : public MemoryReportingProcess {
|
||||||
};
|
};
|
||||||
|
|
||||||
RefPtr<MemoryReportingProcess> GPUProcessManager::GetProcessMemoryReporter() {
|
RefPtr<MemoryReportingProcess> GPUProcessManager::GetProcessMemoryReporter() {
|
||||||
// Ensure mProcess is non-null before calling EnsureGPUReady, to avoid
|
if (!EnsureGPUReady()) {
|
||||||
// launching the process if it has not already been launched.
|
|
||||||
if (!mProcess || !EnsureGPUReady()) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return new GPUMemoryReporter();
|
return new GPUMemoryReporter();
|
||||||
|
|
|
@ -93,9 +93,6 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
|
||||||
// Ensure that GPU-bound methods can be used. If no GPU process is being
|
// Ensure that GPU-bound methods can be used. If no GPU process is being
|
||||||
// used, or one is launched and ready, this function returns immediately.
|
// used, or one is launched and ready, this function returns immediately.
|
||||||
// Otherwise it blocks until the GPU process has finished launching.
|
// Otherwise it blocks until the GPU process has finished launching.
|
||||||
// If the GPU process is enabled but has not yet been launched then this will
|
|
||||||
// launch the process. If that is not desired then check that return value of
|
|
||||||
// Process() is non-null before calling.
|
|
||||||
bool EnsureGPUReady();
|
bool EnsureGPUReady();
|
||||||
|
|
||||||
already_AddRefed<CompositorSession> CreateTopLevelCompositor(
|
already_AddRefed<CompositorSession> CreateTopLevelCompositor(
|
||||||
|
@ -233,8 +230,8 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
|
||||||
void RegisterInProcessSession(InProcessCompositorSession* aSession);
|
void RegisterInProcessSession(InProcessCompositorSession* aSession);
|
||||||
void UnregisterInProcessSession(InProcessCompositorSession* aSession);
|
void UnregisterInProcessSession(InProcessCompositorSession* aSession);
|
||||||
|
|
||||||
void DestroyRemoteCompositorSessions();
|
void RebuildRemoteSessions();
|
||||||
void DestroyInProcessCompositorSessions();
|
void RebuildInProcessSessions();
|
||||||
|
|
||||||
// Returns true if we crossed the threshold such that we should disable
|
// Returns true if we crossed the threshold such that we should disable
|
||||||
// acceleration.
|
// acceleration.
|
||||||
|
@ -265,8 +262,6 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
|
||||||
void DestroyProcess(bool aUnexpectedShutdown = false);
|
void DestroyProcess(bool aUnexpectedShutdown = false);
|
||||||
|
|
||||||
void HandleProcessLost();
|
void HandleProcessLost();
|
||||||
// Reinitialize rendering following a GPU process loss.
|
|
||||||
void ReinitializeRendering();
|
|
||||||
|
|
||||||
void EnsureVsyncIOThread();
|
void EnsureVsyncIOThread();
|
||||||
void ShutdownVsyncIOThread();
|
void ShutdownVsyncIOThread();
|
||||||
|
@ -323,12 +318,6 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
|
||||||
uint32_t mDeviceResetCount;
|
uint32_t mDeviceResetCount;
|
||||||
TimeStamp mDeviceResetLastTime;
|
TimeStamp mDeviceResetLastTime;
|
||||||
|
|
||||||
// Keeps track of whether not the application is in the foreground on android.
|
|
||||||
bool mAppInForeground;
|
|
||||||
// Whether we must finish re-initializing rendering following a process loss
|
|
||||||
// where we decided not to re-launch the process immediately.
|
|
||||||
bool mNeedsRenderingReinit;
|
|
||||||
|
|
||||||
// Fields that are associated with the current GPU process.
|
// Fields that are associated with the current GPU process.
|
||||||
GPUProcessHost* mProcess;
|
GPUProcessHost* mProcess;
|
||||||
uint64_t mProcessToken;
|
uint64_t mProcessToken;
|
||||||
|
|
|
@ -42,12 +42,5 @@ interface IChildProcess {
|
||||||
* Returns the interface that other processes should use to allocate Surfaces to be
|
* Returns the interface that other processes should use to allocate Surfaces to be
|
||||||
* consumed by the GPU process. Must only be called for a GPU child process type.
|
* consumed by the GPU process. Must only be called for a GPU child process type.
|
||||||
*/
|
*/
|
||||||
ISurfaceAllocator getSurfaceAllocatorFromGpuProcess();
|
ISurfaceAllocator getSurfaceAllocator();
|
||||||
|
|
||||||
/**
|
|
||||||
* Connects the child process' SurfaceAllocator to the specified RemoteSurfaceAllocator.
|
|
||||||
* Must be called after creating the child process and after rendering has been reinitialized
|
|
||||||
* following the GPU process being killed, to allow the child process to allocate Surfaces.
|
|
||||||
*/
|
|
||||||
oneway void setSurfaceAllocator(in ISurfaceAllocator surfaceAllocator);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,4 +9,6 @@ import org.mozilla.gecko.gfx.ISurfaceAllocator;
|
||||||
|
|
||||||
interface IProcessManager {
|
interface IProcessManager {
|
||||||
void getEditableParent(in IGeckoEditableChild child, long contentId, long tabId);
|
void getEditableParent(in IGeckoEditableChild child, long contentId, long tabId);
|
||||||
|
// Returns the interface that child processes should use to allocate Surfaces.
|
||||||
|
ISurfaceAllocator getSurfaceAllocator();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,12 @@ import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import androidx.annotation.NonNull;
|
import org.mozilla.gecko.GeckoAppShell;
|
||||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||||
|
import org.mozilla.gecko.process.GeckoProcessManager;
|
||||||
|
import org.mozilla.gecko.process.GeckoServiceChildProcess;
|
||||||
|
|
||||||
public final class SurfaceAllocator {
|
/* package */ final class SurfaceAllocator {
|
||||||
private static final String LOGTAG = "SurfaceAllocator";
|
private static final String LOGTAG = "SurfaceAllocator";
|
||||||
|
|
||||||
private static ISurfaceAllocator sAllocator;
|
private static ISurfaceAllocator sAllocator;
|
||||||
|
@ -21,13 +23,23 @@ public final class SurfaceAllocator {
|
||||||
// connection to the allocator service.
|
// connection to the allocator service.
|
||||||
private static final SparseArray<GeckoSurface> sSurfaces = new SparseArray<GeckoSurface>();
|
private static final SparseArray<GeckoSurface> sSurfaces = new SparseArray<GeckoSurface>();
|
||||||
|
|
||||||
public static synchronized void connect(final @NonNull ISurfaceAllocator allocator) {
|
private static synchronized void ensureConnection() {
|
||||||
if (allocator == null) {
|
if (sAllocator != null) {
|
||||||
throw new IllegalArgumentException("SurfaceAllocator.connect() allocator must be non-null");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
allocator
|
if (GeckoAppShell.isParentProcess()) {
|
||||||
|
sAllocator = GeckoProcessManager.getInstance().getSurfaceAllocator();
|
||||||
|
} else {
|
||||||
|
sAllocator = GeckoServiceChildProcess.getSurfaceAllocator();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sAllocator == null) {
|
||||||
|
Log.w(LOGTAG, "Failed to connect to RemoteSurfaceAllocator");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sAllocator
|
||||||
.asBinder()
|
.asBinder()
|
||||||
.linkToDeath(
|
.linkToDeath(
|
||||||
new IBinder.DeathRecipient() {
|
new IBinder.DeathRecipient() {
|
||||||
|
@ -47,7 +59,6 @@ public final class SurfaceAllocator {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
0);
|
0);
|
||||||
sAllocator = allocator;
|
|
||||||
} catch (final RemoteException e) {
|
} catch (final RemoteException e) {
|
||||||
Log.w(LOGTAG, "Failed to connect to RemoteSurfaceAllocator", e);
|
Log.w(LOGTAG, "Failed to connect to RemoteSurfaceAllocator", e);
|
||||||
sAllocator = null;
|
sAllocator = null;
|
||||||
|
@ -58,6 +69,8 @@ public final class SurfaceAllocator {
|
||||||
public static synchronized GeckoSurface acquireSurface(
|
public static synchronized GeckoSurface acquireSurface(
|
||||||
final int width, final int height, final boolean singleBufferMode) {
|
final int width, final int height, final boolean singleBufferMode) {
|
||||||
try {
|
try {
|
||||||
|
ensureConnection();
|
||||||
|
|
||||||
if (sAllocator == null) {
|
if (sAllocator == null) {
|
||||||
Log.w(LOGTAG, "Failed to acquire GeckoSurface: not connected");
|
Log.w(LOGTAG, "Failed to acquire GeckoSurface: not connected");
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -66,6 +66,37 @@ public final class GeckoProcessManager extends IProcessManager.Stub {
|
||||||
nativeGetEditableParent(child, contentId, tabId);
|
nativeGetEditableParent(child, contentId, tabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the surface allocator interface to be used by child processes to allocate Surfaces. The
|
||||||
|
* service bound to the returned interface may live in either the GPU process or parent process.
|
||||||
|
*/
|
||||||
|
@Override // IProcessManager
|
||||||
|
public ISurfaceAllocator getSurfaceAllocator() {
|
||||||
|
final GeckoResult<Boolean> gpuReady = GeckoAppShell.ensureGpuProcessReady();
|
||||||
|
|
||||||
|
try {
|
||||||
|
final GeckoResult<ISurfaceAllocator> allocator = new GeckoResult<>();
|
||||||
|
if (gpuReady.poll(1000)) {
|
||||||
|
// The GPU process is enabled and ready, so ask it for its surface allocator.
|
||||||
|
XPCOMEventTarget.runOnLauncherThread(
|
||||||
|
() -> {
|
||||||
|
final Selector selector = new Selector(GeckoProcessType.GPU);
|
||||||
|
final GpuProcessConnection conn =
|
||||||
|
(GpuProcessConnection) INSTANCE.mConnections.getExistingConnection(selector);
|
||||||
|
|
||||||
|
allocator.complete(conn.getSurfaceAllocator());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// The GPU process is disabled, so return the parent process allocator instance.
|
||||||
|
allocator.complete(RemoteSurfaceAllocator.getInstance());
|
||||||
|
}
|
||||||
|
return allocator.poll(100);
|
||||||
|
} catch (final Throwable e) {
|
||||||
|
Log.e(LOGTAG, "Error in getSurfaceAllocator", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@WrapForJNI
|
@WrapForJNI
|
||||||
public static CompositorSurfaceManager getCompositorSurfaceManager() {
|
public static CompositorSurfaceManager getCompositorSurfaceManager() {
|
||||||
final Selector selector = new Selector(GeckoProcessType.GPU);
|
final Selector selector = new Selector(GeckoProcessType.GPU);
|
||||||
|
@ -74,43 +105,6 @@ public final class GeckoProcessManager extends IProcessManager.Stub {
|
||||||
return conn.getCompositorSurfaceManager();
|
return conn.getCompositorSurfaceManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Connects the specified child process' SurfaceAllocator. Should be called after creating the
|
|
||||||
* child process, and after rendering has been reinitialized following the a GPU process loss, to
|
|
||||||
* allow the child process to allocate Surfaces.
|
|
||||||
*
|
|
||||||
* @param selector Selector identifying the child process to connect.
|
|
||||||
* @param gpuProcessEnabled Whether the GPU process is enabled.
|
|
||||||
*/
|
|
||||||
@WrapForJNI
|
|
||||||
public static void setChildProcessSurfaceAllocator(
|
|
||||||
final Selector selector, final boolean gpuProcessEnabled) {
|
|
||||||
XPCOMEventTarget.assertOnLauncherThread();
|
|
||||||
final ChildConnection conn = INSTANCE.mConnections.getExistingConnection(selector);
|
|
||||||
if (conn == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gpuProcessEnabled) {
|
|
||||||
// If the GPU process is enabled then attempt to connect the child process to the GPU process'
|
|
||||||
// surface allocator. If the GPU process has died then we may be unable to find the
|
|
||||||
// connection, in which case do nothing - this function will be called again once rendering
|
|
||||||
// has been reinitialized.
|
|
||||||
final Selector gpuSelector = new Selector(GeckoProcessType.GPU);
|
|
||||||
final GpuProcessConnection gpuConn =
|
|
||||||
(GpuProcessConnection) INSTANCE.mConnections.getExistingConnection(gpuSelector);
|
|
||||||
if (gpuConn != null) {
|
|
||||||
conn.setSurfaceAllocator(gpuConn.getSurfaceAllocator());
|
|
||||||
} else {
|
|
||||||
Log.w(LOGTAG, "setSurfaceAllocator called with GPU process enabled but not running");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// If the GPU process is disabled then connect the child process to the parent process'
|
|
||||||
// surface allocator
|
|
||||||
conn.setSurfaceAllocator(RemoteSurfaceAllocator.getInstance());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Gecko uses this class to uniquely identify a process managed by GeckoProcessManager. */
|
/** Gecko uses this class to uniquely identify a process managed by GeckoProcessManager. */
|
||||||
public static final class Selector {
|
public static final class Selector {
|
||||||
private final GeckoProcessType mType;
|
private final GeckoProcessType mType;
|
||||||
|
@ -251,14 +245,6 @@ public final class GeckoProcessManager extends IProcessManager.Stub {
|
||||||
return GeckoResult.fromValue(null);
|
return GeckoResult.fromValue(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSurfaceAllocator(final ISurfaceAllocator surfaceAllocator) {
|
|
||||||
try {
|
|
||||||
mChild.setSurfaceAllocator(surfaceAllocator);
|
|
||||||
} catch (final RemoteException e) {
|
|
||||||
Log.w(LOGTAG, "Error calling IChildProcess.setSurfaceAllocator()", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBinderConnected(final IBinder service) {
|
protected void onBinderConnected(final IBinder service) {
|
||||||
XPCOMEventTarget.assertOnLauncherThread();
|
XPCOMEventTarget.assertOnLauncherThread();
|
||||||
|
@ -336,7 +322,7 @@ public final class GeckoProcessManager extends IProcessManager.Stub {
|
||||||
@Override
|
@Override
|
||||||
protected void onBinderConnected(@NonNull final IChildProcess child) throws RemoteException {
|
protected void onBinderConnected(@NonNull final IChildProcess child) throws RemoteException {
|
||||||
mCompositorSurfaceManager = new CompositorSurfaceManager(child.getCompositorSurfaceManager());
|
mCompositorSurfaceManager = new CompositorSurfaceManager(child.getCompositorSurfaceManager());
|
||||||
mSurfaceAllocator = child.getSurfaceAllocatorFromGpuProcess();
|
mSurfaceAllocator = child.getSurfaceAllocator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompositorSurfaceManager getCompositorSurfaceManager() {
|
public CompositorSurfaceManager getCompositorSurfaceManager() {
|
||||||
|
|
|
@ -14,7 +14,6 @@ import android.os.ParcelFileDescriptor;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import org.mozilla.gecko.GeckoAppShell;
|
import org.mozilla.gecko.GeckoAppShell;
|
||||||
import org.mozilla.gecko.GeckoThread;
|
import org.mozilla.gecko.GeckoThread;
|
||||||
import org.mozilla.gecko.GeckoThread.FileDescriptors;
|
import org.mozilla.gecko.GeckoThread.FileDescriptors;
|
||||||
|
@ -23,7 +22,6 @@ import org.mozilla.gecko.IGeckoEditableChild;
|
||||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||||
import org.mozilla.gecko.gfx.ICompositorSurfaceManager;
|
import org.mozilla.gecko.gfx.ICompositorSurfaceManager;
|
||||||
import org.mozilla.gecko.gfx.ISurfaceAllocator;
|
import org.mozilla.gecko.gfx.ISurfaceAllocator;
|
||||||
import org.mozilla.gecko.gfx.SurfaceAllocator;
|
|
||||||
import org.mozilla.gecko.util.ThreadUtils;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
|
|
||||||
public class GeckoServiceChildProcess extends Service {
|
public class GeckoServiceChildProcess extends Service {
|
||||||
|
@ -165,17 +163,10 @@ public class GeckoServiceChildProcess extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ISurfaceAllocator getSurfaceAllocatorFromGpuProcess() {
|
public ISurfaceAllocator getSurfaceAllocator() {
|
||||||
Log.e(
|
Log.e(LOGTAG, "Invalid call to IChildProcess.getSurfaceAllocator for non-GPU process");
|
||||||
LOGTAG,
|
|
||||||
"Invalid call to IChildProcess.getSurfaceAllocatorFromGpuProcess for non-GPU process");
|
|
||||||
throw new AssertionError(
|
throw new AssertionError(
|
||||||
"Invalid call to IChildProcess.getSurfaceAllocatorFromGpuProcess for non-GPU process.");
|
"Invalid call to IChildProcess.getSurfaceAllocator for non-GPU process.");
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSurfaceAllocator(final @NonNull ISurfaceAllocator surfaceAllocator) {
|
|
||||||
SurfaceAllocator.connect(surfaceAllocator);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,4 +202,12 @@ public class GeckoServiceChildProcess extends Service {
|
||||||
mMemoryController.onLowMemory();
|
mMemoryController.onLowMemory();
|
||||||
super.onLowMemory();
|
super.onLowMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the surface allocator interface that should be used by this process to allocate
|
||||||
|
* Surfaces, for consumption in either the GPU process or parent process.
|
||||||
|
*/
|
||||||
|
public static ISurfaceAllocator getSurfaceAllocator() throws RemoteException {
|
||||||
|
return sProcessManager.getSurfaceAllocator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class GeckoServiceGpuProcess extends GeckoServiceChildProcess {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ISurfaceAllocator getSurfaceAllocatorFromGpuProcess() {
|
public ISurfaceAllocator getSurfaceAllocator() {
|
||||||
return RemoteSurfaceAllocator.getInstance();
|
return RemoteSurfaceAllocator.getInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1130,7 +1130,7 @@ class LayerViewSupport final
|
||||||
}
|
}
|
||||||
|
|
||||||
nsWindow* gkWindow = acc->GetNsWindow();
|
nsWindow* gkWindow = acc->GetNsWindow();
|
||||||
if (!gkWindow || !gkWindow->mCompositorBridgeChild) {
|
if (!gkWindow) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче