Mac OSX [SOLVED] macOS Async Dialog Extension Problems

Samuel Venable

Time Killer
I've tested this extension on Windows, Mac, and Linux, and the only platform I have any problems in is Mac, and more specifically I only have these issues with the functions which utilize the async dialog event. Note: the modal, non-async versions of each dialog function are working just fine for me on macOS Catalina. It's only the async dialogs that cause the segfault. I have a feeling this might be a problem more so with how I wrote the extension so the source code to the dylib is included in the ZIP file under the extensions node in the resource tree. I am using the ID of 63 for the async dialog event as instructed from my previous Helpdesk ticket I filed to YoYo. I could change it to use the social event as a workaround, but I doubt even if I tried that it would fix the segfault.

I think why it might be segfaulting is because I am attempting to use functions that explicitly block the main thread despite being run from a secondary thread, but I'm not sure if that's even what my code is actually doing under the hood, as I've seen Apple's docs make no direct mention the functions should behave that way, (that is--block the main thread), when called from a secondary thread.

Make sure you codesign the provided *.dylib before attempting to run the project, otherwise you'll get errors.

You'll notice from what the compile form says, I didn't codesign it for my test case, that is because I am using an older version of the Runtime intentionally to avoid the need to codesign. Note - the source of the problem can't be that I didn't codesign it because again the app works just fine on Catalina for me if I use this older runtime + only test with the non-async functions, and they do actually work doing this. What does in fact crash, regardless of the runtime used, and regardless of whether you codesign, is the async functions alone. Just wanted to clarify this stuff.

After further investigation the problem appears to be that the NSWindow can not be brought into a different thread other than the main thread when during or after being made visible -- any ideas on how I should write my extension differently to ensure this isn't an issue? I feel completely clueless on how to achieve this, or where my window creation code should be moved to. I also found from a stackoverflow question that the source of the problem could be that I am not setting a valid rectangle size for the dialogs when they are being initialized, and I will try this and report back whether it makes a difference, but I doubt that will be the entire problem solver here.



Compile Form:
https://pastebin.com/gDHXDmQz

Crash Report from Screenshot:
https://pastebin.com/N5a1XmLC

macOS Async Dialog Extension Test (*.yyz)

Thanks you!
Samuel
 
Last edited:

Samuel Venable

Time Killer
This has been solved. I decided to create a secondary executable to reside in the app bundle's "Resources" folder, and this executable is launched asynchronously as a separate/child process of the game to create the async dialogs, and then it reads from the output when the dialogs close to get the return value. Works perfect for my DialogModule extension, however it will require users to build the dlgmod executable from source code and replace the one I have built, manually, so they can actually run it and have it codesigned along with everything else. If you download the yyz in the OP now it reflects these changes so you can test it for yourself. :)
 
Top