diff --git a/widget/gtk/WindowSurfaceWayland.cpp b/widget/gtk/WindowSurfaceWayland.cpp index 68d8488695d1..753b49eb0c9d 100644 --- a/widget/gtk/WindowSurfaceWayland.cpp +++ b/widget/gtk/WindowSurfaceWayland.cpp @@ -556,6 +556,7 @@ WindowSurfaceWayland::WindowSurfaceWayland(nsWindow *aWindow) , mBackBuffer(nullptr) , mFrameCallback(nullptr) , mFrameCallbackSurface(nullptr) + , mDisplayThreadMessageLoop(MessageLoop::current()) , mDelayedCommit(false) , mFullScreenDamage(false) , mIsMainThread(NS_IsMainThread()) @@ -574,8 +575,8 @@ WindowSurfaceWayland::~WindowSurfaceWayland() if (!mIsMainThread) { // We can be destroyed from main thread even though we was created/used // in compositor thread. We have to unref/delete WaylandDisplay in compositor - // thread then. - MessageLoop::current()->PostTask( + // thread then and we can't use MessageLoop::current() here. + mDisplayThreadMessageLoop->PostTask( NewRunnableFunction(&WaylandDisplayRelease, mWaylandDisplay->GetDisplay())); } else { WaylandDisplayRelease(mWaylandDisplay->GetDisplay()); diff --git a/widget/gtk/WindowSurfaceWayland.h b/widget/gtk/WindowSurfaceWayland.h index bc1dadc52c03..8fd98a6f3e65 100644 --- a/widget/gtk/WindowSurfaceWayland.h +++ b/widget/gtk/WindowSurfaceWayland.h @@ -121,6 +121,7 @@ private: WindowBackBuffer* mBackBuffer; wl_callback* mFrameCallback; wl_surface* mFrameCallbackSurface; + MessageLoop* mDisplayThreadMessageLoop; bool mDelayedCommit; bool mFullScreenDamage; bool mIsMainThread;