electron/shell
Biru Mohanathas 7f1e3ca3de
fix: shutdown crash in DownloadItem callback (#27342)
The call stack for one of our top crashes looks like this:

```
node::Abort (node_errors.cc:241)
node::Assert (node_errors.cc:256)
node::MakeCallback (callback.cc:226)
gin_helper::internal::CallMethodWithArgs (event_emitter_caller.cc:23)
gin_helper::EmitEvent<T> (event_emitter_caller.h:51)
gin_helper::EventEmitterMixin<T>::Emit<T> (event_emitter_mixin.h:81)
electron::api::DownloadItem::OnDownloadUpdated (electron_api_download_item.cc:115)
download::DownloadItemImpl::UpdateObservers (download_item_impl.cc:482)
content::DownloadManagerImpl::Shutdown (download_manager_impl.cc:508)
content::BrowserContext::~BrowserContext (browser_context.cc:476)
```

Full stack here: https://sentry.io/share/issue/9b030a0601b547188181b543c16ecda2/

During browser shutdown, the `DownloadManager` was being cleaned up
*after* the Node environment had already been destroyed. This caused the
`DownloadItem::OnDownloadUpdated` callback to crash when trying to emit
the JS `done` event.

To prevent this, we now manually shut down the `DownloadManager`
earlier. This is also mentioned in the comment on
`DownloadManager::Shutdown`:

```
// Shutdown the download manager. Content calls this when BrowserContext is
// being destructed. If the embedder needs this to be called earlier, it can
// call it. In that case, the delegate's Shutdown() method will only be called
// once.
```
2021-01-20 11:30:08 -08:00
..
app refactor: remove last use of InternalCallbackScope (#27029) 2020-12-16 14:02:36 -06:00
browser fix: shutdown crash in DownloadItem callback (#27342) 2021-01-20 11:30:08 -08:00
common chore: duplicate symbols for mojom interfaces in component build (#27186) 2021-01-19 11:31:44 +09:00
renderer chore: bump chromium to 096e5313aaf19dfa0c4710145c34d (master) (#26535) 2020-12-14 10:57:36 -08:00
utility chore: bump chromium to adc5df74b86afdff676989ced8cd3 (master) (#26223) 2020-11-13 16:16:56 -08:00