Bug 1371838 - register the WR thread pool's thread to gecko profiler. r=jrmuizel
authorJerryShih <hshih@mozilla.com>
Sat, 11 Nov 2017 18:57:31 +0800
changeset 696844 a6ad193d398eeb72b8a68a7db5cf684ec16e4a4b
parent 696843 8e69fae378b7bd766824f43d5c5935f745821730
child 696845 3fe8d225b7baeb47a4c040d3db49025008f529a1
push id88807
push userbmo:ato@sny.no
push dateSun, 12 Nov 2017 01:46:20 +0000
reviewersjrmuizel
bugs1371838
milestone58.0a1
Bug 1371838 - register the WR thread pool's thread to gecko profiler. r=jrmuizel MozReview-Commit-ID: BUyTq2vz3cO
gfx/webrender_bindings/src/bindings.rs
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -592,19 +592,24 @@ extern "C" {
     fn gecko_profiler_unregister_thread();
 }
 
 pub struct WrThreadPool(Arc<rayon::ThreadPool>);
 
 #[no_mangle]
 pub unsafe extern "C" fn wr_thread_pool_new() -> *mut WrThreadPool {
     let worker_config = rayon::Configuration::new()
-        .thread_name(|idx|{ format!("WebRender:Worker#{}", idx) })
+        .thread_name(|idx|{ format!("WRWorker#{}", idx) })
         .start_handler(|idx| {
-            register_thread_with_profiler(format!("WebRender:Worker#{}", idx));
+            let name = format!("WRWorker#{}", idx);
+            register_thread_with_profiler(name.clone());
+            gecko_profiler_register_thread(CString::new(name).unwrap().as_ptr());
+        })
+        .exit_handler(|_idx| {
+            gecko_profiler_unregister_thread();
         });
 
     let workers = Arc::new(rayon::ThreadPool::new(worker_config).unwrap());
 
     Box::into_raw(Box::new(WrThreadPool(workers)))
 }
 
 /// cbindgen:postfix=WR_DESTRUCTOR_SAFE_FUNC