Bug 1378474 - part 2 - label WebGLQuery's AvailableRunnable; r=jgilbert,billm
authorNathan Froyd <froydnj@mozilla.com>
Wed, 23 Aug 2017 10:39:40 -0400
changeset 428350 a286544935474e9cf637cecd2a7aa5def0e0eeba
parent 428349 98b144a76336dab86346a9fcbbac40672e6cc0b9
child 428351 a82248fb2615d8c3c3589078c76f17e1bbb7d255
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert, billm
bugs1378474
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1378474 - part 2 - label WebGLQuery's AvailableRunnable; r=jgilbert,billm If we have an associated canvas element, the query should go in the queue of the associated document.
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLQuery.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -1403,16 +1403,26 @@ WebGLContext::GetCompositorBackendType()
         return mCanvasElement->GetCompositorBackendType();
     } else if (mOffscreenCanvas) {
         return mOffscreenCanvas->GetCompositorBackendType();
     }
 
     return LayersBackend::LAYERS_NONE;
 }
 
+nsIDocument*
+WebGLContext::GetOwnerDoc() const
+{
+    MOZ_ASSERT(mCanvasElement);
+    if (!mCanvasElement) {
+        return nullptr;
+    }
+    return mCanvasElement->OwnerDoc();
+}
+
 void
 WebGLContext::Commit()
 {
     if (mOffscreenCanvas) {
         mOffscreenCanvas->CommitFrameToCompositor();
     }
 }
 
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -509,16 +509,17 @@ public:
     void EnqueueUpdateContextLossStatus();
 
     bool TryToRestoreContext();
 
     void AssertCachedBindings();
     void AssertCachedGlobalState();
 
     dom::HTMLCanvasElement* GetCanvas() const { return mCanvasElement; }
+    nsIDocument* GetOwnerDoc() const;
 
     // WebIDL WebGLRenderingContext API
     void Commit();
     void GetCanvas(Nullable<dom::OwningHTMLCanvasElementOrOffscreenCanvas>& retval);
     GLsizei DrawingBufferWidth() const { return IsContextLost() ? 0 : mWidth; }
     GLsizei DrawingBufferHeight() const {
         return IsContextLost() ? 0 : mHeight;
     }
--- a/dom/canvas/WebGLQuery.cpp
+++ b/dom/canvas/WebGLQuery.cpp
@@ -59,17 +59,24 @@ WebGLQuery::Delete()
     mContext->MakeContextCurrent();
     mContext->gl->fDeleteQueries(1, &mGLName);
     LinkedListElement<WebGLQuery>::removeFrom(mContext->mQueries);
 }
 
 static void
 DispatchAvailableRunnable(WebGLQuery* query)
 {
-    NS_DispatchToCurrentThread(new AvailableRunnable(query));
+    RefPtr<AvailableRunnable> runnable = new AvailableRunnable(query);
+
+    nsIDocument* document = query->mContext->GetOwnerDoc();
+    if (document) {
+        document->Dispatch(TaskCategory::Other, runnable.forget());
+        return;
+    }
+    NS_DispatchToCurrentThread(runnable.forget());
 }
 
 ////
 
 static GLenum
 TargetForDriver(const gl::GLContext* gl, GLenum target)
 {
     switch (target) {