Repository: electron
Issue: Crash when closing a window with a webview and devtools open
Labels: platform/macOS,component/webview,crash :boom:,bug :beetle:,status/confirmed,component/webcontents,23-x-y,24-x-y,25-x-y

Repro gist: https://gist.github.com/5e8247678bdd4f4e30bd496b2421f28c

Stack trace:
```
Process 15614 stopped
* thread #1, name = 'CrBrowserMain', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x30)
    frame #0: 0x000000010031f502 Electron Framework`::AddDevToolsExtensionsToClient() at inspectable_web_contents.cc:597:42 [opt]
   594 	#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
   595 	void InspectableWebContents::AddDevToolsExtensionsToClient() {
   596 	  // get main browser context
-> 597 	  auto* browser_context = web_contents_->GetBrowserContext();
   598 	  const extensions::ExtensionRegistry* registry =
   599 	      extensions::ExtensionRegistry::Get(browser_context);
   600 	  if (!registry)
Target 0: (Electron) stopped.
(lldb) bt
* thread #1, name = 'CrBrowserMain', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x30)
  * frame #0: 0x000000010031f502 Electron Framework`::AddDevToolsExtensionsToClient() at inspectable_web_contents.cc:597:42 [opt]
    frame #1: 0x000000010031f4b5 Electron Framework`::LoadCompleted() at inspectable_web_contents.cc:587:3 [opt]
    frame #2: 0x0000000109e4e168 Electron Framework`::ParseAndHandle<>() [inlined] Run at callback.h:166:12 [opt]
    frame #3: 0x0000000109e4e12b Electron Framework`::ParseAndHandle<>() [inlined] Apply<base::RepeatingCallback<void ()>> at devtools_embedder_message_dispatcher.cc:84 [opt]
    frame #4: 0x0000000109e4e12b Electron Framework`::ParseAndHandle<>() at devtools_embedder_message_dispatcher.cc:112 [opt]
    frame #5: 0x0000000109e4e1aa Electron Framework`::Run() [inlined] Invoke<bool (*const &)(const base::RepeatingCallback<void ()> &, base::OnceCallback<void (const base::Value *)>, const base::ListValue &), const base::RepeatingCallback<void ()> &, base::OnceCallback<void (const base::Value *)>, const base::ListValue &> at bind_internal.h:404:12 [opt]
    frame #6: 0x0000000109e4e193 Electron Framework`::Run() [inlined] MakeItSo<bool (*const &)(const base::RepeatingCallback<void ()> &, base::OnceCallback<void (const base::Value *)>, const base::ListValue &), const base::RepeatingCallback<void ()> &, base::OnceCallback<void (const base::Value *)>, const base::ListValue &> at bind_internal.h:648 [opt]
    frame #7: 0x0000000109e4e193 Electron Framework`::Run() [inlined] RunImpl<bool (*const &)(const base::RepeatingCallback<void ()> &, base::OnceCallback<void (const base::Value *)>, const base::ListValue &), const std::tuple<base::RepeatingCallback<void ()> > &, 0UL> at bind_internal.h:721 [opt]
    frame #8: 0x0000000109e4e193 Electron Framework`::Run() at bind_internal.h:703 [opt]
    frame #9: 0x0000000109e4e031 Electron Framework`::Dispatch() [inlined] Run at callback.h:166:12 [opt]
    frame #10: 0x0000000109e4dfe7 Electron Framework`::Dispatch() at devtools_embedder_message_dispatcher.cc:147 [opt]
    frame #11: 0x0000000100322146 Electron Framework`::HandleMessageFromDevToolsFrontend() at inspectable_web_contents.cc:914:33 [opt]
    frame #12: 0x00000001003247b4 Electron Framework`::MakeItSo<void (electron::InspectableWebContents::*const &)(base::Value), const base::WeakPtr<electron::InspectableWebContents> &, base::Value>() [inlined] Invoke<void (electron::InspectableWebContents::*)(base::Value), const base::WeakPtr<electron::InspectableWebContents> &, base::Value> at bind_internal.h:509:12 [opt]
[...]
```

Bisected to https://github.com/electron/electron/compare/v14.0.0-nightly.20210305...v14.0.0-nightly.20210308. #27920 seems like a likely culprit, so cc @zcbenz