Firefox shutdown is blocked on extension shutdown,
Extension shutdown is blocked on extension startup,
extension startup is blocked on background startup,
background startup is blocked on an extension's background page.
The background startup can take a long while; see telemetry: WEBEXT_BACKGROUND_PAGE_LOAD_MS, for Firefox Beta 67:
- The median is 1.42 seconds
- The 75th percentile is 3.03 seconds
- The 95th percentile is 15.21 seconds.
- 0.51% takes over 50 seconds.
This long delay is responsible for 499 of the AsyncShutdown timeout crashes in the past week.
ext-backgroundPage.js is already prepared to reliably handle early shut down when delayed startups are enabled (especially after the changes from bug 1501375 that landed in 67).
We should also stop blocking startup in other cases, i.e. avoid
await this.build(). Many of our tests rely on the background page to have started up before proceeding with the tests, so to avoid intermittent test failures, we need to update tests and await the background page's startup event where necessary to avoid intermittents.