### Preflight Checklist

* [x] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md) for this project.
* [x] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project adheres to.
* [x] I have searched the issue tracker for an issue that matches the one I want to file, without success.

### Issue Details

* **Electron Version:**
  * 8.2.0
  * 9.0.0-beta.12
* **Operating System:**
  * MacOS 10.14.6
* **Last Known Working Electron version:**
  * Unknown

### Expected Behavior
The renderer do not crash.

### Actual Behavior
The renderer is crashing as soon as the app is starting.

### To Reproduce

```sh
$ git clone https://github.com/boutetnico/electron-bug-report.git -b fpcollect
$ npm install
$ npm start || electron .
```

### Additional Information

I have spent a lot of time researching this and came to the conclusion the following conditions are required for the crash to occur:

- `nodeIntegrationInSubFrames`=`true`
- An invokable IPC is sent from preload to the main process
- Followed by invokation of `executeJavaScript`
- index.html loads [fp-collect](https://github.com/antoinevastel/fp-collect/blob/master/src/fpCollect.js)

Crash report from Sentry:
```
OS Version: macOS 10.14.6 (18G3020)
Report Version: 104

Crashed Thread: 33484704

Application Specific Information:
Fatal Error: EXC_BAD_ACCESS / KERN_INVALID_ADDRESS

Thread 33484704 Crashed:
0   Electron Framework              0x104a799de         electron::api::ExecuteJavaScript (electron_api_web_frame.cc:385)
1   Electron Framework              0x104a7e68b         mate::internal::Dispatcher<T>::DispatchToCallback (callback.h:132)
2   Electron Framework              0x1056028fb         v8::internal::FunctionCallbackArguments::Call (api-arguments-inl.h:158)
3   Electron Framework              0x105601df9         v8::internal::(anonymous namespace)::HandleApiCallHelper<T> (builtins-api.cc:111)
4   Electron Framework              0x1056013d1         v8::internal::Builtin_Impl_HandleApiCall (builtins-api.cc:141)
5   Electron Framework              0x1060047d8         Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit
6   Electron Framework              0x105f94277         Builtins_InterpreterEntryTrampoline
7   Electron Framework              0x105f8dc78         Builtins_ArgumentsAdaptorTrampoline
8   Electron Framework              0x105f94277         [inlined] Builtins_InterpreterEntryTrampoline
9   Electron Framework              0x105f94277         Builtins_InterpreterEntryTrampoline
10  Electron Framework              0x105fc23af         Builtins_AsyncFunctionAwaitResolveClosure
11  Electron Framework              0x105fe3b91         Builtins_PromiseFulfillReactionJob
12  Electron Framework              0x105fb4127         Builtins_RunMicrotasks
13  Electron Framework              0x105f91ad7         Builtins_JSRunMicrotasksEntry
14  Electron Framework              0x1056bb60f         v8::internal::(anonymous namespace)::Invoke (simulator.h:142)
15  Electron Framework              0x1056bbc12         v8::internal::(anonymous namespace)::InvokeWithTryCatch (execution.cc:326)
16  Electron Framework              0x1056bbcdc         v8::internal::Execution::TryRunMicrotasks (execution.cc:405)
17  Electron Framework              0x1056ddce6         v8::internal::MicrotaskQueue::RunMicrotasks (microtask-queue.cc:164)
18  Electron Framework              0x104a75ede         electron::util::Promise<T>::ResolveWithGin (promise_util.h:186)
19  Electron Framework              0x104a75dcb         base::internal::Invoker<T>::RunOnce (electron_api_renderer_ipc.cc:92)
20  Electron Framework              0x106a67c5a         electron::mojom::ElectronBrowser_Invoke_ForwardToCallback::Accept (callback.h:98)
21  Electron Framework              0x106e6584f         mojo::InterfaceEndpointClient::HandleValidatedMessage (interface_endpoint_client.cc:549)
22  Electron Framework              0x106e6ac72         mojo::internal::MultiplexRouter::ProcessIncomingMessage (multiplex_router.cc:883)
23  Electron Framework              0x106e69808         mojo::internal::MultiplexRouter::ProcessTasks (multiplex_router.cc:718)
24  Electron Framework              0x106e6b227         mojo::internal::MultiplexRouter::LockAndCallProcessTasks (multiplex_router.cc:911)
25  Electron Framework              0x106b5595e         base::TaskAnnotator::RunTask (callback.h:98)
26  Electron Framework              0x106b651b9         base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl (thread_controller_with_message_pump_impl.cc:365)
27  Electron Framework              0x106b64f56         base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoSomeWork (thread_controller_with_message_pump_impl.cc:219)
28  Electron Framework              0x106bb3da0         ___ZN4base24MessagePumpCFRunLoopBase13RunWorkSourceEPv_block_invoke (message_pump_mac.mm:491)
29  Electron Framework              0x106baf5e9         base::mac::CallWithEHFrame
30  Electron Framework              0x106bb367e         base::MessagePumpCFRunLoopBase::RunWorkSource (message_pump_mac.mm:467)
31  CoreFoundation                  0x7fff36af6e33      <unknown>
32  CoreFoundation                  0x7fff36af6dd9      <unknown>
33  CoreFoundation                  0x7fff36ada79b      <unknown>
34  CoreFoundation                  0x7fff36ad9d65      <unknown>
35  CoreFoundation                  0x7fff36ad966e      <unknown>
36  Foundation                      0x7fff38d3f2ff      <unknown>
37  Electron Framework              0x106bb42b0         base::MessagePumpNSRunLoop::DoRun (message_pump_mac.mm:737)
38  Electron Framework              0x106bb3011         base::MessagePumpCFRunLoopBase::Run (message_pump_mac.mm:186)
39  Electron Framework              0x106b65a76         base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run (thread_controller_with_message_pump_impl.cc:463)
40  Electron Framework              0x106b3dd66         base::RunLoop::Run (run_loop.cc:156)
41  Electron Framework              0x109fe65d8         content::RendererMain (renderer_main.cc:213)
42  Electron Framework              0x106218a1b         content::ContentMainRunnerImpl::Run (content_main_runner_impl.cc:871)
43  Electron Framework              0x10845e903         service_manager::Main (main.cc:423)
44  Electron Framework              0x1054d66f3         content::ContentMain (content_main.cc:19)
45  Electron Framework              0x10490fb93         ElectronMain (electron_library_main.mm:23)
46  Electron Helper (Renderer)      0x103b1ff84         main (electron_main.cc:232)
47  libdyld.dylib                   0x7fff62a613d5      [inlined] <unknown>
48  libdyld.dylib                   0x7fff62a613d5      <unknown>

Thread 33484721
0   libsystem_kernel.dylib          0x7fff62b97bfa      <unknown>
1   libsystem_pthread.dylib         0x7fff62c543fd      [inlined] <unknown>
2   libsystem_pthread.dylib         0x7fff62c543fd      <unknown>
3   libobjc.A.dylib                 0x7fff61285d49      <unknown>
4   libsystem_malloc.dylib          0x7fff62c0f282      [inlined] <unknown>
5   libsystem_malloc.dylib          0x7fff62c0f282      <unknown>
6   libobjc.A.dylib                 0x7fff6129ba07      <unknown>
7   libobjc.A.dylib                 0x7fff61285d49      <unknown>
8   libdispatch.dylib               0x7fff62a14127      <unknown>
9   libsystem_malloc.dylib          0x7fff62c0f282      <unknown>
10  libsystem_malloc.dylib          0x7fff62c0ed79      <unknown>
11  libdispatch.dylib               0x7fff62a13b6d      <unknown>
12  libdispatch.dylib               0x7fff62a1b71a      <unknown>
13  CoreFoundation                  0x7fff36c16231      <unknown>
14  libdispatch.dylib               0x7fff62a14626      <unknown>
15  libdispatch.dylib               0x7fff62a226f1      <unknown>
16  libdispatch.dylib               0x7fff62a22b46      <unknown>
17  libsystem_pthread.dylib         0x7fff62c546e6      <unknown>
18  libsystem_pthread.dylib         0x7fff62c543fd      <unknown>
19  libdispatch.dylib               0x7fff62a23497      <unknown>

Thread 33484722
0   libsystem_kernel.dylib          0x7fff62b97bfa      <unknown>
1   libsystem_pthread.dylib         0x7fff62c543fd      <unknown>
2   libdispatch.dylib               0x7fff62a22aec      <unknown>

Thread 33484724
0   libsystem_kernel.dylib          0x7fff62b9e0a2      <unknown>
1   Electron Framework              0x106bc3465         base::MessagePumpKqueue::Run (message_pump_kqueue.cc:170)
2   Electron Framework              0x106b65a76         base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run (thread_controller_with_message_pump_impl.cc:463)
3   Electron Framework              0x106b3dd66         base::RunLoop::Run (run_loop.cc:156)
4   Electron Framework              0x106b6dc83         base::internal::ServiceThread::Run (service_thread.cc:61)
5   Electron Framework              0x106b7c3e3         base::Thread::ThreadMain (thread.cc:376)
6   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
7   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
8   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
9   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484725
0   libsystem_kernel.dylib          0x7fff62b9621a      <unknown>
1   Electron Framework              0x106bb8b85         base::WaitableEvent::TimedWait (waitable_event_mac.cc:167)
2   Electron Framework              0x106b767d7         base::internal::WorkerThread::Delegate::WaitForWork (worker_thread.cc:35)
3   Electron Framework              0x106b77059         base::internal::WorkerThread::RunWorker (worker_thread.cc:316)
4   Electron Framework              0x106b76d43         base::internal::WorkerThread::RunPooledWorker (worker_thread.cc:223)
5   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
6   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
7   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
8   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484726
0   libsystem_kernel.dylib          0x7fff62b9621a      <unknown>
1   Electron Framework              0x106bb8b85         base::WaitableEvent::TimedWait (waitable_event_mac.cc:167)
2   Electron Framework              0x106b767d7         base::internal::WorkerThread::Delegate::WaitForWork (worker_thread.cc:35)
3   Electron Framework              0x106b76e2d         base::internal::WorkerThread::RunWorker (worker_thread.cc:297)
4   Electron Framework              0x106b76cb3         base::internal::WorkerThread::RunBackgroundPooledWorker (worker_thread.cc:229)
5   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
6   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
7   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
8   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484727
0   libsystem_kernel.dylib          0x7fff62b9e0a2      <unknown>
1   Electron Framework              0x106bc3465         base::MessagePumpKqueue::Run (message_pump_kqueue.cc:170)
2   Electron Framework              0x106b65a76         base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run (thread_controller_with_message_pump_impl.cc:463)
3   Electron Framework              0x106b3dd66         base::RunLoop::Run (run_loop.cc:156)
4   Electron Framework              0x106b7c3e3         base::Thread::ThreadMain (thread.cc:376)
5   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
6   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
7   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
8   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484728
0   libsystem_kernel.dylib          0x7fff62b9621a      <unknown>
1   Electron Framework              0x106bb8b85         base::WaitableEvent::TimedWait (waitable_event_mac.cc:167)
2   Electron Framework              0x106bb899e         base::WaitableEvent::Wait (waitable_event_mac.cc:108)
3   Electron Framework              0x106b20dd6         base::MessagePumpDefault::Run (message_pump_default.cc:55)
4   Electron Framework              0x106b65a76         base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run (thread_controller_with_message_pump_impl.cc:463)
5   Electron Framework              0x106b3dd66         base::RunLoop::Run (run_loop.cc:156)
6   Electron Framework              0x106b7c3e3         base::Thread::ThreadMain (thread.cc:376)
7   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
8   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
9   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
10  libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484729
0   libsystem_kernel.dylib          0x7fff62b9621a      <unknown>
1   Electron Framework              0x106bb8b85         base::WaitableEvent::TimedWait (waitable_event_mac.cc:167)
2   Electron Framework              0x106b20d7a         base::MessagePumpDefault::Run (message_pump_default.cc:57)
3   Electron Framework              0x106b65a76         base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run (thread_controller_with_message_pump_impl.cc:463)
4   Electron Framework              0x106b3dd66         base::RunLoop::Run (run_loop.cc:156)
5   Electron Framework              0x10615b5f6         blink::scheduler::WorkerThread::SimpleThreadImpl::Run (worker_thread.cc:169)
6   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
7   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
8   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
9   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484730
0   libsystem_kernel.dylib          0x7fff62b9621a      <unknown>
1   Electron Framework              0x106bb8b85         base::WaitableEvent::TimedWait (waitable_event_mac.cc:167)
2   Electron Framework              0x106bb899e         base::WaitableEvent::Wait (waitable_event_mac.cc:108)
3   Electron Framework              0x106b767c9         base::internal::WorkerThread::Delegate::WaitForWork (worker_thread.cc:33)
4   Electron Framework              0x106b76e2d         base::internal::WorkerThread::RunWorker (worker_thread.cc:297)
5   Electron Framework              0x106b76d73         base::internal::WorkerThread::RunSharedWorker (worker_thread.cc:235)
6   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
7   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
8   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
9   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484731
0   libsystem_kernel.dylib          0x7fff62b99866      <unknown>
1   Electron Framework              0x106bad1b4         base::ConditionVariable::Wait (condition_variable_posix.cc:75)
2   Electron Framework              0x109f37345         content::CategorizedWorkerPool::Run (categorized_worker_pool.cc:280)
3   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
4   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
5   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
6   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484732
0   libsystem_kernel.dylib          0x7fff62b99866      <unknown>
1   Electron Framework              0x106bad1b4         base::ConditionVariable::Wait (condition_variable_posix.cc:75)
2   Electron Framework              0x109f37345         content::CategorizedWorkerPool::Run (categorized_worker_pool.cc:280)
3   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
4   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
5   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
6   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484733
0   libsystem_kernel.dylib          0x7fff62b99866      <unknown>
1   Electron Framework              0x106bad1b4         base::ConditionVariable::Wait (condition_variable_posix.cc:75)
2   Electron Framework              0x109f37345         content::CategorizedWorkerPool::Run (categorized_worker_pool.cc:280)
3   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
4   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
5   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
6   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484756
0   libsystem_kernel.dylib          0x7fff62b9d616      <unknown>
1   Electron Framework              0x104a6e776         electron::NodeBindings::EmbedThreadRunner (node_bindings.cc:459)
2   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
3   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
4   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484757
0   libsystem_kernel.dylib          0x7fff62b9621a      <unknown>
1   Electron Framework              0x106bb8b85         base::WaitableEvent::TimedWait (waitable_event_mac.cc:167)
2   Electron Framework              0x106b767d7         base::internal::WorkerThread::Delegate::WaitForWork (worker_thread.cc:35)
3   Electron Framework              0x106b77059         base::internal::WorkerThread::RunWorker (worker_thread.cc:316)
4   Electron Framework              0x106b76d43         base::internal::WorkerThread::RunPooledWorker (worker_thread.cc:223)
5   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
6   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
7   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
8   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484758
0   libsystem_kernel.dylib          0x7fff62b9621a      <unknown>
1   Electron Framework              0x106bb8b85         base::WaitableEvent::TimedWait (waitable_event_mac.cc:167)
2   Electron Framework              0x106b767d7         base::internal::WorkerThread::Delegate::WaitForWork (worker_thread.cc:35)
3   Electron Framework              0x106b77059         base::internal::WorkerThread::RunWorker (worker_thread.cc:316)
4   Electron Framework              0x106b76d43         base::internal::WorkerThread::RunPooledWorker (worker_thread.cc:223)
5   Electron Framework              0x106badf86         base::(anonymous namespace)::ThreadFunc (platform_thread_posix.cc:81)
6   libsystem_pthread.dylib         0x7fff62c552eb      <unknown>
7   libsystem_pthread.dylib         0x7fff62c58249      <unknown>
8   libsystem_pthread.dylib         0x7fff62c5440d      <unknown>

Thread 33484779
0   libsystem_kernel.dylib          0x7fff62b97bfa      <unknown>
1   libsystem_pthread.dylib         0x7fff62c543fd      <unknown>
2   CoreFoundation                  0x7fff36aa2d17      <unknown>
3   libsystem_malloc.dylib          0x7fff62c0f282      [inlined] <unknown>
4   libsystem_malloc.dylib          0x7fff62c0f282      [inlined] <unknown>
5   libsystem_malloc.dylib          0x7fff62c0f282      <unknown>
6   libsystem_malloc.dylib          0x7fff62c0ed79      <unknown>
7   libdispatch.dylib               0x7fff62a21402      <unknown>
8   libsystem_pthread.dylib         0x7fff62c54910      <unknown>
9   libdispatch.dylib               0x7fff62a14e99      <unknown>
10  libdispatch.dylib               0x7fff62a1b540      <unknown>
11  libdispatch.dylib               0x7fff62a168fd      <unknown>
12  libdispatch.dylib               0x7fff62a14626      <unknown>
13  libdispatch.dylib               0x7fff62a226f1      <unknown>
14  libdispatch.dylib               0x7fff62a22b46      <unknown>
15  libsystem_pthread.dylib         0x7fff62c546e6      <unknown>
16  libsystem_pthread.dylib         0x7fff62c543fd      <unknown>
17  libdispatch.dylib               0x7fff62a22b95      <unknown>



EOF
```
shell/renderer/api/electron_api_web_frame.cc
blink::WebFrame* web_frame = GetRenderFrame(window)->GetWebFrame();
  if (web_frame->IsWebLocalFrame()) {
    web_frame->ToWebLocalFrame()
        ->FrameWidget()
        ->GetActiveWebInputMethodController()
        ->CommitText(blink::WebString::FromUTF8(text),
                     blink::WebVector<blink::WebImeTextSpan>(),
                     blink::WebRange(), 0);
  }
}
base::string16 InsertCSS(v8::Local<v8::Value> window,
                         const std::string& css,
                         gin_helper::Arguments* args) {
  blink::WebDocument::CSSOrigin css_origin =
      blink::WebDocument::CSSOrigin::kAuthorOrigin;
  gin_helper::Dictionary options;
  if (args->GetNext(&options))
    options.Get("cssOrigin", &css_origin);
  blink::WebFrame* web_frame = GetRenderFrame(window)->GetWebFrame();
  if (web_frame->IsWebLocalFrame()) {
    return web_frame->ToWebLocalFrame()
        ->GetDocument()
        .InsertStyleSheet(blink::WebString::FromUTF8(css), nullptr, css_origin)
        .Utf16();
  }
  return base::string16();
}
void RemoveInsertedCSS(v8::Local<v8::Value> window, const base::string16& key) {