Bug 1861252 - Anticipate servo thread pool shutdown in leak checking builds. r=xpcom-reviewers,emilio

Differential Revision: https://phabricator.services.mozilla.com/D195098
This commit is contained in:
Jens Stutte 2023-11-30 15:28:39 +00:00
Родитель cad0b85c61
Коммит 3bc5d595aa
1 изменённых файлов: 11 добавлений и 10 удалений

Просмотреть файл

@ -635,6 +635,13 @@ nsresult ShutdownXPCOM(nsIServiceManager* aServMgr) {
observerService->Shutdown();
}
#ifdef NS_FREE_PERMANENT_DATA
// In leak-checking / ASAN / etc. builds, shut down the Servo thread-pool,
// which will wait for all the work to be done. For other builds, we don't
// really want to wait on shutdown for possibly slow tasks.
Servo_ShutdownThreadPool();
#endif
// XPCOMShutdownFinal is the default phase for ClearOnShutdown.
// This AdvanceShutdownPhase will thus free most ClearOnShutdown()'ed
// smart pointers. Some destructors may fire extra main thread runnables
@ -768,16 +775,10 @@ nsresult ShutdownXPCOM(nsIServiceManager* aServMgr) {
GkRust_Shutdown();
#ifdef NS_FREE_PERMANENT_DATA
// By the time we're shutting down, there may still be async parse tasks going
// on in the Servo thread-pool. This is fairly uncommon, though not
// impossible. CSS parsing heavily uses the atom table, so obviously it's not
// fine to get rid of it.
//
// In leak-checking / ASAN / etc. builds, shut down the servo thread-pool,
// which will wait for all the work to be done. For other builds, we don't
// really want to wait on shutdown for possibly slow tasks. So just leak the
// atom table in those.
Servo_ShutdownThreadPool();
// As we do shutdown Servo only in leak-checking builds, there may still
// be async parse tasks going on in the Servo thread-pool in other builds.
// CSS parsing heavily uses the atom table, so we can safely drop it only
// if Servo has been stopped, too.
NS_ShutdownAtomTable();
#endif