Skip to content

FileBrowser.WaitForSave/LoadDialog coroutine returns too early on Android #107

Closed

Description

@jaoreir

Description of the bug

When using FileBrowser.WaitForSaveDialog(...) or FileBrowser.WaitForLoadDialog(...) coroutines, they end before FileBrowser.Success becomes true on android, causing the example coroutine in the readme of the project to not work properly.

Reproduction steps

    IEnumerator TestRoutine()
    {
        yield return FileBrowser.WaitForSaveDialog(
            FileBrowser.PickMode.Files,
            false,
            null,
            "save.txt",
            "TITLE",
            "Save"
        );
        Debug.Log($"FileBrowser.Success: {FileBrowser.Success}");
        if (FileBrowser.Success) // This never becomes true
        {
            string filePath = FileBrowser.Result[0];
            Debug.Log($"File path: {filePath}");
            FileBrowserHelpers.WriteTextToFile(filePath, "test file content 123123");
            Debug.Log("Saved");
        }
    }

If I additionally wait for FileBrowser.Success to become true, the rest of the code works fine, but now if the user clicks the "Cancel" button, the coroutine would get stuck waiting forever.

    IEnumerator TestRoutine()
    {
        yield return FileBrowser.WaitForSaveDialog(
            FileBrowser.PickMode.Files,
            false,
            null,
            "save.txt",
            "TITLE",
            "Save"
        );
        yield return new WaitUntil(() => FileBrowser.Success); // This line is needed to actually wait for the dialog to finish
        Debug.Log($"FileBrowser.Success: {FileBrowser.Success}");
        if (FileBrowser.Success)
        {
            string filePath = FileBrowser.Result[0];
            Debug.Log($"File path: {filePath}");
            FileBrowserHelpers.WriteTextToFile(filePath, "test file content 123123");
            Debug.Log("Saved");
        }
    }

Platform specs

  • Unity version: 2022.3.50f1
  • Platform: Android
  • Device: Samsung Galaxy A55 5G
  • How did you download the plugin: github repo link in manifest.json

Activity

  1. yasirkula commented on May 20, 2025

    @yasirkula
    Owner

    It was caused by 1750c04 's RequestPermissionAsync implementation. Coroutine was waiting for the dialog to become inactive but the RequestPermissionAsync function wasn't activating the file browser until the permission is granted, so the coroutine was completing immediately.

  2. added a commit that references this issue on May 20, 2025
    0990d13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions