Skip to content

Commit

Permalink
Bug 1684991 - Start the RDD process early. r=media-playback-reviewers…
Browse files Browse the repository at this point in the history
…,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
  • Loading branch information
aosmond committed Nov 19, 2024
1 parent 9edf24d commit 7c0050f
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 4 deletions.
13 changes: 13 additions & 0 deletions dom/base/nsDOMWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions dom/interfaces/base/nsIDOMWindowUtils.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
7 changes: 7 additions & 0 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion toolkit/components/aboutmemory/tests/test_aboutmemory5.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++;
Expand Down

0 comments on commit 7c0050f

Please sign in to comment.