Bug 1430038 - Part 1: Add VR process to the process list; r=kip, jimm

Summary: MozReview-Commit-ID: AWyFur2gLCQ

Tags: #secure-revision

Differential Revision: https://phabricator.services.mozilla.com/D2876

MozReview-Commit-ID: HHGDiXyaqnB

--HG--
extra : rebase_source : cbb94eb1aaca4ca385559c0e997b508a80121105
This commit is contained in:
Daosheng Mu 2018-06-22 16:30:14 -07:00
parent 79bc1ca39f
commit 8ac5934ce1
8 changed files with 41 additions and 10 deletions

View File

@ -391,6 +391,7 @@ private:
DECL_GFX_PREF(Live, "dom.vr.puppet.enabled", VRPuppetEnabled, bool, false);
DECL_GFX_PREF(Live, "dom.vr.puppet.submitframe", VRPuppetSubmitFrame, uint32_t, 0);
DECL_GFX_PREF(Live, "dom.vr.display.rafMaxDuration", VRDisplayRafMaxDuration, uint32_t, 50);
DECL_GFX_PREF(Once, "dom.vr.process.enabled", VRProcessEnabled, bool, false);
DECL_GFX_PREF(Once, "dom.vr.service.enabled", VRServiceEnabled, bool, false);
DECL_GFX_PREF(Live, "dom.w3c_pointer_events.enabled", PointerEventsEnabled, bool, false);

View File

@ -143,7 +143,8 @@ auto
GeckoChildProcessHost::GetPathToBinary(FilePath& exePath, GeckoProcessType processType) -> BinaryPathType
{
if (sRunSelfAsContentProc &&
(processType == GeckoProcessType_Content || processType == GeckoProcessType_GPU)) {
(processType == GeckoProcessType_Content || processType == GeckoProcessType_GPU ||
processType == GeckoProcessType_VR)) {
#if defined(OS_WIN)
wchar_t exePathBuf[MAXPATHLEN];
if (!::GetModuleFileNameW(nullptr, exePathBuf, MAXPATHLEN)) {
@ -763,7 +764,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
// Tmp dir that the GPU process should use for crash reports. This arg is
// always populated (but possibly with an empty value) for a GPU child process.
if (mProcessType == GeckoProcessType_GPU) {
if (mProcessType == GeckoProcessType_GPU || mProcessType == GeckoProcessType_VR) {
nsCOMPtr<nsIFile> file;
CrashReporter::GetChildProcessTmpDir(getter_AddRefs(file));
nsAutoCString path;
@ -1000,6 +1001,11 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
shouldSandboxCurrentProcess = true;
}
break;
case GeckoProcessType_VR:
if (mSandboxLevel > 0 && !PR_GetEnv("MOZ_DISABLE_VR_SANDBOX")) {
// TODO: Implement sandbox for VR process, Bug 1430043.
}
break;
case GeckoProcessType_Default:
default:
MOZ_CRASH("Bad process type in GeckoChildProcessHost");
@ -1082,6 +1088,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
// child processes.
if (mProcessType == GeckoProcessType_Content ||
mProcessType == GeckoProcessType_GPU ||
mProcessType == GeckoProcessType_VR ||
mProcessType == GeckoProcessType_GMPlugin) {
if (!mSandboxBroker.AddTargetPeer(process)) {
NS_WARNING("Failed to add content process as target peer.");

View File

@ -5332,16 +5332,18 @@ pref("dom.vr.poseprediction.enabled", true);
// this requirement to be disabled for special cases such as during automated
// tests or in a headless kiosk system.
pref("dom.vr.require-gesture", true);
// path to OSVR DLLs
pref("gfx.vr.osvr.utilLibPath", "");
pref("gfx.vr.osvr.commonLibPath", "");
pref("gfx.vr.osvr.clientLibPath", "");
pref("gfx.vr.osvr.clientKitLibPath", "");
// Enable a separate process for VR module.
pref("dom.vr.process.enabled", false);
// Puppet device, used for simulating VR hardware within tests and dev tools
pref("dom.vr.puppet.enabled", false);
// Allow displaying the result of vr submitframe (0: disable, 1: store the
// result as a base64 image, 2: show it on the screen).
pref("dom.vr.puppet.submitframe", 0);
// path to OSVR DLLs
pref("gfx.vr.osvr.utilLibPath", "");
pref("gfx.vr.osvr.commonLibPath", "");
pref("gfx.vr.osvr.clientLibPath", "");
pref("gfx.vr.osvr.clientKitLibPath", "");
// The number of milliseconds since last frame start before triggering a new frame.
// When content is failing to submit frames on time or the lower level VR platform API's
// are rejecting frames, it determines the rate at which RAF callbacks will be called.

View File

@ -795,9 +795,10 @@ SYNC_ENUMS(IPDLUNITTEST, IPDLUnitTest)
SYNC_ENUMS(GMPLUGIN, GMPlugin)
SYNC_ENUMS(GPU, GPU)
SYNC_ENUMS(PDFIUM, PDFium)
SYNC_ENUMS(VR, VR)
// .. and ensure that that is all of them:
static_assert(GeckoProcessType_PDFium + 1 == GeckoProcessType_End,
static_assert(GeckoProcessType_VR + 1 == GeckoProcessType_End,
"Did not find the final GeckoProcessType");
NS_IMETHODIMP
@ -5137,6 +5138,12 @@ XRE_IsGPUProcess()
return XRE_GetProcessType() == GeckoProcessType_GPU;
}
bool
XRE_IsVRProcess()
{
return XRE_GetProcessType() == GeckoProcessType_VR;
}
/**
* Returns true in the e10s parent process and in the main process when e10s
* is disabled.

View File

@ -122,6 +122,8 @@ using mozilla::_ipdltest::IPDLUnitTestProcessChild;
#include "mozilla/widget/PDFiumProcessChild.h"
#endif
#include "VRProcessChild.h"
using namespace mozilla;
using mozilla::ipc::BrowserProcessSubThread;
@ -668,6 +670,7 @@ XRE_InitChildProcess(int aArgc,
break;
case GeckoProcessType_GMPlugin:
case GeckoProcessType_PDFium:
case GeckoProcessType_VR:
uiLoopType = MessageLoop::TYPE_DEFAULT;
break;
default:
@ -730,6 +733,10 @@ XRE_InitChildProcess(int aArgc,
process = new gfx::GPUProcessImpl(parentPID);
break;
case GeckoProcessType_VR:
process = new gfx::VRProcessChild(parentPID);
break;
default:
MOZ_CRASH("Unknown main thread class");
}

View File

@ -283,7 +283,8 @@ Faulty::IsValidProcessType(void)
|| currentProcessType == GeckoProcessType_Content
|| currentProcessType == GeckoProcessType_GMPlugin
|| currentProcessType == GeckoProcessType_GPU
|| currentProcessType == GeckoProcessType_PDFium)) {
|| currentProcessType == GeckoProcessType_PDFium
|| currentProcessType == GeckoProcessType_VR)) {
// Fuzz inside any of the above child process only.
isValidProcessType = true;
} else if (targetChildren && targetParent) {

View File

@ -375,6 +375,7 @@ enum GeckoProcessType
GeckoProcessType_GPU, // GPU and compositor process
GeckoProcessType_PDFium, // Gecko PDFium process
GeckoProcessType_VR, // VR process
GeckoProcessType_End,
GeckoProcessType_Invalid = GeckoProcessType_End
};
@ -386,7 +387,8 @@ static const char* const kGeckoProcessTypeString[] = {
"ipdlunittest",
"geckomediaplugin",
"gpu",
"pdfium"
"pdfium",
"vr"
};
static_assert(MOZ_ARRAY_LENGTH(kGeckoProcessTypeString) ==
@ -464,6 +466,9 @@ XRE_API(bool,
XRE_API(bool,
XRE_IsGPUProcess, ())
XRE_API(bool,
XRE_IsVRProcess, ())
XRE_API(bool,
XRE_IsPluginProcess, ())

View File

@ -77,6 +77,7 @@ interface nsIXULRuntime : nsISupports
const unsigned long PROCESS_TYPE_GMPLUGIN = 4;
const unsigned long PROCESS_TYPE_GPU = 5;
const unsigned long PROCESS_TYPE_PDFIUM = 6;
const unsigned long PROCESS_TYPE_VR = 7;
/**
* The type of the caller's process. Returns one of the values above.