We're getting lots of crash reports from users on macOS Big Sur. The crashing line is either

https://github.com/electron/electron/blob/e3c4bbd21fb0ea2a79d8572add78e4b8c07c64a8/shell/browser/ui/message_box_mac.mm#L117

or

https://github.com/electron/electron/blob/e3c4bbd21fb0ea2a79d8572add78e4b8c07c64a8/shell/browser/ui/message_box_mac.mm#L128

The crash report is annotated with:

>Crashing on exception: -[NSApplication runModalForWindow:] may not be invoked inside of transaction begin/commit pair, or inside of transaction commit (usually this means it was invoked inside of a view's -drawRect: method.)
>ViewBridge hint(s): (
>     "bridge key: most-recent-completion"
>)

This is on Electron 10.1.6, I have not tested other versions.

cc @zcbenz
shell/common/gin_helper/promise.h
gin_helper::Locker locker(isolate());
    v8::HandleScope handle_scope(isolate());
    gin_helper::MicrotasksScope microtasks_scope(isolate());
    v8::Context::Scope context_scope(GetContext());
    return GetInner()->Resolve(GetContext(),
                               gin::ConvertToV8(isolate(), value));
  }
  template <typename... ResolveType>
  v8::MaybeLocal<v8::Promise> Then(
      base::OnceCallback<void(ResolveType...)> cb) {
    static_assert(sizeof...(ResolveType) <= 1,
                  "A promise's 'Then' callback should only receive at most one "
                  "parameter");
    static_assert(
        std::is_same<RT, std::tuple_element_t<0, std::tuple<ResolveType...>>>(),
        "A promises's 'Then' callback must handle the same type as the "
        "promises resolve type");
    gin_helper::Locker locker(isolate());
    v8::HandleScope handle_scope(isolate());
    v8::Context::Scope context_scope(GetContext());
    v8::Local<v8::Value> value = gin::ConvertToV8(isolate(), std::move(cb));
    v8::Local<v8::Function> handler = value.As<v8::Function>();
    return GetHandle()->Then(GetContext(), handler);
  }
};
template <>
class Promise<void> : public PromiseBase {