author | Nicholas Nethercote <nnethercote@mozilla.com> |
Tue, 18 Apr 2017 16:56:43 +1000 | |
changeset 367568 | 527d5254f92739ad0d5d3859ea338ac534d4a728 |
parent 367567 | f6bd1a90ea8f57a45d3b80ae23d42fbd63aecb3f |
child 367569 | 690c244100f13c5f55191db614b4be668d458318 |
push id | 32137 |
push user | cbook@mozilla.com |
push date | Thu, 06 Jul 2017 09:18:21 +0000 |
treeherder | mozilla-central@018b3829d0a7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jimm |
bugs | 1352575 |
milestone | 56.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1099,18 +1099,17 @@ ContentParent::RecvCreateGMPService() mozilla::ipc::IPCResult ContentParent::RecvLoadPlugin(const uint32_t& aPluginId, nsresult* aRv, uint32_t* aRunID, Endpoint<PPluginModuleParent>* aEndpoint) { *aRv = NS_OK; - if (!mozilla::plugins::SetupBridge(aPluginId, this, false, aRv, aRunID, - aEndpoint)) { + if (!mozilla::plugins::SetupBridge(aPluginId, this, aRv, aRunID, aEndpoint)) { return IPC_FAIL_NO_REASON(this); } return IPC_OK(); } mozilla::ipc::IPCResult ContentParent::RecvUngrabPointer(const uint32_t& aTime) { @@ -1136,17 +1135,17 @@ ContentParent::RecvConnectPluginBridge(c nsresult* aRv, Endpoint<PPluginModuleParent>* aEndpoint) { *aRv = NS_OK; // We don't need to get the run ID for the plugin, since we already got it // in the first call to SetupBridge in RecvLoadPlugin, so we pass in a dummy // pointer and just throw it away. uint32_t dummy = 0; - if (!mozilla::plugins::SetupBridge(aPluginId, this, true, aRv, &dummy, aEndpoint)) { + if (!mozilla::plugins::SetupBridge(aPluginId, this, aRv, &dummy, aEndpoint)) { return IPC_FAIL(this, "SetupBridge failed"); } return IPC_OK(); } mozilla::ipc::IPCResult ContentParent::RecvGetBlocklistState(const uint32_t& aPluginId, uint32_t* aState)
--- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -753,27 +753,25 @@ nsPluginHost::InstantiatePluginInstance( return NS_ERROR_FAILURE; } rv = SetUpPluginInstance(aMimeType, aURL, instanceOwner); if (NS_FAILED(rv)) { instanceOwner->Destroy(); return NS_ERROR_FAILURE; } - const bool isAsyncInit = (rv == NS_PLUGIN_INIT_PENDING); RefPtr<nsNPAPIPluginInstance> instance; rv = instanceOwner->GetInstance(getter_AddRefs(instance)); if (NS_FAILED(rv)) { instanceOwner->Destroy(); return rv; } - // Async init plugins will initiate their own widget creation. - if (!isAsyncInit && instance) { + if (instance) { CreateWidget(instanceOwner); } // At this point we consider instantiation to be successful. Do not return an error. instanceOwner.forget(aOwner); #ifdef PLUGIN_LOGGING nsAutoCString urlSpec2;
--- a/dom/plugins/ipc/PluginAsyncSurrogate.cpp +++ b/dom/plugins/ipc/PluginAsyncSurrogate.cpp @@ -504,17 +504,17 @@ PluginAsyncSurrogate::WaitForInit() } Telemetry::AutoTimer<Telemetry::BLOCKED_ON_PLUGINASYNCSURROGATE_WAITFORINIT_MS> timer(mParent->GetHistogramKey()); bool result = false; MOZ_ASSERT(mParent); if (mParent->IsChrome()) { PluginProcessParent* process = static_cast<PluginModuleChromeParent*>(mParent)->Process(); MOZ_ASSERT(process); - process->SetCallRunnableImmediately(true); + process->SetCallRunnableImmediately(); if (!process->WaitUntilConnected()) { return false; } } if (!mParent->WaitForIPCConnection()) { return false; } if (!mParent->IsChrome()) {
--- a/dom/plugins/ipc/PluginBridge.h +++ b/dom/plugins/ipc/PluginBridge.h @@ -23,17 +23,17 @@ class Endpoint; } // namespace ipc namespace plugins { class PPluginModuleParent; bool SetupBridge(uint32_t aPluginId, dom::ContentParent* aContentParent, - bool aForceBridgeNow, nsresult* aResult, uint32_t* aRunID, + nsresult* aResult, uint32_t* aRunID, ipc::Endpoint<PPluginModuleParent>* aEndpoint); nsresult FindPluginsForContent(uint32_t aPluginEpoch, nsTArray<PluginTag>* aPlugins, nsTArray<FakePluginTag>* aFakePlugins, uint32_t* aNewPluginEpoch);
--- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -1770,32 +1770,22 @@ PluginInstanceParent::NPP_NewStream(NPMI NullableString(stream->headers))) { return NPERR_GENERIC_ERROR; } Telemetry::AutoTimer<Telemetry::BLOCKED_ON_PLUGIN_STREAM_INIT_MS> timer(Module()->GetHistogramKey()); NPError err = NPERR_NO_ERROR; - if (mParent->IsStartingAsync()) { - MOZ_ASSERT(mSurrogate); - mSurrogate->AsyncCallDeparting(); - if (SendAsyncNPP_NewStream(bs, NullableString(type), seekable)) { - *stype = nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN; - } else { - err = NPERR_GENERIC_ERROR; - } - } else { - bs->SetAlive(); - if (!CallNPP_NewStream(bs, NullableString(type), seekable, &err, stype)) { - err = NPERR_GENERIC_ERROR; - } - if (NPERR_NO_ERROR != err) { - Unused << PBrowserStreamParent::Send__delete__(bs); - } + bs->SetAlive(); + if (!CallNPP_NewStream(bs, NullableString(type), seekable, &err, stype)) { + err = NPERR_GENERIC_ERROR; + } + if (NPERR_NO_ERROR != err) { + Unused << PBrowserStreamParent::Send__delete__(bs); } return err; } NPError PluginInstanceParent::NPP_DestroyStream(NPStream* stream, NPReason reason) {
--- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -83,51 +83,41 @@ static const char kHangUIMinDisplayPref[ #define CHILD_TIMEOUT_PREF kHangUITimeoutPref #else #define CHILD_TIMEOUT_PREF kChildTimeoutPref #endif bool mozilla::plugins::SetupBridge(uint32_t aPluginId, dom::ContentParent* aContentParent, - bool aForceBridgeNow, nsresult* rv, uint32_t* runID, ipc::Endpoint<PPluginModuleParent>* aEndpoint) { AUTO_PROFILER_LABEL("plugins::SetupBridge", OTHER); if (NS_WARN_IF(!rv) || NS_WARN_IF(!runID)) { return false; } - PluginModuleChromeParent::ClearInstantiationFlag(); RefPtr<nsPluginHost> host = nsPluginHost::GetInst(); RefPtr<nsNPAPIPlugin> plugin; *rv = host->GetPluginForContentProcess(aPluginId, getter_AddRefs(plugin)); if (NS_FAILED(*rv)) { return true; } PluginModuleChromeParent* chromeParent = static_cast<PluginModuleChromeParent*>(plugin->GetLibrary()); /* * We can't accumulate BLOCKED_ON_PLUGIN_MODULE_INIT_MS until here because * its histogram key is not available until *after* NP_Initialize. */ chromeParent->AccumulateModuleInitBlockedTime(); *rv = chromeParent->GetRunID(runID); if (NS_FAILED(*rv)) { return true; } - if (chromeParent->IsStartingAsync()) { - chromeParent->SetContentParent(aContentParent); - } - if (!aForceBridgeNow && chromeParent->IsStartingAsync() && - PluginModuleChromeParent::DidInstantiate()) { - // We'll handle the bridging asynchronously - return true; - } ipc::Endpoint<PPluginModuleParent> parent; ipc::Endpoint<PPluginModuleChild> child; *rv = PPluginModule::CreateEndpoints(aContentParent->OtherPid(), chromeParent->OtherPid(), &parent, &child); if (NS_FAILED(*rv)) { @@ -501,24 +491,16 @@ PluginModuleContentParent::OnLoadPluginR PluginModuleMapping::FindModuleByPluginId(aPluginId)); MOZ_ASSERT(moduleMapping); PluginModuleContentParent* parent = moduleMapping->GetModule(); MOZ_ASSERT(parent); parent->RecvNP_InitializeResult(aResult ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR); } -void -PluginModuleChromeParent::SetContentParent(dom::ContentParent* aContentParent) -{ - // mContentParent is to be used ONLY during async plugin init! - MOZ_ASSERT(aContentParent && mIsStartingAsync); - mContentParent = aContentParent; -} - bool PluginModuleChromeParent::SendAssociatePluginId() { MOZ_ASSERT(mContentParent); return mContentParent->SendAssociatePluginId(mPluginId, OtherPid()); } // static @@ -527,35 +509,33 @@ PluginModuleChromeParent::LoadModule(con nsPluginTag* aPluginTag) { PLUGIN_LOG_DEBUG_FUNCTION; nsAutoPtr<PluginModuleChromeParent> parent( new PluginModuleChromeParent(aFilePath, aPluginId, aPluginTag->mSandboxLevel)); UniquePtr<LaunchCompleteTask> onLaunchedRunnable(new LaunchedTask(parent)); - parent->mSubprocess->SetCallRunnableImmediately(!parent->mIsStartingAsync); + parent->mSubprocess->SetCallRunnableImmediately(); TimeStamp launchStart = TimeStamp::Now(); bool launched = parent->mSubprocess->Launch(Move(onLaunchedRunnable), aPluginTag->mSandboxLevel); if (!launched) { // We never reached open parent->mShutdown = true; return nullptr; } parent->mIsFlashPlugin = aPluginTag->mIsFlashPlugin; uint32_t blocklistState; nsresult rv = aPluginTag->GetBlocklistState(&blocklistState); parent->mIsBlocklisted = NS_FAILED(rv) || blocklistState != 0; - if (!parent->mIsStartingAsync) { - int32_t launchTimeoutSecs = Preferences::GetInt(kLaunchTimeoutPref, 0); - if (!parent->mSubprocess->WaitUntilConnected(launchTimeoutSecs * 1000)) { - parent->mShutdown = true; - return nullptr; - } + int32_t launchTimeoutSecs = Preferences::GetInt(kLaunchTimeoutPref, 0); + if (!parent->mSubprocess->WaitUntilConnected(launchTimeoutSecs * 1000)) { + parent->mShutdown = true; + return nullptr; } TimeStamp launchEnd = TimeStamp::Now(); parent->mTimeBlocked = (launchEnd - launchStart); return parent.forget(); } void PluginModuleChromeParent::OnProcessLaunched(const bool aSucceeded) @@ -641,17 +621,17 @@ PluginModuleChromeParent::OnProcessLaunc #endif } bool PluginModuleChromeParent::WaitForIPCConnection() { PluginProcessParent* process = Process(); MOZ_ASSERT(process); - process->SetCallRunnableImmediately(true); + process->SetCallRunnableImmediately(); if (!process->WaitUntilConnected()) { return false; } return true; } bool PluginModuleChromeParent::InitCrashReporter() @@ -668,21 +648,16 @@ PluginModuleChromeParent::InitCrashRepor } { mozilla::MutexAutoLock lock(mCrashReporterMutex); mCrashReporter = MakeUnique<ipc::CrashReporterHost>( GeckoProcessType_Plugin, shmem, threadId); - - mCrashReporter->AddNote(NS_LITERAL_CSTRING("AsyncPluginInit"), - mIsStartingAsync ? - NS_LITERAL_CSTRING("1") : - NS_LITERAL_CSTRING("0")); } #endif return true; } PluginModuleParent::PluginModuleParent(bool aIsChrome) : mQuirks(QUIRKS_NOT_INITIALIZED) @@ -692,30 +667,23 @@ PluginModuleParent::PluginModuleParent(b , mClearSiteDataSupported(false) , mGetSitesWithDataSupported(false) , mNPNIface(nullptr) , mNPPIface(nullptr) , mPlugin(nullptr) , mTaskFactory(this) , mSandboxLevel(0) , mIsFlashPlugin(false) - , mIsStartingAsync(false) , mNPInitialized(false) , mIsNPShutdownPending(false) , mAsyncNewRv(NS_ERROR_NOT_INITIALIZED) #ifdef MOZ_CRASHREPORTER , mCrashReporterMutex("PluginModuleChromeParent::mCrashReporterMutex") #endif { -#if defined(MOZ_CRASHREPORTER) - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AsyncPluginInit"), - mIsStartingAsync ? - NS_LITERAL_CSTRING("1") : - NS_LITERAL_CSTRING("0")); -#endif } PluginModuleParent::~PluginModuleParent() { if (!OkToCleanup()) { MOZ_CRASH("unsafe destruction"); } @@ -732,18 +700,16 @@ PluginModuleContentParent::PluginModuleC Preferences::RegisterCallback(TimeoutChanged, kContentTimeoutPref, this); } PluginModuleContentParent::~PluginModuleContentParent() { Preferences::UnregisterCallback(TimeoutChanged, kContentTimeoutPref, this); } -bool PluginModuleChromeParent::sInstantiated = false; - PluginModuleChromeParent::PluginModuleChromeParent(const char* aFilePath, uint32_t aPluginId, int32_t aSandboxLevel) : PluginModuleParent(true) , mSubprocess(new PluginProcessParent(aFilePath)) , mPluginId(aPluginId) , mChromeTaskFactory(this) , mHangAnnotationFlags(0) @@ -758,17 +724,16 @@ PluginModuleChromeParent::PluginModuleCh , mFlashProcess2(0) , mFinishInitTask(nullptr) #endif , mInitOnAsyncConnect(false) , mAsyncInitRv(NS_ERROR_NOT_INITIALIZED) , mContentParent(nullptr) { NS_ASSERTION(mSubprocess, "Out of memory!"); - sInstantiated = true; mSandboxLevel = aSandboxLevel; mRunID = GeckoChildProcessHost::GetUniqueID(); mozilla::HangMonitor::RegisterAnnotator(*this); } PluginModuleChromeParent::~PluginModuleChromeParent() { @@ -2171,26 +2136,16 @@ PluginModuleParent::HandledWindowedPlugi void PluginModuleParent::OnInitFailure() { if (GetIPCChannel()->CanSend()) { Close(); } mShutdown = true; - - if (mIsStartingAsync) { - /* If we've failed then we need to enumerate any pending NPP_New calls - and clean them up. */ - uint32_t len = mSurrogateInstances.Length(); - for (uint32_t i = 0; i < len; ++i) { - mSurrogateInstances[i]->NotifyAsyncInitFailed(); - } - mSurrogateInstances.Clear(); - } } class PluginOfflineObserver final : public nsIObserver { public: NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER @@ -2299,26 +2254,17 @@ PluginModuleParent::NP_Initialize(NPNets mNPPIface = pFuncs; if (mShutdown) { *error = NPERR_GENERIC_ERROR; return NS_ERROR_FAILURE; } *error = NPERR_NO_ERROR; - if (mIsStartingAsync) { - if (GetIPCChannel()->CanSend()) { - // We're already connected, so we may call this immediately. - RecvNP_InitializeResult(*error); - } else { - PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs); - } - } else { - SetPluginFuncs(pFuncs); - } + SetPluginFuncs(pFuncs); return NS_OK; } nsresult PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) { PLUGIN_LOG_DEBUG_METHOD; @@ -2328,45 +2274,27 @@ PluginModuleChromeParent::NP_Initialize( return NS_ERROR_FAILURE; } *error = NPERR_NO_ERROR; mNPNIface = bFuncs; mNPPIface = pFuncs; - // NB: This *MUST* be set prior to checking whether the subprocess has - // been connected! - if (mIsStartingAsync) { - PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs); - } - if (!mSubprocess->IsConnected()) { // The subprocess isn't connected yet. Defer NP_Initialize until // OnProcessLaunched is invoked. mInitOnAsyncConnect = true; return NS_OK; } PluginSettings settings; GetSettings(&settings); TimeStamp callNpInitStart = TimeStamp::Now(); - // Asynchronous case - if (mIsStartingAsync) { - if (!SendAsyncNP_Initialize(settings)) { - Close(); - return NS_ERROR_FAILURE; - } - TimeStamp callNpInitEnd = TimeStamp::Now(); - mTimeBlocked += (callNpInitEnd - callNpInitStart); - return NS_OK; - } - - // Synchronous case if (!CallNP_Initialize(settings, error)) { Close(); return NS_ERROR_FAILURE; } else if (*error != NPERR_NO_ERROR) { Close(); return NS_ERROR_FAILURE; } @@ -2382,36 +2310,30 @@ mozilla::ipc::IPCResult PluginModuleParent::RecvNP_InitializeResult(const NPError& aError) { if (aError != NPERR_NO_ERROR) { OnInitFailure(); return IPC_OK(); } SetPluginFuncs(mNPPIface); - if (mIsStartingAsync) { - InitAsyncSurrogates(); - } mNPInitialized = true; return IPC_OK(); } mozilla::ipc::IPCResult PluginModuleChromeParent::RecvNP_InitializeResult(const NPError& aError) { if (!mContentParent) { return PluginModuleParent::RecvNP_InitializeResult(aError); } bool initOk = aError == NPERR_NO_ERROR; if (initOk) { SetPluginFuncs(mNPPIface); - if (mIsStartingAsync && !SendAssociatePluginId()) { - initOk = false; - } } mNPInitialized = initOk; bool result = mContentParent->SendLoadPluginResult(mPluginId, initOk); mContentParent = nullptr; if (!result) { return IPC_FAIL_NO_REASON(this); } return IPC_OK(); @@ -2436,22 +2358,17 @@ PluginModuleParent::NP_Initialize(NPNets } #if defined(XP_WIN) || defined(XP_MACOSX) nsresult PluginModuleContentParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) { PLUGIN_LOG_DEBUG_METHOD; - nsresult rv = PluginModuleParent::NP_Initialize(bFuncs, error); - if (mIsStartingAsync && GetIPCChannel()->CanSend()) { - // We're already connected, so we may call this immediately. - RecvNP_InitializeResult(*error); - } - return rv; + return PluginModuleParent::NP_Initialize(bFuncs, error); } #endif nsresult PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) { nsresult rv = PluginModuleParent::NP_Initialize(bFuncs, error); @@ -2472,25 +2389,16 @@ PluginModuleChromeParent::NP_Initialize( return NS_OK; } #endif PluginSettings settings; GetSettings(&settings); TimeStamp callNpInitStart = TimeStamp::Now(); - if (mIsStartingAsync) { - if (!SendAsyncNP_Initialize(settings)) { - return NS_ERROR_FAILURE; - } - TimeStamp callNpInitEnd = TimeStamp::Now(); - mTimeBlocked += (callNpInitEnd - callNpInitStart); - return NS_OK; - } - if (!CallNP_Initialize(settings, error)) { Close(); return NS_ERROR_FAILURE; } TimeStamp callNpInitEnd = TimeStamp::Now(); mTimeBlocked += (callNpInitEnd - callNpInitStart); RecvNP_InitializeResult(*error); return NS_OK; @@ -2499,21 +2407,16 @@ PluginModuleChromeParent::NP_Initialize( mozilla::ipc::IPCResult PluginModuleParent::RecvNP_InitializeResult(const NPError& aError) { if (aError != NPERR_NO_ERROR) { OnInitFailure(); return IPC_OK(); } - if (mIsStartingAsync && mNPPIface) { - SetPluginFuncs(mNPPIface); - InitAsyncSurrogates(); - } - mNPInitialized = true; return IPC_OK(); } mozilla::ipc::IPCResult PluginModuleChromeParent::RecvNP_InitializeResult(const NPError& aError) { bool ok = true; @@ -2521,20 +2424,16 @@ PluginModuleChromeParent::RecvNP_Initial if ((ok = SendAssociatePluginId())) { ok = mContentParent->SendLoadPluginResult(mPluginId, aError == NPERR_NO_ERROR); mContentParent = nullptr; } } else if (aError == NPERR_NO_ERROR) { // Initialization steps for (e10s && !asyncInit) || !e10s #if defined XP_WIN - if (mIsStartingAsync) { - SetPluginFuncs(mNPPIface); - } - // Send the info needed to join the browser process's audio session to the // plugin process. nsID id; nsString sessionName; nsString iconPath; if (NS_SUCCEEDED(mozilla::widget::GetAudioSessionData(id, sessionName, iconPath))) { @@ -2550,78 +2449,34 @@ PluginModuleChromeParent::RecvNP_Initial if (!ok) { return IPC_FAIL_NO_REASON(this); } return PluginModuleParent::RecvNP_InitializeResult(aError); } #endif -void -PluginModuleParent::InitAsyncSurrogates() -{ - if (MaybeRunDeferredShutdown()) { - // We've shut down, so the surrogates are no longer valid. Clear - // mSurrogateInstances to ensure that these aren't used. - mSurrogateInstances.Clear(); - return; - } - - uint32_t len = mSurrogateInstances.Length(); - for (uint32_t i = 0; i < len; ++i) { - NPError err; - mAsyncNewRv = mSurrogateInstances[i]->NPP_New(&err); - if (NS_FAILED(mAsyncNewRv)) { - mSurrogateInstances[i]->NotifyAsyncInitFailed(); - continue; - } - } - mSurrogateInstances.Clear(); -} - bool PluginModuleParent::RemovePendingSurrogate( const RefPtr<PluginAsyncSurrogate>& aSurrogate) { - return mSurrogateInstances.RemoveElement(aSurrogate); -} - -bool -PluginModuleParent::MaybeRunDeferredShutdown() -{ - if (!mIsStartingAsync || !mIsNPShutdownPending) { - return false; - } - MOZ_ASSERT(!mShutdown); - NPError error; - if (!DoShutdown(&error)) { - return false; - } - mIsNPShutdownPending = false; - return true; + // XXX: this function will be removed soon. + MOZ_CRASH(); } nsresult PluginModuleParent::NP_Shutdown(NPError* error) { PLUGIN_LOG_DEBUG_METHOD; if (mShutdown) { *error = NPERR_GENERIC_ERROR; return NS_ERROR_FAILURE; } - /* If we're still running an async NP_Initialize then we need to defer - shutdown until we've received the result of the NP_Initialize call. */ - if (mIsStartingAsync && !mNPInitialized) { - mIsNPShutdownPending = true; - *error = NPERR_NO_ERROR; - return NS_OK; - } - if (!DoShutdown(error)) { return NS_ERROR_FAILURE; } return NS_OK; } bool @@ -2676,49 +2531,32 @@ PluginModuleParent::NP_GetValue(void *fu #if defined(XP_WIN) || defined(XP_MACOSX) nsresult PluginModuleParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) { NS_ASSERTION(pFuncs, "Null pointer!"); *error = NPERR_NO_ERROR; - if (mIsStartingAsync && !IsChrome()) { - mNPPIface = pFuncs; -#if defined(XP_MACOSX) - if (mNPInitialized) { - SetPluginFuncs(pFuncs); - InitAsyncSurrogates(); - } else { - PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs); - } -#else - PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs); -#endif - } else { - SetPluginFuncs(pFuncs); - } + SetPluginFuncs(pFuncs); return NS_OK; } nsresult PluginModuleChromeParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) { #if defined(XP_MACOSX) if (mInitOnAsyncConnect) { PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs); mNPPIface = pFuncs; *error = NPERR_NO_ERROR; return NS_OK; } #else - if (mIsStartingAsync) { - PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs); - } if (!mSubprocess->IsConnected()) { mNPPIface = pFuncs; mInitOnAsyncConnect = true; *error = NPERR_NO_ERROR; return NS_OK; } #endif @@ -2747,47 +2585,26 @@ PluginModuleParent::NPP_New(NPMIMEType p { PLUGIN_LOG_DEBUG_METHOD; if (mShutdown) { *error = NPERR_GENERIC_ERROR; return NS_ERROR_FAILURE; } - if (mIsStartingAsync) { - if (!PluginAsyncSurrogate::Create(this, pluginType, instance, - argc, argn, argv)) { - *error = NPERR_GENERIC_ERROR; - return NS_ERROR_FAILURE; - } - - if (!mNPInitialized) { - RefPtr<PluginAsyncSurrogate> surrogate = - PluginAsyncSurrogate::Cast(instance); - mSurrogateInstances.AppendElement(surrogate); - *error = NPERR_NO_ERROR; - return NS_PLUGIN_INIT_PENDING; - } - } - // create the instance on the other side InfallibleTArray<nsCString> names; InfallibleTArray<nsCString> values; for (int i = 0; i < argc; ++i) { names.AppendElement(NullableString(argn[i])); values.AppendElement(NullableString(argv[i])); } - nsresult rv = NPP_NewInternal(pluginType, instance, names, values, - saved, error); - if (NS_FAILED(rv) || !mIsStartingAsync) { - return rv; - } - return NS_PLUGIN_INIT_PENDING; + return NPP_NewInternal(pluginType, instance, names, values, saved, error); } class nsCaseInsensitiveUTF8StringArrayComparator { public: template<class A, class B> bool Equals(const A& a, const B& b) const { return a.Equals(b.get(), nsCaseInsensitiveUTF8StringComparator()); @@ -2911,20 +2728,16 @@ PluginModuleParent::NPP_NewInternal(NPMI // specified. if (supportsAsyncRender && supportsForceDirect && gfxWindowsPlatform::GetPlatform()->SupportsPluginDirectDXGIDrawing()) { ForceDirect(names, values); } #endif } - // Release the surrogate reference that was in pdata - RefPtr<PluginAsyncSurrogate> surrogate( - dont_AddRef(PluginAsyncSurrogate::Cast(instance))); - // Now replace it with the instance instance->pdata = static_cast<PluginDataResolver*>(parentInstance); // Any IPC messages for the PluginInstance actor should be dispatched to the // DocGroup for the plugin's document. RefPtr<nsPluginInstanceOwner> owner = parentInstance->GetOwner(); nsCOMPtr<nsIDOMElement> elt; owner->GetDOMElement(getter_AddRefs(elt)); if (nsCOMPtr<nsINode> node = do_QueryInterface(elt)) { @@ -2942,41 +2755,29 @@ PluginModuleParent::NPP_NewInternal(NPMI instance->pdata = nullptr; *error = NPERR_GENERIC_ERROR; return NS_ERROR_FAILURE; } { // Scope for timer Telemetry::AutoTimer<Telemetry::BLOCKED_ON_PLUGIN_INSTANCE_INIT_MS> timer(GetHistogramKey()); - if (mIsStartingAsync) { - MOZ_ASSERT(surrogate); - surrogate->AsyncCallDeparting(); - if (!SendAsyncNPP_New(parentInstance)) { + if (!CallSyncNPP_New(parentInstance, error)) { + // if IPC is down, we'll get an immediate "failed" return, but + // without *error being set. So make sure that the error + // condition is signaled to nsNPAPIPluginInstance + if (NPERR_NO_ERROR == *error) { *error = NPERR_GENERIC_ERROR; - return NS_ERROR_FAILURE; } - *error = NPERR_NO_ERROR; - } else { - if (!CallSyncNPP_New(parentInstance, error)) { - // if IPC is down, we'll get an immediate "failed" return, but - // without *error being set. So make sure that the error - // condition is signaled to nsNPAPIPluginInstance - if (NPERR_NO_ERROR == *error) { - *error = NPERR_GENERIC_ERROR; - } - return NS_ERROR_FAILURE; - } + return NS_ERROR_FAILURE; } } if (*error != NPERR_NO_ERROR) { - if (!mIsStartingAsync) { - NPP_Destroy(instance, 0); - } + NPP_Destroy(instance, 0); return NS_ERROR_FAILURE; } UpdatePluginTimeout(); return NS_OK; }
--- a/dom/plugins/ipc/PluginModuleParent.h +++ b/dom/plugins/ipc/PluginModuleParent.h @@ -94,18 +94,16 @@ protected: DeallocPPluginInstanceParent(PPluginInstanceParent* aActor) override; public: explicit PluginModuleParent(bool aIsChrome); virtual ~PluginModuleParent(); bool RemovePendingSurrogate(const RefPtr<PluginAsyncSurrogate>& aSurrogate); - /** @return the state of the pref that controls async plugin init */ - bool IsStartingAsync() const { return mIsStartingAsync; } /** @return whether this modules NP_Initialize has successfully completed executing */ bool IsInitialized() const { return mNPInitialized; } bool IsChrome() const { return mIsChrome; } virtual void SetPlugin(nsNPAPIPlugin* plugin) override { mPlugin = plugin; @@ -310,26 +308,23 @@ public: #if defined(XP_MACOSX) virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing) override; #endif #if defined(XP_MACOSX) || defined(XP_WIN) virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor) override; #endif - void InitAsyncSurrogates(); - layers::TextureClientRecycleAllocator* EnsureTextureAllocatorForDirectBitmap(); layers::TextureClientRecycleAllocator* EnsureTextureAllocatorForDXGISurface(); protected: void NotifyFlashHang(); void NotifyPluginCrashed(); void OnInitFailure(); - bool MaybeRunDeferredShutdown(); bool DoShutdown(NPError* error); bool GetSetting(NPNVariable aVariable); void GetSettings(PluginSettings* aSettings); bool mIsChrome; bool mShutdown; bool mHadLocalInstance; @@ -352,20 +347,18 @@ protected: ScopedClose mPluginXSocketFdDup; #endif bool GetPluginDetails(); friend class mozilla::plugins::PluginAsyncSurrogate; - bool mIsStartingAsync; bool mNPInitialized; bool mIsNPShutdownPending; - nsTArray<RefPtr<PluginAsyncSurrogate>> mSurrogateInstances; nsresult mAsyncNewRv; uint32_t mRunID; RefPtr<layers::TextureClientRecycleAllocator> mTextureAllocatorForDirectBitmap; RefPtr<layers::TextureClientRecycleAllocator> mTextureAllocatorForDXGISurface; #ifdef MOZ_CRASHREPORTER /** @@ -427,24 +420,16 @@ class PluginModuleChromeParent * LoadModule * * This may or may not launch a plugin child process, * and may or may not be very expensive. */ static PluginLibrary* LoadModule(const char* aFilePath, uint32_t aPluginId, nsPluginTag* aPluginTag); - /** - * The following two functions are called by SetupBridge to determine - * whether an existing plugin module was reused, or whether a new module - * was instantiated by the plugin host. - */ - static void ClearInstantiationFlag() { sInstantiated = false; } - static bool DidInstantiate() { return sInstantiated; } - virtual ~PluginModuleChromeParent(); /* * Takes a full multi-process dump including the plugin process and the * content process. If aBrowserDumpId is not empty then the browser dump * associated with it will be paired to the resulting minidump. * Takes ownership of the file associated with aBrowserDumpId. * @@ -535,19 +520,16 @@ class PluginModuleChromeParent EvaluateHangUIState(const bool aReset); #endif // XP_WIN virtual bool WaitForIPCConnection() override; virtual mozilla::ipc::IPCResult RecvNP_InitializeResult(const NPError& aError) override; - void - SetContentParent(dom::ContentParent* aContentParent); - bool SendAssociatePluginId(); void CachedSettingChanged(); virtual mozilla::ipc::IPCResult AnswerGetKeyState(const int32_t& aVirtKey, int16_t* aRet) override; @@ -699,17 +681,16 @@ private: nsresult mAsyncInitRv; // mContentParent is to be used ONLY during the IPC dance that occurs // when ContentParent::RecvLoadPlugin is called under async plugin init! // In other contexts it is *unsafe*, as there might be multiple content // processes in existence! dom::ContentParent* mContentParent; nsCOMPtr<nsIObserver> mPluginOfflineObserver; bool mIsBlocklisted; - static bool sInstantiated; #if defined(XP_WIN) && defined(MOZ_SANDBOX) mozilla::SandboxPermissions mSandboxPermissions; #endif #ifdef MOZ_CRASHREPORTER nsCOMPtr<nsIFile> mBrowserDumpFile; TakeFullMinidumpCallback mTakeFullMinidumpCallback; #endif
--- a/dom/plugins/ipc/PluginProcessParent.cpp +++ b/dom/plugins/ipc/PluginProcessParent.cpp @@ -126,19 +126,19 @@ PluginProcessParent::Delete() ioLoop->PostTask( NewNonOwningRunnableMethod("plugins::PluginProcessParent::Delete", this, &PluginProcessParent::Delete)); } void -PluginProcessParent::SetCallRunnableImmediately(bool aCallImmediately) +PluginProcessParent::SetCallRunnableImmediately() { - mRunCompleteTaskImmediately = aCallImmediately; + mRunCompleteTaskImmediately = true; } /** * This function exists so that we may provide an additional level of * indirection between the task being posted to main event loop (a * RunnableMethod) and the launch complete task itself. This is needed * for cases when both WaitUntilConnected or OnChannel* race to invoke the * task.
--- a/dom/plugins/ipc/PluginProcessParent.h +++ b/dom/plugins/ipc/PluginProcessParent.h @@ -63,17 +63,17 @@ public: { return true; } const std::string& GetPluginFilePath() { return mPluginFilePath; } using mozilla::ipc::GeckoChildProcessHost::GetChannel; - void SetCallRunnableImmediately(bool aCallImmediately); + void SetCallRunnableImmediately(); virtual bool WaitUntilConnected(int32_t aTimeoutMs = 0) override; virtual void OnChannelConnected(int32_t peer_pid) override; virtual void OnChannelError() override; bool IsConnected(); static bool IsPluginProcessId(base::ProcessId procId);
--- a/xpcom/base/ErrorList.py +++ b/xpcom/base/ErrorList.py @@ -460,17 +460,16 @@ with modules["NETWORK"]: # 7: NS_ERROR_MODULE_PLUGINS # ======================================================================= with modules["PLUGINS"]: errors["NS_ERROR_PLUGINS_PLUGINSNOTCHANGED"] = FAILURE(1000) errors["NS_ERROR_PLUGIN_DISABLED"] = FAILURE(1001) errors["NS_ERROR_PLUGIN_BLOCKLISTED"] = FAILURE(1002) errors["NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED"] = FAILURE(1003) errors["NS_ERROR_PLUGIN_CLICKTOPLAY"] = FAILURE(1004) - errors["NS_PLUGIN_INIT_PENDING"] = SUCCESS(1005) # ======================================================================= # 8: NS_ERROR_MODULE_LAYOUT # ======================================================================= with modules["LAYOUT"]: # Return code for nsITableLayout