Bug 1515689 - Fix initialization/destruction race in UiCompositorControllerParent r=botond

It looks like we can do initialization and destruction from the UI
thread before the bits that run on the Compositor thread have run. Avoid
this by synchronously waiting on the Compositor.

Differential Revision: https://phabricator.services.mozilla.com/D16596

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Willcox 2019-01-17 19:37:32 +00:00
Родитель b75c602ced
Коммит 92d41d761f
1 изменённых файлов: 11 добавлений и 3 удалений

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

@ -17,6 +17,7 @@
#include "mozilla/Unused.h"
#include "FrameMetrics.h"
#include "SynchronousTask.h"
namespace mozilla {
namespace layers {
@ -277,9 +278,16 @@ void UiCompositorControllerParent::InitializeForSameProcess() {
// This function is called by UiCompositorControllerChild in the main thread.
// So dispatch to the compositor thread to Initialize.
if (!CompositorThreadHolder::IsInCompositorThread()) {
CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod(
"layers::UiCompositorControllerParent::InitializeForSameProcess", this,
&UiCompositorControllerParent::InitializeForSameProcess));
SynchronousTask task(
"UiCompositorControllerParent::InitializeForSameProcess");
CompositorThreadHolder::Loop()->PostTask(NS_NewRunnableFunction(
"UiCompositorControllerParent::InitializeForSameProcess", [&]() {
AutoCompleteTask complete(&task);
InitializeForSameProcess();
}));
task.Wait();
return;
}