We use GdkWindow from mozcontainer to draw when CSD or Wayland is enabled. It means that the mShell's GdkWindow is used by GDK to draw decorations (usually shadows) and main firefox window is rendered to mContainer which is nested in mShell. To draw asynchronously (off-main thread) we can no more draw directly to GdkWindow owned by mContainer. This GdkWindow (and its wl_surface) is owned by Gdk and it's updated by Gdk internals from main thread. Instead we create wl_subsurface which overlays whole mContainer and attach it as child of wl_surface owned by mContainer. The wl_subsurface is owned by us, it's not touched by Gdk and can be drawn off main thread without any collision/deadlock.
Created attachment 8834428 [details] [diff] [review] wip WIP patch. Bug 1299083 has to be sorted out first.