Bug 1684991 - Start the RDD process early. r=media-playback-reviewers,alwu

This patch makes it so that we launch the RDD process relatively early
in the Firefox startup. This will improve the latency when we began
playback for the first video.

Differential Revision: https://phabricator.services.mozilla.com/D229427
This commit is contained in:
Andrew Osmond 2024-11-19 02:31:01 +00:00
parent 9edf24dd1b
commit 7c0050f3a5
7 changed files with 43 additions and 4 deletions

View File

@ -116,6 +116,7 @@
#include "mozilla/layers/IAPZCTreeManager.h" // for layers::ZoomToRectBehavior
#include "mozilla/dom/Document.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/RDDProcessManager.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/gfx/gfxVars.h"
@ -4380,6 +4381,18 @@ nsDOMWindowUtils::GetGpuProcessPid(int32_t* aPid) {
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetRddProcessPid(int32_t* aPid) {
RDDProcessManager* pm = RDDProcessManager::Get();
if (pm) {
*aPid = pm->RDDProcessPid();
} else {
*aPid = -1;
}
return NS_OK;
}
struct StateTableEntry {
const char* mStateString;
ElementState mState;

View File

@ -2129,6 +2129,11 @@ interface nsIDOMWindowUtils : nsISupports {
*/
readonly attribute int32_t gpuProcessPid;
/**
* Returns the RDD process pid, or -1 if there is no RDD process.
*/
readonly attribute int32_t rddProcessPid;
/**
* Returns usage data for a given storage object.
*

View File

@ -68,6 +68,7 @@
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/RecursiveMutex.h"
#include "mozilla/RDDProcessManager.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/ScriptPreloader.h"
#include "mozilla/Components.h"
@ -2964,6 +2965,12 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
gpm->AddListener(this);
if (StaticPrefs::media_rdd_process_enabled()) {
// Ensure the RDD process has been started.
RDDProcessManager* rdd = RDDProcessManager::Get();
rdd->LaunchRDDProcess();
}
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
// This looks like a lot of work, but in a normal browser session we just

View File

@ -132,7 +132,12 @@
socketProcessRunning = 1;
}
let m2 = (vsizes.length == (4 + socketProcessRunning + ChromeUtils.aliveUtilityProcesses) &&
let rddProcessRunning = 0;
if (window.windowUtils.rddProcessPid != -1) {
rddProcessRunning = 1;
}
let m2 = (vsizes.length == (4 + socketProcessRunning + rddProcessRunning + ChromeUtils.aliveUtilityProcesses) &&
endOfBrowsers.length == 3);
ok(m2, "three content processes present in loaded data");
good = good && !!m2;

View File

@ -105,7 +105,7 @@
SimpleTest.waitForClipboard(
function(aActual) {
mostRecentActual = aActual;
let rslt = aActual.trim() === aExpected.trim();
let rslt = aActual.trim().startsWith(aExpected.trim());
if (!rslt) {
// Try copying again.
synthesizeKey("A", {accelKey: true});

View File

@ -237,7 +237,11 @@
if (SpecialPowers.Services.io.socketProcessLaunched) {
socketProcessRunning = 1;
}
is(aAmounts.length, 1 + socketProcessRunning,
let rddProcessRunning = 0;
if (window.windowUtils.rddProcessPid != -1) {
rddProcessRunning = 1;
}
is(aAmounts.length, 1 + socketProcessRunning + rddProcessRunning,
aName + " has " + aAmounts.length + " report");
let n = aAmounts[0];
if (!aCanBeUnreasonable) {

View File

@ -21,8 +21,12 @@
if (SpecialPowers.Services.io.socketProcessLaunched) {
socketProcessRunning = 1;
}
let rddProcessRunning = 0;
if (window.windowUtils.rddProcessPid != -1) {
rddProcessRunning = 1;
}
let numToOpen = 3;
const expectedNumRemotes = numToOpen + socketProcessRunning;
const expectedNumRemotes = numToOpen + socketProcessRunning + rddProcessRunning;
let numReady = 0;
// Create some remote processes, and set up message-passing so that
@ -96,6 +100,7 @@
} else {
ok(processes[i].startsWith("Browser (") || processes[i].startsWith("Web Content (") ||
(processes[i].startsWith("Socket (") && socketProcessRunning)
|| (processes[i].startsWith("RDD (") && rddProcessRunning)
|| processes[i].startsWith("web (") || processes[i].startsWith("Utility ("),
"correct non-empty process name prefix: " + processes[i]);
numNonEmptyProcesses++;