Test case: https://gist.github.com/c45a3d632e1740fad6d3d8bb351af654. Reproduces on macOS 100% of the time.

```
2:03:30 PM Received signal 11 SEGV_MAPERR 000000000018
2:03:30 PM 0   Electron Framework                  0x0000000115292649 base::debug::CollectStackTrace(void**, unsigned long) + 9
2:03:30 PM 1   Electron Framework                  0x00000001151ab783 base::debug::StackTrace::StackTrace() + 19
2:03:30 PM 2   Electron Framework                  0x00000001152925a1 base::debug::(anonymous namespace)::StackDumpSignalHandler(int, __siginfo*, void*) + 1329
2:03:30 PM 3   libsystem_platform.dylib            0x00007fff696df5fd _sigtramp + 29
2:03:30 PM 4   ???                                 0x00000000000005d5 0x0 + 1493
2:03:30 PM 5   Electron Framework                  0x00000001109cf2d8 non-virtual thunk to electron::api::BrowserWindow::DidFirstVisuallyNonEmptyPaint() + 24
2:03:30 PM 6   Electron Framework                  0x00000001144d9f9b void content::WebContentsImpl::WebContentsObserverList::NotifyObservers<void (content::WebContentsObserver::*)()>(void (content::WebContentsObserver::*)()) + 475
2:03:30 PM 7   Electron Framework                  0x0000000114500156 content::WebContentsImpl::DidFirstVisuallyNonEmptyPaint(content::RenderViewHostImpl*) + 102
2:03:30 PM 8   Electron Framework                  0x0000000112037738 blink::mojom::FrameWidgetHostStubDispatch::Accept(blink::mojom::FrameWidgetHost*, mojo::Message*) + 1928
2:03:30 PM 9   Electron Framework                  0x000000011569a5ef mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message*) + 623
2:03:30 PM 10  Electron Framework                  0x00000001156a0a6f mojo::MessageDispatcher::Accept(mojo::Message*) + 271
2:03:30 PM 11  Electron Framework                  0x000000011569c15d mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message*) + 61
2:03:30 PM 12  Electron Framework                  0x0000000115a2ce96 IPC::(anonymous namespace)::ChannelAssociatedGroupController::AcceptOnEndpointThread(mojo::Message) + 710
2:03:30 PM 13  Electron Framework                  0x0000000115a29b0c base::internal::Invoker<base::internal::BindState<void (IPC::(anonymous namespace)::ChannelAssociatedGroupController::*)(mojo::Message), scoped_refptr<IPC::(anonymous namespace)::ChannelAssociatedGroupController>, mojo::Message>, void ()>::RunOnce(base::internal::BindStateBase*) + 140
2:03:30 PM 14  Electron Framework                  0x0000000115229c6b base::TaskAnnotator::RunTask(char const*, base::PendingTask*) + 411
2:03:30 PM 15  Electron Framework                  0x000000011524e35e base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::sequence_manager::LazyNow*) + 974
2:03:30 PM 16  Electron Framework                  0x000000011524dacb base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() + 107
2:03:30 PM 17  Electron Framework                  0x000000011524e982 non-virtual thunk to base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() + 18
2:03:30 PM 18  Electron Framework                  0x00000001152a9703 base::MessagePumpCFRunLoopBase::RunWork() + 83
2:03:30 PM 19  Electron Framework                  0x00000001152a24c2 base::mac::CallWithEHFrame(void () block_pointer) + 10
2:03:30 PM 20  Electron Framework                  0x00000001152a911f base::MessagePumpCFRunLoopBase::RunWorkSource(void*) + 63
2:03:30 PM 21  CoreFoundation                      0x00007fff2f446832 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
2:03:30 PM 22  CoreFoundation                      0x00007fff2f4467d1 __CFRunLoopDoSource0 + 103
2:03:30 PM 23  CoreFoundation                      0x00007fff2f4465eb __CFRunLoopDoSources0 + 209
2:03:30 PM 24  CoreFoundation                      0x00007fff2f44531a __CFRunLoopRun + 927
2:03:30 PM 25  CoreFoundation                      0x00007fff2f44491e CFRunLoopRunSpecific + 462
2:03:30 PM 26  HIToolbox                           0x00007fff2e070abd RunCurrentEventLoopInMode + 292
2:03:30 PM 27  HIToolbox                           0x00007fff2e0707d5 ReceiveNextEventCommon + 584
2:03:30 PM 28  HIToolbox                           0x00007fff2e070579 _BlockUntilNextEventMatchingListInModeWithFilter + 64
2:03:30 PM 29  AppKit                              0x00007fff2c6b7039 _DPSNextEvent + 883
2:03:30 PM 30  AppKit                              0x00007fff2c6b5880 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
2:03:30 PM 31  AppKit                              0x00007fff2c6a758e -[NSApplication run] + 658
2:03:30 PM 32  Electron Framework                  0x00000001152aa2ec base::MessagePumpNSApplication::DoRun(base::MessagePump::Delegate*) + 348
2:03:30 PM 33  Electron Framework                  0x00000001152a8ab3 base::MessagePumpCFRunLoopBase::Run(base::MessagePump::Delegate*) + 131
2:03:30 PM 34  Electron Framework                  0x000000011524eeeb base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) + 651
2:03:30 PM 35  Electron Framework                  0x00000001152027c0 base::RunLoop::Run(base::Location const&) + 880
2:03:30 PM 36  Electron Framework                  0x0000000113ddb396 content::BrowserMainLoop::RunMainMessageLoop() + 246
2:03:30 PM 37  Electron Framework                  0x0000000113ddd112 content::BrowserMainRunnerImpl::Run() + 82
2:03:30 PM 38  Electron Framework                  0x0000000113dd860b content::BrowserMain(content::MainFunctionParams const&) + 251
2:03:30 PM 39  Electron Framework                  0x00000001123587bb content::ContentMainRunnerImpl::RunBrowser(content::MainFunctionParams&, bool) + 1419
2:03:30 PM 40  Electron Framework                  0x00000001123581c0 content::ContentMainRunnerImpl::Run(bool) + 528
2:03:30 PM 41  Electron Framework                  0x00000001123570bd content::RunContentProcess(content::ContentMainParams const&, content::ContentMainRunner*) + 2653
2:03:30 PM 42  Electron Framework                  0x00000001123571ac content::ContentMain(content::ContentMainParams const&) + 44
2:03:30 PM 43  Electron Framework                  0x0000000110993ef7 ElectronMain + 135
2:03:30 PM 44  Electron                            0x0000000109933cea main + 298
2:03:30 PM 45  libdyld.dylib                       0x00007fff694e6cc9 start + 1
2:03:30 PM 46  ???                                 0x0000000000000004 0x0 + 4
```
shell/browser/api/electron_api_browser_window.cc
content::RenderViewHost* new_host) {
  if (old_host)
    old_host->GetWidget()->RemoveInputEventObserver(this);
  if (new_host)
    new_host->GetWidget()->AddInputEventObserver(this);
}
void BrowserWindow::RenderFrameCreated(
    content::RenderFrameHost* render_frame_host) {
  if (!window()->transparent())
    return;
  content::RenderWidgetHostImpl* impl = content::RenderWidgetHostImpl::FromID(
      render_frame_host->GetProcess()->GetID(),
      render_frame_host->GetRoutingID());
  if (impl)
    impl->owner_delegate()->SetBackgroundOpaque(false);
}
void BrowserWindow::DidFirstVisuallyNonEmptyPaint() {
  if (window()->IsVisible())
    return;
  
  
  auto* const view = web_contents()->GetRenderWidgetHostView();
  view->Show();
  view->SetSize(window()->GetContentSize());
}
void BrowserWindow::BeforeUnloadDialogCancelled() {