Backed out 5 changesets (bug 944665, bug 922465, bug 930282) for b2g xpcshell crashes

CLOSED TREE

Backed out changeset c4f970dd2a4f (bug 930282)
Backed out changeset 625f5303fc68 (bug 930282)
Backed out changeset bf8e90edd152 (bug 922465)
Backed out changeset a21b57c78253 (bug 944665)
Backed out changeset 9275a2efc9e3 (bug 944665)

--HG--
extra : rebase_source : bfbe3786e0db2073e26dc383b89525d22be0b3bd
This commit is contained in:
Phil Ringnalda 2013-12-08 15:32:15 -08:00
parent 7a1a801461
commit f676c9d65c
10 changed files with 100 additions and 270 deletions

View File

@ -56,9 +56,7 @@ MOZ_TOOLKIT_SEARCH=
MOZ_PLACES=
MOZ_B2G=1
if test "$OS_TARGET" = "Android"; then
MOZ_NUWA_PROCESS=1
fi
#MOZ_NUWA_PROCESS=1
MOZ_FOLD_LIBS=1
MOZ_JSDOWNLOADS=1

View File

@ -1348,6 +1348,17 @@ PreloadSlowThings()
TabChild::PreloadSlowThings();
#ifdef MOZ_NUWA_PROCESS
// After preload of slow things, start freezing threads.
if (IsNuwaProcess()) {
// Perform GC before freezing the Nuwa process to reduce memory usage.
ContentChild::GetSingleton()->RecvGarbageCollect();
MessageLoop::current()->
PostTask(FROM_HERE,
NewRunnableFunction(OnFinishNuwaPreparation));
}
#endif
}
bool
@ -1358,32 +1369,15 @@ ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID,
mAppInfo.buildID.Assign(buildID);
mAppInfo.name.Assign(name);
mAppInfo.UAName.Assign(UAName);
if (!Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
return true;
}
// If we're part of the mozbrowser machinery, go ahead and start
// preloading things. We can only do this for mozbrowser because
// PreloadSlowThings() may set the docshell of the first TabChild
// inactive, and we can only safely restore it to active from
// BrowserElementChild.js.
if ((mIsForApp || mIsForBrowser)
#ifdef MOZ_NUWA_PROCESS
&& !IsNuwaProcess()
#endif
) {
if ((mIsForApp || mIsForBrowser) &&
Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
PreloadSlowThings();
}
#ifdef MOZ_NUWA_PROCESS
if (IsNuwaProcess()) {
ContentChild::GetSingleton()->RecvGarbageCollect();
MessageLoop::current()->PostTask(
FROM_HERE, NewRunnableFunction(OnFinishNuwaPreparation));
}
#endif
return true;
}

View File

@ -1249,13 +1249,93 @@ ContentParent::ContentParent(mozIApplication* aApp,
Open(mSubprocess->GetChannel(), mSubprocess->GetOwnedChildProcessHandle());
InitInternal(aInitialPriority,
true, /* Setup off-main thread compositing */
true /* Send registered chrome */);
// Set the subprocess's priority. We do this early on because we're likely
// /lowering/ the process's CPU and memory priority, which it has inherited
// from this process.
//
// This call can cause us to send IPC messages to the child process, so it
// must come after the Open() call above.
ProcessPriorityManager::SetProcessPriority(this, aInitialPriority);
// NB: internally, this will send an IPC message to the child
// process to get it to create the CompositorChild. This
// message goes through the regular IPC queue for this
// channel, so delivery will happen-before any other messages
// we send. The CompositorChild must be created before any
// PBrowsers are created, because they rely on the Compositor
// already being around. (Creation is async, so can't happen
// on demand.)
bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
if (useOffMainThreadCompositing) {
DebugOnly<bool> opened = PCompositor::Open(this);
MOZ_ASSERT(opened);
if (Preferences::GetBool("layers.async-video.enabled",false)) {
opened = PImageBridge::Open(this);
MOZ_ASSERT(opened);
}
}
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
nsChromeRegistryChrome* chromeRegistry =
static_cast<nsChromeRegistryChrome*>(registrySvc.get());
chromeRegistry->SendRegisteredChrome(this);
mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this);
if (gAppData) {
nsCString version(gAppData->version);
nsCString buildID(gAppData->buildID);
nsCString name(gAppData->name);
nsCString UAName(gAppData->UAName);
// Sending all information to content process.
unused << SendAppInfo(version, buildID, name, UAName);
}
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
// This looks like a lot of work, but in a normal browser session we just
// send two loads.
nsCOMArray<nsIStyleSheet>& agentSheets = *sheetService->AgentStyleSheets();
for (uint32_t i = 0; i < agentSheets.Length(); i++) {
URIParams uri;
SerializeURI(agentSheets[i]->GetSheetURI(), uri);
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET);
}
nsCOMArray<nsIStyleSheet>& userSheets = *sheetService->UserStyleSheets();
for (uint32_t i = 0; i < userSheets.Length(); i++) {
URIParams uri;
SerializeURI(userSheets[i]->GetSheetURI(), uri);
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET);
}
nsCOMArray<nsIStyleSheet>& authorSheets = *sheetService->AuthorStyleSheets();
for (uint32_t i = 0; i < authorSheets.Length(); i++) {
URIParams uri;
SerializeURI(authorSheets[i]->GetSheetURI(), uri);
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
}
}
#ifdef MOZ_CONTENT_SANDBOX
// Bug 921817. We enable the sandbox in RecvSetProcessPrivileges,
// which is where a preallocated process drops unnecessary privileges,
// but a non-preallocated process will already have changed its
// uid/gid/etc immediately after forking. Thus, we send this message,
// which is otherwise a no-op, to sandbox it at an appropriate point
// during startup.
if (aOSPrivileges != base::PRIVILEGES_INHERIT) {
if (!SendSetProcessPrivileges(base::PRIVILEGES_INHERIT)) {
KillHard();
}
}
#endif
}
#ifdef MOZ_NUWA_PROCESS
static const mozilla::ipc::FileDescriptor*
static const FileDescriptor*
FindFdProtocolFdMapping(const nsTArray<ProtocolFdMapping>& aFds,
ProtocolId aProtoId)
{
@ -1321,9 +1401,8 @@ ContentParent::ContentParent(ContentParent* aTemplate,
priority = PROCESS_PRIORITY_FOREGROUND;
}
InitInternal(priority,
false, /* Setup Off-main thread compositing */
false /* Send registered chrome */);
ProcessPriorityManager::SetProcessPriority(this, priority);
mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this);
}
#endif // MOZ_NUWA_PROCESS
@ -1353,101 +1432,6 @@ ContentParent::~ContentParent()
}
}
void
ContentParent::InitInternal(ProcessPriority aInitialPriority,
bool aSetupOffMainThreadCompositing,
bool aSendRegisteredChrome)
{
// Set the subprocess's priority. We do this early on because we're likely
// /lowering/ the process's CPU and memory priority, which it has inherited
// from this process.
//
// This call can cause us to send IPC messages to the child process, so it
// must come after the Open() call above.
ProcessPriorityManager::SetProcessPriority(this, aInitialPriority);
if (aSetupOffMainThreadCompositing) {
// NB: internally, this will send an IPC message to the child
// process to get it to create the CompositorChild. This
// message goes through the regular IPC queue for this
// channel, so delivery will happen-before any other messages
// we send. The CompositorChild must be created before any
// PBrowsers are created, because they rely on the Compositor
// already being around. (Creation is async, so can't happen
// on demand.)
bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
if (useOffMainThreadCompositing) {
DebugOnly<bool> opened = PCompositor::Open(this);
MOZ_ASSERT(opened);
if (Preferences::GetBool("layers.async-video.enabled",false)) {
opened = PImageBridge::Open(this);
MOZ_ASSERT(opened);
}
}
}
if (aSendRegisteredChrome) {
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
nsChromeRegistryChrome* chromeRegistry =
static_cast<nsChromeRegistryChrome*>(registrySvc.get());
chromeRegistry->SendRegisteredChrome(this);
}
mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this);
if (gAppData) {
nsCString version(gAppData->version);
nsCString buildID(gAppData->buildID);
nsCString name(gAppData->name);
nsCString UAName(gAppData->UAName);
// Sending all information to content process.
unused << SendAppInfo(version, buildID, name, UAName);
}
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
// This looks like a lot of work, but in a normal browser session we just
// send two loads.
nsCOMArray<nsIStyleSheet>& agentSheets = *sheetService->AgentStyleSheets();
for (uint32_t i = 0; i < agentSheets.Length(); i++) {
URIParams uri;
SerializeURI(agentSheets[i]->GetSheetURI(), uri);
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET);
}
nsCOMArray<nsIStyleSheet>& userSheets = *sheetService->UserStyleSheets();
for (uint32_t i = 0; i < userSheets.Length(); i++) {
URIParams uri;
SerializeURI(userSheets[i]->GetSheetURI(), uri);
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET);
}
nsCOMArray<nsIStyleSheet>& authorSheets = *sheetService->AuthorStyleSheets();
for (uint32_t i = 0; i < authorSheets.Length(); i++) {
URIParams uri;
SerializeURI(authorSheets[i]->GetSheetURI(), uri);
unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
}
}
#ifdef MOZ_CONTENT_SANDBOX
// Bug 921817. We enable the sandbox in RecvSetProcessPrivileges,
// which is where a preallocated process drops unnecessary privileges,
// but a non-preallocated process will already have changed its
// uid/gid/etc immediately after forking. Thus, we send this message,
// which is otherwise a no-op, to sandbox it at an appropriate point
// during startup.
if (mOSPrivileges != base::PRIVILEGES_INHERIT) {
if (!SendSetProcessPrivileges(base::PRIVILEGES_INHERIT)) {
KillHard();
}
}
#endif
}
bool
ContentParent::IsAlive()
{

View File

@ -265,11 +265,6 @@ private:
// The common initialization for the constructors.
void InitializeMembers();
// The common initialization logic shared by all constuctors.
void InitInternal(ProcessPriority aPriority,
bool aSetupOffMainThreadCompositing,
bool aSendRegisteredChrome);
virtual ~ContentParent();
void Init();

View File

@ -281,15 +281,6 @@ PreallocatedProcessManagerImpl::PublishSpareProcess(ContentParent* aContent)
{
MOZ_ASSERT(NS_IsMainThread());
if (Preferences::GetBool("dom.ipc.processPriorityManager.testMode")) {
AutoJSContext cx;
nsCOMPtr<nsIMessageBroadcaster> ppmm =
do_GetService("@mozilla.org/parentprocessmessagemanager;1");
nsresult rv = ppmm->BroadcastAsyncMessage(
NS_LITERAL_STRING("TEST-ONLY:nuwa-add-new-process"),
JSVAL_NULL, JSVAL_NULL, cx, 1);
}
if (!mNuwaForkWaitTasks.IsEmpty()) {
mNuwaForkWaitTasks.ElementAt(0)->Cancel();
mNuwaForkWaitTasks.RemoveElementAt(0);
@ -321,14 +312,6 @@ PreallocatedProcessManagerImpl::OnNuwaReady()
ProcessPriorityManager::SetProcessPriority(mPreallocatedAppProcess,
hal::PROCESS_PRIORITY_FOREGROUND);
mIsNuwaReady = true;
if (Preferences::GetBool("dom.ipc.processPriorityManager.testMode")) {
AutoJSContext cx;
nsCOMPtr<nsIMessageBroadcaster> ppmm =
do_GetService("@mozilla.org/parentprocessmessagemanager;1");
nsresult rv = ppmm->BroadcastAsyncMessage(
NS_LITERAL_STRING("TEST-ONLY:nuwa-ready"),
JSVAL_NULL, JSVAL_NULL, cx, 1);
}
NuwaFork();
}

View File

@ -1,2 +0,0 @@
[test_NuwaProcessCreation.html]
run-if = toolkit == 'gonk'

View File

@ -5,5 +5,4 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
MOCHITEST_MANIFESTS += ['mochitest.ini']

View File

@ -1,99 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
Test if Nuwa process created successfully.
-->
<head>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.waitForExplicitFinish();
function TestLoader() {}
TestLoader.prototype = {
_waitingTask: 0,
onTestReady: null,
unlockTestReady: function() {
this._waitingTask--;
this._maybeLoadTest();
},
lockTestReady: function() {
this._waitingTask++;
},
_maybeLoadTest: function() {
if (this._waitingTask == 0) {
this.onTestReady();
}
}
}
var testLoader = new TestLoader();
testLoader.lockTestReady();
window.addEventListener('load', function() {
testLoader.unlockTestReady();
});
function setPref(pref, value) {
testLoader.lockTestReady();
if (value !== undefined && value !== null) {
SpecialPowers.pushPrefEnv({'set': [[pref, value]]}, function() { testLoader.unlockTestReady(); });
} else {
SpecialPowers.pushPrefEnv({'clear': [[pref]]}, function() { testLoader.unlockTestReady(); });
}
}
setPref('dom.ipc.processPriorityManager.testMode', true);
setPref('dom.ipc.processPriorityManager.enabled', true);
setPref('dom.ipc.processPriorityManager.backgroundLRUPoolLevels', 2);
function runTest()
{
// Shutdown preallocated process.
SpecialPowers.setBoolPref('dom.ipc.processPrelaunch.enabled', false);
let cpmm = SpecialPowers.Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(SpecialPowers.Ci.nsISyncMessageSender);
let seenNuwaReady = false;
let msgHandler = {
receiveMessage: function receiveMessage(msg) {
msg = SpecialPowers.wrap(msg);
if (msg.name == 'TEST-ONLY:nuwa-ready') {
ok(true, "Got nuwa-ready");
is(seenNuwaReady, false, "Already received nuwa ready");
seenNuwaReady = true;
} else if (msg.name == 'TEST-ONLY:nuwa-add-new-process') {
ok(true, "Got nuwa-add-new-process");
is(seenNuwaReady, true, "Receive nuwa-add-new-process before nuwa-ready");
testEnd();
}
}
};
let timeout = setTimeout(function() {
ok(false, "Nuwa process is not launched");
testEnd();
}, 60000);
function testEnd() {
cpmm.removeMessageListener("TEST-ONLY:nuwa-ready", msgHandler);
cpmm.removeMessageListener("TEST-ONLY:nuwa-add-new-process", msgHandler);
clearTimeout(timeout);
SimpleTest.finish();
}
cpmm.addMessageListener("TEST-ONLY:nuwa-ready", msgHandler);
cpmm.addMessageListener("TEST-ONLY:nuwa-add-new-process", msgHandler);
// Setting this pref to true should cause us to prelaunch a process.
SpecialPowers.setBoolPref('dom.ipc.processPrelaunch.enabled', true);
}
testLoader.onTestReady = runTest;
</script>
</body>
</html>

View File

@ -14,9 +14,6 @@
#include "nsNetUtil.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "nsISystemProxySettings.h"
#ifdef MOZ_NUWA_PROCESS
#include "ipc/Nuwa.h"
#endif
//-----------------------------------------------------------------------------
using namespace mozilla;
@ -677,13 +674,6 @@ nsPACMan::NamePACThread()
{
NS_ABORT_IF_FALSE(!NS_IsMainThread(), "wrong thread");
PR_SetCurrentThreadName("Proxy Resolution");
#ifdef MOZ_NUWA_PROCESS
if (IsNuwaProcess()) {
NS_ASSERTION(NuwaMarkCurrentThread != nullptr,
"NuwaMarkCurrentThread is undefined!");
NuwaMarkCurrentThread(nullptr, nullptr);
}
#endif
}
nsresult

View File

@ -11,9 +11,6 @@
#include "mozilla/Telemetry.h"
#include "mozilla/ThreadHangStats.h"
#include "mozilla/ThreadLocal.h"
#ifdef MOZ_NUWA_PROCESS
#include "ipc/Nuwa.h"
#endif
#include "prinrval.h"
#include "prthread.h"
@ -34,15 +31,6 @@ private:
static void MonitorThread(void* aData)
{
PR_SetCurrentThreadName("BgHangManager");
#ifdef MOZ_NUWA_PROCESS
if (IsNuwaProcess()) {
NS_ASSERTION(NuwaMarkCurrentThread != nullptr,
"NuwaMarkCurrentThread is undefined!");
NuwaMarkCurrentThread(nullptr, nullptr);
}
#endif
/* We do not hold a reference to BackgroundHangManager here
because the monitor thread only exists as long as the
BackgroundHangManager instance exists. We stop the monitor