Well, it seems that maybe we shouldn't count on Travis CI to support Catalina. If anyone can reproduce the error on OS X 10.15 and wants to contribute a bug fix, please us know. We are happy to work together with you to fix this issue! Thanks.
@k-ye kindly offered to help with this. According to what the users say, it seems that the crash happens here: https://github.com/taichi-dev/taichi/blob/master/taichi/gui/cocoa.cpp#L121
One possibility is that OS X GUI system is slightly changed on 10.15.
@k-ye cocoa.cpp uses C++ to simulate objective-C (the only supported language for OS X GUI development) calls. You may also want to check out the "Opening a Window" section in these slides for more details about this hack :-)
I've located the crash to be L140 in taichi/gui/cocoa.cpp:
call(window, "makeKeyAndOrderFront:", window);
makeKeyAndOrderFront displays the window. My guess is that this should be done inside AppDelegate::applicationDidFinishLaunching (like this)? However, this callback seems to be invoked only if we call [NSApp run], and we can't do that because it blocks.
I tried a fix by delay launching the window to GUI::process_event(). This seems to solve the problem.
I cannot say if this fixes the real problem, though. I found a simple obj-c code that basically did the same thing (https://www.oreilly.com/library/view/building-cocoa-applications/0596002351/ch04.html), without delaying launching the window. It worked just fine :-/
Actually, scratch what i said before. I moved makeKeyAndOrderFront to one line below canvas initialization and it's working now.
I saw that canvas is used inside redraw. Maybe we hit a race condition here?
Hi @k-ye I think what you concluded here makes a lot of sense. makeKeyAndOrderFront might have triggered a redraw which uses the canvas, which may or may not have been initialized, depending on the event scheduling. This explains stochastic crashing to some degree. Let's release it in v0.3.21 and see how the user reacts! Thank you!
According to users' feedback so far, I believe this is (finally) resolved. Thanks again, @k-ye !