Bug 1254029 - Do not wait in ImageBridgeChild::FlushAllImages() except gonk r=nical

This commit is contained in:
Sotaro Ikeda 2016-04-12 17:22:04 -07:00
Родитель 6ffa2e7e92
Коммит c417e9ad15
1 изменённых файлов: 34 добавлений и 4 удалений

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

@ -625,8 +625,17 @@ void ImageBridgeChild::UpdateAsyncCanvasRendererNow(AsyncCanvasRenderer* aWrappe
} }
static void FlushAllImagesSync(ImageClient* aClient, ImageContainer* aContainer, static void FlushAllImagesSync(ImageClient* aClient, ImageContainer* aContainer,
RefPtr<AsyncTransactionWaiter>&& aWaiter) RefPtr<AsyncTransactionWaiter>&& aWaiter,
ReentrantMonitor* aBarrier,
bool* const outDone)
{ {
#ifdef MOZ_WIDGET_GONK
MOZ_ASSERT(aWaiter);
#else
MOZ_ASSERT(!aWaiter);
#endif
ReentrantMonitorAutoEnter autoMon(*aBarrier);
if (!ImageBridgeChild::IsCreated() || ImageBridgeChild::IsShutDown()) { if (!ImageBridgeChild::IsCreated() || ImageBridgeChild::IsShutDown()) {
// How sad. If we get into this branch it means that the ImageBridge // How sad. If we get into this branch it means that the ImageBridge
// got destroyed between the time we ImageBridgeChild::FlushAllImage // got destroyed between the time we ImageBridgeChild::FlushAllImage
@ -635,7 +644,12 @@ static void FlushAllImagesSync(ImageClient* aClient, ImageContainer* aContainer,
// in the shutdown of gecko for this to be happening for a good reason. // in the shutdown of gecko for this to be happening for a good reason.
NS_WARNING("Something is holding on to graphics resources after the shutdown" NS_WARNING("Something is holding on to graphics resources after the shutdown"
"of the graphics subsystem!"); "of the graphics subsystem!");
#ifdef MOZ_WIDGET_GONK
aWaiter->DecrementWaitCount(); aWaiter->DecrementWaitCount();
#endif
*outDone = true;
aBarrier->NotifyAll();
return; return;
} }
MOZ_ASSERT(aClient); MOZ_ASSERT(aClient);
@ -649,7 +663,11 @@ static void FlushAllImagesSync(ImageClient* aClient, ImageContainer* aContainer,
// If any AsyncTransactionTrackers were created by FlushAllImages and attached // If any AsyncTransactionTrackers were created by FlushAllImages and attached
// to aWaiter, aWaiter will not complete until those trackers all complete. // to aWaiter, aWaiter will not complete until those trackers all complete.
// Otherwise, aWaiter will be ready to complete now. // Otherwise, aWaiter will be ready to complete now.
#ifdef MOZ_WIDGET_GONK
aWaiter->DecrementWaitCount(); aWaiter->DecrementWaitCount();
#endif
*outDone = true;
aBarrier->NotifyAll();
} }
// static // static
@ -667,15 +685,27 @@ void ImageBridgeChild::FlushAllImages(ImageClient* aClient,
return; return;
} }
RefPtr<AsyncTransactionWaiter> waiter = new AsyncTransactionWaiter(); ReentrantMonitor barrier("FlushAllImages Lock");
ReentrantMonitorAutoEnter autoMon(barrier);
bool done = false;
RefPtr<AsyncTransactionWaiter> waiter;
#ifdef MOZ_WIDGET_GONK
waiter = new AsyncTransactionWaiter();
// This increment is balanced by the decrement in FlushAllImagesSync // This increment is balanced by the decrement in FlushAllImagesSync
waiter->IncrementWaitCount(); waiter->IncrementWaitCount();
#endif
sImageBridgeChildSingleton->GetMessageLoop()->PostTask( sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableFunction(&FlushAllImagesSync, aClient, aContainer, waiter)); NewRunnableFunction(&FlushAllImagesSync, aClient, aContainer, waiter, &barrier, &done));
while (!done) {
barrier.Wait();
}
#ifdef MOZ_WIDGET_GONK
waiter->WaitComplete(); waiter->WaitComplete();
#endif
} }
void void