Bug 1557208 - Leak WebRender's thread pool. r=jrmuizel
authorNicolas Silva <nsilva@mozilla.com>
Wed, 17 Jul 2019 18:29:53 +0200
changeset 483441 927c1651317bd5e7c69635a48924643e81bc3079
parent 483440 4c9962d08d72dbc1503d7446a46dd4782e2a259b
child 483455 17ad24a685ef790a9e022013763c73022d4f5714
push id113724
push usernsilva@mozilla.com
push dateFri, 19 Jul 2019 09:28:26 +0000
treeherdermozilla-inbound@927c1651317b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1557208
milestone70.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 1557208 - Leak WebRender's thread pool. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D38368
gfx/webrender_bindings/src/bindings.rs
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1047,16 +1047,23 @@ pub unsafe extern "C" fn wr_thread_pool_
         })
         .exit_handler(|_idx| {
             gecko_profiler_unregister_thread();
         })
         .build();
 
     let workers = Arc::new(worker.unwrap());
 
+    // This effectively leaks the thread pool. Not great but we only create one and it lives
+    // for as long as the browser.
+    // Do this to avoid intermittent race conditions with nsThreadManager shutdown.
+    // A better fix would involve removing the dependency between implicit nsThreadManager
+    // and webrender's threads, or be able to synchronously terminate rayon's thread pool.
+    mem::forget(Arc::clone(&workers));
+
     Box::into_raw(Box::new(WrThreadPool(workers)))
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn wr_thread_pool_delete(thread_pool: *mut WrThreadPool) {
     Box::from_raw(thread_pool);
 }