Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLB and JSON files not appearing Quest Pro #89

Closed
SashelI opened this issue Oct 13, 2023 · 10 comments
Closed

GLB and JSON files not appearing Quest Pro #89

SashelI opened this issue Oct 13, 2023 · 10 comments
Labels

Comments

@SashelI
Copy link

SashelI commented Oct 13, 2023

Description of the bug

Hi,

Thanks for the asset ! It works well on the Quest Pro (Android), but I've got a problem : .glb and .json files are not appearing in the browser, nor listed by system.IO when retrieving directory info. It works well in the editor when removing the "!Unity_Editor" preprocessing for testing, but once inside the quest the files are non existent. (but png files in the same folder are here).

I've tried using Directory.GetFiles(path) instead of GetFileSystemInfo, but same. The "show hidden files" button doesn't help, and there is no log message.

Reproduction steps

  • Open the browser on a Quest Pro device
  • Try to load a .glb or .json file

Capture d’écran 2023-10-13 145645

com oculus vrshell-20231013-145755

Platform specs

  • Unity version: 2021.3.25f1
  • Platform: Android
  • Device: Quest Pro, Android 12L
  • How did you download the plugin: Asset Store

Additional info

Manisfest File :
<?xml version="1.0" encoding="utf-8" standalone="no"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:installLocation="auto"> <uses-permission android:name="android.permission.RECORD_AUDIO" tools:node="remove" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" tools:node="remove" /> <application android:label="@string/app_name" android:icon="@mipmap/app_icon" android:allowBackup="false" android:requestLegacyExternalStorage="true"> <activity android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity" android:excludeFromRecents="true" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" /> <meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only" /> </application> <uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" /> <uses-feature android:name="com.oculus.feature.PASSTHROUGH" android:required="true" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace"/> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/> </manifest>

image

@SashelI SashelI added the bug label Oct 13, 2023
@yasirkula
Copy link
Owner

Is this png file downloaded by your app? If you copy an arbitrary png file from your computer to Downloads, can it be seen by SimpleFileBrowser? BTW are/were any Storage permission dialogs displayed while opening the file browser?

@SashelI
Copy link
Author

SashelI commented Oct 13, 2023

Is this png file downloaded by your app? If you copy an arbitrary png file from your computer to Downloads, can it be seen by SimpleFileBrowser? BTW are/were any Storage permission dialogs displayed while opening the file browser?

Yup the png was copied from my computer, as were the .glb and the .json :) Nope no storage permission dialogue, well no more I accepted everything it asked once

@yasirkula
Copy link
Owner

yasirkula commented Oct 14, 2023

If you log contents of Directory.GetFiles("/storage/emulated/0/Download") in your own C# script, does it contain the GLB and JSON files? And does removing MANAGE_EXTERNAL_STORAGE permission somehow have any effect?

@SashelI
Copy link
Author

SashelI commented Oct 16, 2023

If you log contents of Directory.GetFiles("/storage/emulated/0/Download") in your own C# script, does it contain the GLB and JSON files? And does removing MANAGE_EXTERNAL_STORAGE permission somehow have any effect?

Hey, I just tested, Logging Directory.GetFiles("/storage/emulated/0/Download") from my script only shows one file (the png) and the MANAGE_EXTERNAL_STORAGE permission is indeed useless in this, I added it afterwards in hopes of making it work but nah ^^"

@yasirkula
Copy link
Owner

I think we need to figure out why Directory.GetFiles fails in the first place. Since it's a built-in .NET function, this issue isn't directly caused by SimpleFileBrowser. If the Directory.GetFiles issue can be resolved somehow, then I believe SimpleFileBrowser will work without any issues.

For the time being, I don't have time to research this. If you find useful resources related to this issue in your own research, please let me know.

@SashelI
Copy link
Author

SashelI commented Oct 16, 2023

Ok thanks. I've tried to find that out before asking here and found nothing, i'll keep on looking.

@SashelI
Copy link
Author

SashelI commented Oct 16, 2023

For anyone running into the same issue : it was caused by the "MANAGE_EXTERNAL_STORAGE permission" not being taken into account if you don't explicitely ask for it in the app, even if you accepted every other external storage auth.

I had to add

using var buildCodes = new AndroidJavaClass("android.os.Build$VERSION_CODES");

//Check SDK version > 29
if (buildVersion.GetStatic<int>("SDK_INT") > buildCodes.GetStatic<int>("Q"))
{
    using var environment = new AndroidJavaClass("android.os.Environment");
    //сhecking if permission already exists
    if (!environment.CallStatic<bool>("isExternalStorageManager"))
    {
        using var settings = new AndroidJavaClass("android.provider.Settings");
        using var uri = new AndroidJavaClass("android.net.Uri");
        using var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        using var currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
        using var parsedUri = uri.CallStatic<AndroidJavaObject>("parse", $"package:{Application.identifier}");
        using var intent = new AndroidJavaObject("android.content.Intent",
            settings.GetStatic<string>("ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION"),
            parsedUri);
        currentActivity.Call("startActivity", intent);
    }
}

From here before calling the FileBrowser, and now I can see every file in the folder -_- I had rejected the "not enough permission" theory as I could see the png in the folder, but I guess Android auths are really f*ked up above Android 11...

Mind that it can throw a warning when publishing your app in the store with this permission in the manifest.

Anyway, thanks

@yasirkula
Copy link
Owner

Thank you for sharing your solution! I'll add a link to it from FAQ. I wish NativeFilePicker worked with Quest which wouldn't have this issue but unfortunately AFAIK it doesn't, so your solution is the only way to go at the moment.

@SashelI
Copy link
Author

SashelI commented Oct 18, 2023

Thanks. Yeah I've tried native file picker before this one, and quickly realized the Android 12 + Meta combo will be a nightmare to figure out x)

@yasirkula
Copy link
Owner

The known Quest issue is, file picker's result is allegedly not sent to the device until the app is minimized and then maximized. If that wasn't an issue, I think it would work wonderfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants