зеркало из 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 "SourceSurfaceRawData.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "gfxConfig.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "gfxPlatformFontList.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
|
@ -3054,8 +3053,6 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
|
|||
std::move(vrBridge), std::move(videoManager),
|
||||
namespaces);
|
||||
|
||||
InitSurfaceAllocator();
|
||||
|
||||
gpm->AddListener(this);
|
||||
|
||||
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
|
||||
|
@ -3228,28 +3225,6 @@ void ContentParent::OnCompositorUnexpectedShutdown() {
|
|||
Unused << SendReinitRendering(std::move(compositor), std::move(imageBridge),
|
||||
std::move(vrBridge), std::move(videoManager),
|
||||
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() {
|
||||
|
|
|
@ -722,11 +722,6 @@ class ContentParent final
|
|||
void OnVarChanged(const GfxVarUpdate& aVar) 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:
|
||||
/**
|
||||
* A map of the remote content process type to a list of content parents
|
||||
|
|
|
@ -92,8 +92,6 @@ GPUProcessManager::GPUProcessManager()
|
|||
mUnstableProcessAttempts(0),
|
||||
mTotalProcessAttempts(0),
|
||||
mDeviceResetCount(0),
|
||||
mAppInForeground(true),
|
||||
mNeedsRenderingReinit(false),
|
||||
mProcess(nullptr),
|
||||
mProcessToken(0),
|
||||
mProcessStable(true),
|
||||
|
@ -132,16 +130,6 @@ GPUProcessManager::Observer::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
mManager->OnXPCOMShutdown();
|
||||
} else if (!strcmp(aTopic, "nsPref:changed")) {
|
||||
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;
|
||||
}
|
||||
|
@ -150,9 +138,6 @@ void GPUProcessManager::OnXPCOMShutdown() {
|
|||
if (mObserver) {
|
||||
nsContentUtils::UnregisterShutdownObserver(mObserver);
|
||||
Preferences::RemoveObserver(mObserver, "");
|
||||
nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService();
|
||||
obsServ->RemoveObserver(mObserver, "application-foreground");
|
||||
obsServ->RemoveObserver(mObserver, "application-background");
|
||||
mObserver = nullptr;
|
||||
}
|
||||
|
||||
|
@ -189,9 +174,6 @@ void GPUProcessManager::LaunchGPUProcess() {
|
|||
mObserver = new Observer(this);
|
||||
nsContentUtils::RegisterShutdownObserver(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.
|
||||
|
@ -281,13 +263,6 @@ bool GPUProcessManager::MaybeDisableGPUProcess(const char* aMessage,
|
|||
}
|
||||
|
||||
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->WaitForLaunch()) {
|
||||
// If this fails, we should have fired OnProcessLaunchComplete and
|
||||
|
@ -569,9 +544,9 @@ void GPUProcessManager::DisableWebRender(wr::WebRenderError aError,
|
|||
const nsCString& aMsg) {
|
||||
if (DisableWebRenderConfig(aError, aMsg)) {
|
||||
if (mProcess) {
|
||||
DestroyRemoteCompositorSessions();
|
||||
RebuildRemoteSessions();
|
||||
} else {
|
||||
DestroyInProcessCompositorSessions();
|
||||
RebuildInProcessSessions();
|
||||
}
|
||||
NotifyListenersOnCompositeDeviceReset();
|
||||
}
|
||||
|
@ -637,7 +612,7 @@ void GPUProcessManager::OnInProcessDeviceReset(bool aTrackThreshold) {
|
|||
// Normally nsWindow::OnPaint() already handled it.
|
||||
gfxWindowsPlatform::GetPlatform()->HandleDeviceReset();
|
||||
#endif
|
||||
DestroyInProcessCompositorSessions();
|
||||
RebuildInProcessSessions();
|
||||
NotifyListenersOnCompositeDeviceReset();
|
||||
}
|
||||
|
||||
|
@ -649,7 +624,7 @@ void GPUProcessManager::OnRemoteProcessDeviceReset(GPUProcessHost* aHost) {
|
|||
return;
|
||||
}
|
||||
|
||||
DestroyRemoteCompositorSessions();
|
||||
RebuildRemoteSessions();
|
||||
NotifyListenersOnCompositeDeviceReset();
|
||||
}
|
||||
|
||||
|
@ -695,41 +670,40 @@ void GPUProcessManager::OnProcessUnexpectedShutdown(GPUProcessHost* aHost) {
|
|||
}
|
||||
|
||||
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:
|
||||
//
|
||||
// (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
|
||||
// that channel.
|
||||
// each channel owning a bridge to the GPU process, on the thread
|
||||
// owning that channel.
|
||||
//
|
||||
// (2) The first channel to process its ActorDestroy message will post a
|
||||
// message to the main thread to call NotifyRemoteActorDestroyed on the
|
||||
// GPUProcessManager, which calls OnProcessUnexpectedShutdown if it has
|
||||
// not handled shutdown for this process yet. OnProcessUnexpectedShutdown
|
||||
// is responsible for tearing down the old process and deciding whether
|
||||
// or not to disable the GPU process. It then calls this function,
|
||||
// HandleProcessLost.
|
||||
// message to the main thread to call NotifyRemoteActorDestroyed on
|
||||
// the GPUProcessManager, which calls OnProcessUnexpectedShutdown if
|
||||
// it has not handled shutdown for this process yet.
|
||||
//
|
||||
// (3) We then notify each widget that its session with the compositor is now
|
||||
// invalid. The widget is responsible for destroying its layer manager
|
||||
// and CompositorBridgeChild. Note that at this stage, not all actors may
|
||||
// have received ActorDestroy yet. CompositorBridgeChild may attempt to
|
||||
// send messages, and if this happens, it will probably report a
|
||||
// MsgDropped error. This is okay.
|
||||
// (3) We then notify each widget that its session with the compositor is
|
||||
// now invalid. The widget is responsible for destroying its layer
|
||||
// manager and CompositorBridgeChild. Note that at this stage, not
|
||||
// all actors may have received ActorDestroy yet. CompositorBridgeChild
|
||||
// may attempt to send messages, and if this happens, it will probably
|
||||
// report a MsgDropped error. This is okay.
|
||||
//
|
||||
// (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
|
||||
// to re-launch the GPU process. Or, on Android if the app is in the
|
||||
// background we may decide to wait until it comes to the foreground
|
||||
// before re-launching.
|
||||
// exist for the old compositor. We may make a decision on whether or
|
||||
// not to re-launch the GPU process. Currently, we do not relaunch it,
|
||||
// and any new compositors will be created in-process and will default
|
||||
// to software.
|
||||
//
|
||||
// (5) When we do decide to re-launch, or continue without a GPU process, we
|
||||
// notify each ContentParent of the lost connection. It will request new
|
||||
// endpoints from the GPUProcessManager and forward them to its
|
||||
// ContentChild. The parent-side of these endpoints may come from the
|
||||
// compositor thread of the UI process, or the compositor thread of the
|
||||
// GPU process. However, no actual compositors should exist yet.
|
||||
// (5) Next we notify each ContentParent of the lost connection. It will
|
||||
// request new endpoints from the GPUProcessManager and forward them
|
||||
// to its ContentChild. The parent-side of these endpoints may come
|
||||
// from the compositor thread of the UI process, or the compositor
|
||||
// thread of the GPU process. However, no actual compositors should
|
||||
// exist yet.
|
||||
//
|
||||
// (6) Each ContentChild will receive new endpoints. It will destroy its
|
||||
// Compositor/ImageBridgeChild singletons and recreate them, as well
|
||||
|
@ -742,15 +716,15 @@ void GPUProcessManager::HandleProcessLost() {
|
|||
// (b) [CONTENT] BrowserChild::ReinitRendering
|
||||
// (c) [CONTENT] BrowserChild::SendEnsureLayersConnected
|
||||
// (d) [UI] BrowserParent::RecvEnsureLayersConnected
|
||||
// (e) [UI] RemoteLayerTreeOwner::EnsureLayersConnected
|
||||
// (e) [UI] RenderFrame::EnsureLayersConnected
|
||||
// (f) [UI] CompositorBridgeChild::SendNotifyChildRecreated
|
||||
//
|
||||
// Note that at step (e), RemoteLayerTreeOwner will call
|
||||
// GetWindowRenderer on the nsIWidget owning the tab. This step ensures
|
||||
// that a compositor exists for the window. If we decided to launch a new
|
||||
// GPU Process, at this point we block until the process has launched and
|
||||
// we're able to create a new window compositor. Otherwise, if
|
||||
// compositing is now in-process, this will simply create a new
|
||||
// Note that at step (e), RenderFrame will call GetLayerManager
|
||||
// on the nsIWidget owning the tab. This step ensures that a compositor
|
||||
// exists for the window. If we decided to launch a new GPU Process,
|
||||
// at this point we block until the process has launched and we're
|
||||
// able to create a new window compositor. Otherwise, if compositing
|
||||
// is now in-process, this will simply create a new
|
||||
// CompositorBridgeParent in the UI process. If there are multiple tabs
|
||||
// in the same window, additional tabs will simply return the already-
|
||||
// established compositor.
|
||||
|
@ -761,34 +735,10 @@ void GPUProcessManager::HandleProcessLost() {
|
|||
// exists, and that the tab can forward layers.
|
||||
//
|
||||
// (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
|
||||
// next refresh tick and paint will ensure that one exists, again via
|
||||
// nsIWidget::GetWindowRenderer. On Android, we called
|
||||
// nsIWidgetListener::RequestRepaint back in step (3) to ensure this
|
||||
// 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;
|
||||
// applied, and the window will not have a new compositor just yet.
|
||||
// The next refresh tick and paint will ensure that one exists, again
|
||||
// via nsIWidget::GetLayerManager.
|
||||
RebuildRemoteSessions();
|
||||
|
||||
// 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
|
||||
|
@ -806,7 +756,7 @@ void GPUProcessManager::ReinitializeRendering() {
|
|||
}
|
||||
}
|
||||
|
||||
void GPUProcessManager::DestroyRemoteCompositorSessions() {
|
||||
void GPUProcessManager::RebuildRemoteSessions() {
|
||||
// Build a list of sessions to notify, since notification might delete
|
||||
// entries from the list.
|
||||
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
|
||||
// entries from the list.
|
||||
nsTArray<RefPtr<InProcessCompositorSession>> sessions;
|
||||
|
@ -1325,9 +1275,7 @@ class GPUMemoryReporter : public MemoryReportingProcess {
|
|||
};
|
||||
|
||||
RefPtr<MemoryReportingProcess> GPUProcessManager::GetProcessMemoryReporter() {
|
||||
// Ensure mProcess is non-null before calling EnsureGPUReady, to avoid
|
||||
// launching the process if it has not already been launched.
|
||||
if (!mProcess || !EnsureGPUReady()) {
|
||||
if (!EnsureGPUReady()) {
|
||||
return nullptr;
|
||||
}
|
||||
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
|
||||
// used, or one is launched and ready, this function returns immediately.
|
||||
// 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();
|
||||
|
||||
already_AddRefed<CompositorSession> CreateTopLevelCompositor(
|
||||
|
@ -233,8 +230,8 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
|
|||
void RegisterInProcessSession(InProcessCompositorSession* aSession);
|
||||
void UnregisterInProcessSession(InProcessCompositorSession* aSession);
|
||||
|
||||
void DestroyRemoteCompositorSessions();
|
||||
void DestroyInProcessCompositorSessions();
|
||||
void RebuildRemoteSessions();
|
||||
void RebuildInProcessSessions();
|
||||
|
||||
// Returns true if we crossed the threshold such that we should disable
|
||||
// acceleration.
|
||||
|
@ -265,8 +262,6 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
|
|||
void DestroyProcess(bool aUnexpectedShutdown = false);
|
||||
|
||||
void HandleProcessLost();
|
||||
// Reinitialize rendering following a GPU process loss.
|
||||
void ReinitializeRendering();
|
||||
|
||||
void EnsureVsyncIOThread();
|
||||
void ShutdownVsyncIOThread();
|
||||
|
@ -323,12 +318,6 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
|
|||
uint32_t mDeviceResetCount;
|
||||
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.
|
||||
GPUProcessHost* mProcess;
|
||||
uint64_t mProcessToken;
|
||||
|
|
|
@ -42,12 +42,5 @@ interface IChildProcess {
|
|||
* 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.
|
||||
*/
|
||||
ISurfaceAllocator getSurfaceAllocatorFromGpuProcess();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
ISurfaceAllocator getSurfaceAllocator();
|
||||
}
|
||||
|
|
|
@ -9,4 +9,6 @@ import org.mozilla.gecko.gfx.ISurfaceAllocator;
|
|||
|
||||
interface IProcessManager {
|
||||
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.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
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 ISurfaceAllocator sAllocator;
|
||||
|
@ -21,13 +23,23 @@ public final class SurfaceAllocator {
|
|||
// connection to the allocator service.
|
||||
private static final SparseArray<GeckoSurface> sSurfaces = new SparseArray<GeckoSurface>();
|
||||
|
||||
public static synchronized void connect(final @NonNull ISurfaceAllocator allocator) {
|
||||
if (allocator == null) {
|
||||
throw new IllegalArgumentException("SurfaceAllocator.connect() allocator must be non-null");
|
||||
private static synchronized void ensureConnection() {
|
||||
if (sAllocator != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
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()
|
||||
.linkToDeath(
|
||||
new IBinder.DeathRecipient() {
|
||||
|
@ -47,7 +59,6 @@ public final class SurfaceAllocator {
|
|||
}
|
||||
},
|
||||
0);
|
||||
sAllocator = allocator;
|
||||
} catch (final RemoteException e) {
|
||||
Log.w(LOGTAG, "Failed to connect to RemoteSurfaceAllocator", e);
|
||||
sAllocator = null;
|
||||
|
@ -58,6 +69,8 @@ public final class SurfaceAllocator {
|
|||
public static synchronized GeckoSurface acquireSurface(
|
||||
final int width, final int height, final boolean singleBufferMode) {
|
||||
try {
|
||||
ensureConnection();
|
||||
|
||||
if (sAllocator == null) {
|
||||
Log.w(LOGTAG, "Failed to acquire GeckoSurface: not connected");
|
||||
return null;
|
||||
|
|
|
@ -66,6 +66,37 @@ public final class GeckoProcessManager extends IProcessManager.Stub {
|
|||
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
|
||||
public static CompositorSurfaceManager getCompositorSurfaceManager() {
|
||||
final Selector selector = new Selector(GeckoProcessType.GPU);
|
||||
|
@ -74,43 +105,6 @@ public final class GeckoProcessManager extends IProcessManager.Stub {
|
|||
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. */
|
||||
public static final class Selector {
|
||||
private final GeckoProcessType mType;
|
||||
|
@ -251,14 +245,6 @@ public final class GeckoProcessManager extends IProcessManager.Stub {
|
|||
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
|
||||
protected void onBinderConnected(final IBinder service) {
|
||||
XPCOMEventTarget.assertOnLauncherThread();
|
||||
|
@ -336,7 +322,7 @@ public final class GeckoProcessManager extends IProcessManager.Stub {
|
|||
@Override
|
||||
protected void onBinderConnected(@NonNull final IChildProcess child) throws RemoteException {
|
||||
mCompositorSurfaceManager = new CompositorSurfaceManager(child.getCompositorSurfaceManager());
|
||||
mSurfaceAllocator = child.getSurfaceAllocatorFromGpuProcess();
|
||||
mSurfaceAllocator = child.getSurfaceAllocator();
|
||||
}
|
||||
|
||||
public CompositorSurfaceManager getCompositorSurfaceManager() {
|
||||
|
|
|
@ -14,7 +14,6 @@ import android.os.ParcelFileDescriptor;
|
|||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoThread;
|
||||
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.gfx.ICompositorSurfaceManager;
|
||||
import org.mozilla.gecko.gfx.ISurfaceAllocator;
|
||||
import org.mozilla.gecko.gfx.SurfaceAllocator;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
public class GeckoServiceChildProcess extends Service {
|
||||
|
@ -165,17 +163,10 @@ public class GeckoServiceChildProcess extends Service {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ISurfaceAllocator getSurfaceAllocatorFromGpuProcess() {
|
||||
Log.e(
|
||||
LOGTAG,
|
||||
"Invalid call to IChildProcess.getSurfaceAllocatorFromGpuProcess for non-GPU process");
|
||||
public ISurfaceAllocator getSurfaceAllocator() {
|
||||
Log.e(LOGTAG, "Invalid call to IChildProcess.getSurfaceAllocator for non-GPU process");
|
||||
throw new AssertionError(
|
||||
"Invalid call to IChildProcess.getSurfaceAllocatorFromGpuProcess for non-GPU process.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSurfaceAllocator(final @NonNull ISurfaceAllocator surfaceAllocator) {
|
||||
SurfaceAllocator.connect(surfaceAllocator);
|
||||
"Invalid call to IChildProcess.getSurfaceAllocator for non-GPU process.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,4 +202,12 @@ public class GeckoServiceChildProcess extends Service {
|
|||
mMemoryController.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
|
||||
public ISurfaceAllocator getSurfaceAllocatorFromGpuProcess() {
|
||||
public ISurfaceAllocator getSurfaceAllocator() {
|
||||
return RemoteSurfaceAllocator.getInstance();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1130,7 +1130,7 @@ class LayerViewSupport final
|
|||
}
|
||||
|
||||
nsWindow* gkWindow = acc->GetNsWindow();
|
||||
if (!gkWindow || !gkWindow->mCompositorBridgeChild) {
|
||||
if (!gkWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче