Bug 1350986 - Add some gfxCriticalNote messages for WebRender startup failure codepaths. r=jrmuizel
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 27 Mar 2017 14:32:39 -0400
changeset 552126 c68322f0c5bfc977b0338e38b7d9bfcacca841d9
parent 552125 66c5bed82ee6e0677902416c1c79676f4d3059e9
child 552127 f54f6455a648d9ba1126f1f98e703a6671ccd76a
push id51252
push userhikezoe@mozilla.com
push dateTue, 28 Mar 2017 02:10:27 +0000
reviewersjrmuizel
bugs1350986
milestone55.0a1
Bug 1350986 - Add some gfxCriticalNote messages for WebRender startup failure codepaths. r=jrmuizel MozReview-Commit-ID: 7VHA8QBMvJ8
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/webrender_ffi.h
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -43,16 +43,21 @@ bool is_glcontext_egl(void* glcontext_pt
 
   mozilla::gl::GLContext* glcontext = reinterpret_cast<mozilla::gl::GLContext*>(glcontext_ptr);
   if (!glcontext) {
     return false;
   }
   return glcontext->GetContextType() == mozilla::gl::GLContextType::EGL;
 }
 
+void gfx_critical_note(const char* msg)
+{
+  gfxCriticalNote << msg;
+}
+
 void* get_proc_address_from_glcontext(void* glcontext_ptr, const char* procname)
 {
   MOZ_ASSERT(glcontext_ptr);
 
   mozilla::gl::GLContext* glcontext = reinterpret_cast<mozilla::gl::GLContext*>(glcontext_ptr);
   if (!glcontext) {
     return nullptr;
   }
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -41,25 +41,27 @@ public:
   }
 
   virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
   {
     layers::AutoCompleteTask complete(mTask);
 
     RefPtr<gl::GLContext> gl = gl::GLContextProvider::CreateForCompositorWidget(mCompositorWidget, true);
     if (!gl || !gl->MakeCurrent()) {
+      gfxCriticalNote << "Failed GL context creation for WebRender: " << hexa(gl.get());
       return;
     }
 
     gl->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, mMaxTextureSize);
     *mUseANGLE = gl->IsANGLE();
 
     WrRenderer* wrRenderer = nullptr;
     if (!wr_window_new(aWindowId, mSize.width, mSize.height, gl.get(),
                        this->mEnableProfiler, mWrApi, &wrRenderer)) {
+      // wr_window_new puts a message into gfxCriticalNote if it returns false
       return;
     }
     MOZ_ASSERT(wrRenderer);
 
     RefPtr<RenderThread> thread = &aRenderThread;
     auto renderer = MakeUnique<RendererOGL>(Move(thread),
                                             Move(gl),
                                             Move(mCompositorWidget),
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -550,16 +550,17 @@ fn get_proc_address(glcontext_ptr: *mut 
     symbol as *const _
 }
 
 extern "C" {
     fn is_in_compositor_thread() -> bool;
     fn is_in_render_thread() -> bool;
     fn is_in_main_thread() -> bool;
     fn is_glcontext_egl(glcontext_ptr: *mut c_void) -> bool;
+    fn gfx_critical_note(msg: *const c_char);
 }
 
 struct CppNotifier {
     window_id: WrWindowId,
 }
 
 unsafe impl Send for CppNotifier {}
 
@@ -723,16 +724,18 @@ pub extern "C" fn wr_window_new(window_i
         ..Default::default()
     };
 
     let window_size = DeviceUintSize::new(window_width, window_height);
     let (renderer, sender) = match Renderer::new(gl, opts, window_size) {
         Ok((renderer, sender)) => (renderer, sender),
         Err(e) => {
             println!(" Failed to create a Renderer: {:?}", e);
+            let msg = CString::new(format!("wr_window_new: {:?}", e)).unwrap();
+            unsafe { gfx_critical_note(msg.as_ptr()); }
             return false;
         }
     };
 
     renderer.set_render_notifier(Box::new(CppNotifier { window_id: window_id }));
 
     *out_api = Box::into_raw(Box::new(sender.create_api()));
     *out_renderer = Box::into_raw(Box::new(renderer));
--- a/gfx/webrender_bindings/webrender_ffi.h
+++ b/gfx/webrender_bindings/webrender_ffi.h
@@ -65,16 +65,17 @@ WR_DECL_FFI_2(WrFontKey, uint32_t, uint3
 // ----
 // Functions invoked from Rust code
 // ----
 
 bool is_in_compositor_thread();
 bool is_in_main_thread();
 bool is_in_render_thread();
 bool is_glcontext_egl(void* glcontext_ptr);
+void gfx_critical_note(const char* msg);
 void* get_proc_address_from_glcontext(void* glcontext_ptr, const char* procname);
 
 // -----
 // Enums used in C++ code with corresponding enums in Rust code
 // -----
 enum class WrBoxShadowClipMode: uint32_t {
   None,
   Outset,