The very same problem here since few years. Beachball on object initiation on some machines on Mojave. Contacted Apple Developer Technical Support (DTS) and they believe it's a bug. Also report it to the relevant engineering team, but no response.
self.dialog = NSOpenPanel();
However if you install xCode and try to debug the project on the same machine that is having this issue it disappears immediately. So the only clue of the issue is the app crash report (attached to this post). If somebody from the Apple side is following this thread please assist.
Crash Report - https://developer.apple.com/forums/content/attachment/3c1dd9d8-09d5-4fd9-bdeb-211e7a675b18Another report - https://developer.apple.com/forums/content/attachment/268c48be-eff1-4440-a465-8202edb3f4af