Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

PlayerLoop internal function error when opening a native macOS file browser dialog

Discussion in 'macOS' started by CanisLupus, Dec 10, 2019.

  1. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    We have a project using a plugin named StandaloneFileBrowser, which provides methods to open file browsers (for opening and saving files) on Windows and macOS. (Yes, it is a 3rd party library, but it's much easier to illustrate the problem with it.)

    On macOS in particular, calling any of the dialogs and then confirming or cancelling the dialog will cause this error in Unity:
    We currently suspect that this may happen because entering/exiting the native dialog (which freezes the Unity player) will trigger a redraw in Unity while it is already running the PlayerLoop. Of course we could be wrong.

    To our knowledge, this didn't happen on Unity 2017.4.11f1, which we were using before in our project. This happens in Unity 2019.2.15f1 and 2019.2.12f1.

    There is another recent thread that reports the same problem for Windows, but using Unity 2017.

    I submitted this as a bug (case 1204399) but I'm attaching the project here along with the reproduction steps:

    1. Build the project for macOS, development build.
    2. Run it and wait one second for the dialog to appear.
    3. Cancel it.
    4. See the error appear.

    Does anyone have a workaround for this problem? Thanks!
     

    Attached Files:

  2. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Well, a possible workaround is to use the Async versions of the StandaloneFileBrowser calls, like
    StandaloneFileBrowser.SaveFilePanelAsync. This doesn't block Unity and seems to avoid the bug.