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
public:
  using PromiseBase::PromiseBase;
  
  static void ResolvePromise(Promise<RT> promise, RT result) {
    if (gin_helper::Locker::IsBrowserProcess() &&
        !content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
      base::PostTask(FROM_HERE, {content::BrowserThread::UI},
                     base::BindOnce([](Promise<RT> promise,
                                       RT result) { promise.Resolve(result); },
                                    std::move(promise), std::move(result)));
    } else {
      promise.Resolve(result);
    }
  }
  
  static v8::Local<v8::Promise> ResolvedPromise(v8::Isolate* isolate,
                                                RT result) {
    Promise<RT> resolved(isolate);
    resolved.Resolve(result);
    return resolved.GetHandle();
  }
  
  
  v8::Maybe<bool> Resolve(const RT& value) {