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
if (gin_helper::Locker::IsBrowserProcess() &&
        !content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
      base::PostTask(
          FROM_HERE, {content::BrowserThread::UI},
          base::BindOnce(
              
              
              
              [](PromiseBase&& promise, std::string str) {
                promise.RejectWithErrorMessage(str);
              },
              std::move(promise), std::string(errmsg.data(), errmsg.size())));
    } else {
      promise.RejectWithErrorMessage(errmsg);
    }
  }
  v8::Maybe<bool> Reject();
  v8::Maybe<bool> Reject(v8::Local<v8::Value> except);
  v8::Maybe<bool> RejectWithErrorMessage(base::StringPiece message);
  v8::Local<v8::Context> GetContext() const;
  v8::Local<v8::Promise> GetHandle() const;
  v8::Isolate* isolate() const { return isolate_; }