Bug 924622 - Make sure gfx's ipc shutdown happens before shutting down xpcom threads. r=bsmedberg, sotaro

This commit is contained in:
Nicolas Silva 2014-04-15 11:34:33 +02:00
Родитель 06fbeaf02f
Коммит 9b422edf54
3 изменённых файлов: 29 добавлений и 11 удалений

Просмотреть файл

@ -331,6 +331,10 @@ static void ReleaseImageClientNow(ImageClient* aClient)
// static
void ImageBridgeChild::DispatchReleaseImageClient(ImageClient* aClient)
{
if (!IsCreated()) {
return;
}
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(&ReleaseImageClientNow, aClient));
@ -345,6 +349,10 @@ static void ReleaseTextureClientNow(TextureClient* aClient)
// static
void ImageBridgeChild::DispatchReleaseTextureClient(TextureClient* aClient)
{
if (!IsCreated()) {
return;
}
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(&ReleaseTextureClientNow, aClient));
@ -364,6 +372,10 @@ static void UpdateImageClientNow(ImageClient* aClient, ImageContainer* aContaine
void ImageBridgeChild::DispatchImageClientUpdate(ImageClient* aClient,
ImageContainer* aContainer)
{
if (!IsCreated()) {
return;
}
if (InImageBridgeChildThread()) {
UpdateImageClientNow(aClient, aContainer);
return;
@ -388,6 +400,10 @@ static void FlushAllImagesSync(ImageClient* aClient, ImageContainer* aContainer,
//static
void ImageBridgeChild::FlushAllImages(ImageClient* aClient, ImageContainer* aContainer, bool aExceptFront)
{
if (!IsCreated()) {
return;
}
if (InImageBridgeChildThread()) {
FlushAllImagesNow(aClient, aContainer, aExceptFront);
return;
@ -577,15 +593,14 @@ bool ImageBridgeChild::StartUpOnThread(Thread* aThread)
void ImageBridgeChild::DestroyBridge()
{
if (!IsCreated()) {
return;
}
NS_ABORT_IF_FALSE(!InImageBridgeChildThread(),
"This method must not be called in this thread.");
// ...because we are about to dispatch synchronous messages to the
// ImageBridgeChild thread.
if (!IsCreated()) {
return;
}
ReentrantMonitor barrier("ImageBridgeDestroyTask lock");
ReentrantMonitorAutoEnter autoMon(barrier);
@ -607,7 +622,8 @@ void ImageBridgeChild::DestroyBridge()
bool InImageBridgeChildThread()
{
return sImageBridgeChildThread->thread_id() == PlatformThread::CurrentId();
return ImageBridgeChild::IsCreated() &&
sImageBridgeChildThread->thread_id() == PlatformThread::CurrentId();
}
MessageLoop * ImageBridgeChild::GetMessageLoop() const

Просмотреть файл

@ -491,12 +491,6 @@ gfxPlatform::Shutdown()
mozilla::gl::GLContextProviderEGL::Shutdown();
#endif
// This will block this thread untill the ImageBridge protocol is completely
// deleted.
ImageBridgeChild::ShutDown();
CompositorParent::ShutDown();
delete gGfxPlatformPrefsLock;
gfxPrefs::DestroySingleton();

Просмотреть файл

@ -126,6 +126,9 @@ extern nsresult nsStringInputStreamConstructor(nsISupports *, REFNSIID, void **)
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/SystemMemoryReporter.h"
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/CompositorParent.h"
#ifdef MOZ_VISUAL_EVENT_TRACER
#include "mozilla/VisualEventTracer.h"
#endif
@ -742,6 +745,11 @@ ShutdownXPCOM(nsIServiceManager* servMgr)
}
}
// This must happen after the shutdown of media and widgets, which
// are triggered by the NS_XPCOM_SHUTDOWN_OBSERVER_ID notification.
mozilla::layers::ImageBridgeChild::ShutDown();
mozilla::layers::CompositorParent::ShutDown();
NS_ProcessPendingEvents(thread);
mozilla::scache::StartupCache::DeleteSingleton();
if (observerService)