mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1798630 - Use nsThread::Shutdown for the RenderThread. r=gfx-reviewers,sotaro
Differential Revision: https://phabricator.services.mozilla.com/D161026
This commit is contained in:
parent
f88b044e04
commit
91630e2b39
@ -70,6 +70,9 @@ LazyLogModule gRenderThreadLog("RenderThread");
|
||||
|
||||
static StaticRefPtr<RenderThread> sRenderThread;
|
||||
static mozilla::BackgroundHangMonitor* sBackgroundHangMonitor;
|
||||
#ifdef DEBUG
|
||||
static bool sRenderThreadEverStarted = false;
|
||||
#endif
|
||||
|
||||
RenderThread::RenderThread(RefPtr<nsIThread> aThread)
|
||||
: mThread(std::move(aThread)),
|
||||
@ -92,6 +95,13 @@ void RenderThread::Start(uint32_t aNamespace) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!sRenderThread);
|
||||
|
||||
#ifdef DEBUG
|
||||
// Check to ensure nobody will try to ever start us more than once during
|
||||
// the process' lifetime (in particular after ShutDown).
|
||||
MOZ_ASSERT(!sRenderThreadEverStarted);
|
||||
sRenderThreadEverStarted = true;
|
||||
#endif
|
||||
|
||||
RefPtr<nsIThread> thread;
|
||||
nsresult rv = NS_NewNamedThread(
|
||||
"Renderer", getter_AddRefs(thread),
|
||||
@ -139,28 +149,33 @@ void RenderThread::ShutDown() {
|
||||
sRenderThread->mHasShutdown = true;
|
||||
}
|
||||
|
||||
layers::SynchronousTask task("RenderThread");
|
||||
RefPtr<Runnable> runnable =
|
||||
WrapRunnable(RefPtr<RenderThread>(sRenderThread.get()),
|
||||
&RenderThread::ShutDownTask, &task);
|
||||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
RefPtr<RenderThread>(sRenderThread.get()), &RenderThread::ShutDownTask);
|
||||
sRenderThread->PostRunnable(runnable.forget());
|
||||
task.Wait();
|
||||
|
||||
// This will empty the thread queue and thus run the above runnable while
|
||||
// spinning the MT event loop.
|
||||
nsCOMPtr<nsIThread> oldThread = sRenderThread->GetRenderThread();
|
||||
oldThread->Shutdown();
|
||||
|
||||
layers::SharedSurfacesParent::Shutdown();
|
||||
layers::CompositableInProcessManager::Shutdown();
|
||||
|
||||
sRenderThread = nullptr;
|
||||
#ifdef XP_WIN
|
||||
if (widget::WinCompositorWindowThread::Get()) {
|
||||
widget::WinCompositorWindowThread::ShutDown();
|
||||
}
|
||||
#endif
|
||||
|
||||
// We null this out only after we finished shutdown to give everbody the
|
||||
// chance to check for sRenderThread->mHasShutdown. Hopefully everybody
|
||||
// checks this before using us!
|
||||
sRenderThread = nullptr;
|
||||
}
|
||||
|
||||
extern void ClearAllBlobImageResources();
|
||||
|
||||
void RenderThread::ShutDownTask(layers::SynchronousTask* aTask) {
|
||||
layers::AutoCompleteTask complete(aTask);
|
||||
void RenderThread::ShutDownTask() {
|
||||
MOZ_ASSERT(IsInRenderThread());
|
||||
LOG("RenderThread::ShutDownTask()");
|
||||
|
||||
|
@ -306,7 +306,7 @@ class RenderThread final {
|
||||
explicit RenderThread(RefPtr<nsIThread> aThread);
|
||||
|
||||
void DeferredRenderTextureHostDestroy();
|
||||
void ShutDownTask(layers::SynchronousTask* aTask);
|
||||
void ShutDownTask();
|
||||
void InitDeviceTask();
|
||||
void PostRunnable(already_AddRefed<nsIRunnable> aRunnable);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user