hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
10.94k stars 2.13k forks source link

PPSSPP does not ask for file permissions unless Browse is used #18922

Open GlazedBelmont opened 5 months ago

GlazedBelmont commented 5 months ago

Game or games this happens in

All

What area of the game / PPSSPP

I've been able to replicate a blackscreen in three frontends (ES-DE, Yuno, Beacon Launcher) due to PPSSPP not having permissions to access the files. It turns out I need to use the Browse option to select a game folder directly so PPSSPP prompts for permissions.

I've always just pressed the SD card button and moved to my PSP folder and started games from there, but if users are using frontends, they may not be doing any of that and end up with the same issue.

What should happen

The game should open without any error messages or black screens due to PPSSPP having permissions to the file, would need to be asked during setup directly.

Logs

03-09 10:12:48.645  4703  4703 I PPSSPP  : EARLY: JNI_OnLoad
03-09 10:12:48.647  4703  4703 I PpssppActivity: Found Shortcut Parameter in data: content://com.android.externalstorage.documents/tree/30FC-BE41%3AGames%2Fpsp/document/30FC-BE41%3AGames%2Fpsp%2FJeanne%20d'Arc.chd
03-09 10:12:48.649  4703  4703 I PPSSPP  : EARLY: NativeApp.setDisplayParameters(1920 x 1025, dpi=369, refresh=60.00)
03-09 10:12:48.649  4703  4703 I PPSSPP  : EARLY: RecalcDPI: display_xres=1920 display_yres=1025 pixel_xres=0 pixel_yres=0
03-09 10:12:48.649  4703  4703 I PPSSPP  : EARLY: RecalcDPI: g_dpi=369.000000 g_dpi_scale_x=0.650406 g_dpi_scale_y=0.650406 dp_xres=1248 dp_yres=666
03-09 10:12:48.650  4703  4703 D PPSSPPNativeActivity: Landscape: true
03-09 10:12:48.652  4703  4703 I PPSSPPNativeActivity: Ext storage: mounted /storage/emulated/0
03-09 10:12:48.652  4703  4703 I PPSSPPNativeActivity: Ext files dir: /storage/emulated/0/Android/data/org.ppsspp.ppsspp/files
03-09 10:12:48.652  4703  4703 I PPSSPPNativeActivity: getSdCardPaths: Attempting fallback
03-09 10:12:48.653  4703  4703 I PPSSPPNativeActivity: SD card: /storage/30FC-BE41
03-09 10:12:48.653  4703  4703 I PPSSPPNativeActivity: End of storage paths
03-09 10:12:48.653  4703  4703 I PPSSPP  : NativeApp.init() -- begin
03-09 10:12:48.656  4703  4703 I PPSSPP  : NativeApp.init(): device name: 'AYN:Odin2'
03-09 10:12:48.656  4703  4703 I PPSSPP  : Additional storage: /storage/30FC-BE41
03-09 10:12:48.656  4703  4703 I PPSSPP  : NativeApp.init(): External storage path: /storage/emulated/0
03-09 10:12:48.656  4703  4703 I PPSSPP  : NativeApp.init(): Launch shortcut parameter: "content://com.android.externalstorage.documents/tree/30FC-BE41%3AGames%2Fpsp/document/30FC-BE41%3AGames%2Fpsp%2FJeanne%20d'Arc.chd"
03-09 10:12:48.656  4703  4703 I PPSSPP  : EARLY: ThreadManager::Init(compute threads: 8, all: 16)
03-09 10:12:48.658  4703  4703 I PPSSPP  : EARLY: Reading '/data/user/0/org.ppsspp.ppsspp/files/memstick_dir.txt' to find memstick dir.
03-09 10:12:48.661  4703  4703 I PPSSPP  : EARLY: Memstick Directory from memstick_dir.txt: 'content://com.android.externalstorage.documents/tree/30FC-BE41%3Appsspp/document/30FC-BE41%3Appsspp'
03-09 10:12:48.675  4703  4703 E PpssppActivity: openContentUri exception: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/30FC-BE41%3AGames%2Fpsp/document/30FC-BE41%3AGames%2Fpsp%2FJeanne%20d'Arc.chd from pid=4703, uid=10150 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
03-09 10:12:48.675  4703  4703 E PpssppActivity: contentUriGetFileInfo exception: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/30FC-BE41%3AGames%2Fpsp/document/30FC-BE41%3AGames%2Fpsp%2FJeanne%20d'Arc.chd from pid=4703, uid=10150 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
03-09 10:12:48.749  4703  4703 I PPSSPPNativeActivity: Setting requested rotation: 5 ('5') (Initialize)
03-09 10:12:48.750  4703  4703 I PPSSPPNativeActivity: OpenGL ES 3.0 detected.
03-09 10:12:48.751  4703  4703 I PPSSPPNativeActivity: InfraredHelper exception: java.lang.Exception: No Ir Emitter
03-09 10:12:48.754  4703  4703 I PPSSPPNativeActivity: Setting requested rotation: 5 ('5') (onCreate)
03-09 10:12:48.756  4703  4703 E PPSSPPNativeActivity: updateSystemUiVisibility: decor view not yet created, ignoring for now
03-09 10:12:48.757  4703  4703 I NativeSurfaceView: NativeSurfaceView
03-09 10:12:48.760  4703  4703 I NativeSurfaceView: MOGA initialized
03-09 10:12:48.760  4703  4703 I PPSSPPNativeActivity: setcontentview before
03-09 10:12:48.761  4703  4703 I PPSSPPNativeActivity: setcontentview after
03-09 10:12:48.761  4703  4703 W PPSSPPNativeActivity: startRenderLoopThread - not starting thread, needs surface
03-09 10:12:48.762  4703  4703 I PPSSPPNativeActivity: Setting requested rotation: 5 ('5') (onResume)
03-09 10:12:48.762  4703  4703 I PPSSPPNativeActivity: onResume
03-09 10:12:48.772  4703  4703 W PPSSPPNativeActivity: startRenderLoopThread - not starting thread, needs surface
03-09 10:12:48.777  4703  4703 I PPSSPPNativeActivity: onAttachedToWindow
03-09 10:12:48.796  4703  4703 W PPSSPPNativeActivity: startRenderLoopThread: Starting thread
03-09 10:12:48.796  4703  4703 I PPSSPPNativeActivity: Setting desired framerate to 60.0 Hz method=1
03-09 10:12:48.820  4703  4703 I InputDeviceState: Registering input device with 8 axes: Odin Controller
03-09 10:12:48.820  4703  4703 I InputDeviceState: Vendor ID:8224 productId: 273 sources: 01000511
03-09 10:12:48.820  4703  4703 I PPSSPPNativeActivity: Input player registered: desc = 8e1073ea5832500672194344d81498833991c43c
03-09 10:12:49.194  4703  4736 E PpssppActivity: openContentUri exception: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/30FC-BE41%3AGames%2Fpsp/document/30FC-BE41%3AGames%2Fpsp%2FJeanne%20d'Arc.chd from pid=4703, uid=10150 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
03-09 10:12:49.194  4703  4736 E PPSSPP  : [FILESYS] LocalFileLoader failed to open content URI: 'content://com.android.externalstorage.documents/tree/30FC-BE41%3AGames%2Fpsp/document/30FC-BE41%3AGames%2Fpsp%2FJeanne%20d'Arc.chd'
03-09 10:12:49.195  4703  4736 E PpssppActivity: contentUriGetFileInfo exception: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/30FC-BE41%3AGames%2Fpsp/document/30FC-BE41%3AGames%2Fpsp%2FJeanne%20d'Arc.chd from pid=4703, uid=10150 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
03-09 10:13:22.085  4703  4703 I PPSSPPNativeActivity: onPause
03-09 10:13:22.092  4703  4703 I PPSSPPNativeActivity: Joining render thread...
03-09 10:13:22.092  4703  4703 I PPSSPPNativeActivity: requestExitVulkanRenderLoop
03-09 10:13:22.106  4703  4703 I PPSSPPNativeActivity: Joined render thread
03-09 10:13:22.106  4703  4703 I PPSSPPNativeActivity: onPause completed
03-09 10:13:22.123  4703  4703 I PPSSPPNativeActivity: requestExitVulkanRenderLoop
03-09 10:13:22.123  4703  4703 E PPSSPP  : [SYSTEM] Render loop already exited
03-09 10:13:24.540  4703  4703 I PPSSPPNativeActivity: Setting requested rotation: 5 ('5') (onResume)
03-09 10:13:24.548  4703  4703 I PPSSPPNativeActivity: onResume
03-09 10:13:24.645  4703  4703 W PPSSPPNativeActivity: startRenderLoopThread - not starting thread, needs surface
03-09 10:13:24.649  4703  4703 W PPSSPPNativeActivity: startRenderLoopThread: Starting thread
03-09 10:13:24.649  4703  4703 I PPSSPPNativeActivity: Setting desired framerate to 60.0 Hz method=1
03-09 10:13:24.659  4703  4736 E PpssppActivity: openContentUri exception: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/30FC-BE41%3AGames%2Fpsp/document/30FC-BE41%3AGames%2Fpsp%2FJeanne%20d'Arc.chd from pid=4703, uid=10150 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
03-09 10:13:24.659  4703  4736 E PPSSPP  : [FILESYS] LocalFileLoader failed to open content URI: 'content://com.android.externalstorage.documents/tree/30FC-BE41%3AGames%2Fpsp/document/30FC-BE41%3AGames%2Fpsp%2FJeanne%20d'Arc.chd'
03-09 10:13:24.660  4703  4736 E PpssppActivity: contentUriGetFileInfo exception: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/30FC-BE41%3AGames%2Fpsp/document/30FC-BE41%3AGames%2Fpsp%2FJeanne%20d'Arc.chd from pid=4703, uid=10150 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
03-09 10:13:26.373  4703  4703 I PPSSPPNativeActivity: onPause
03-09 10:13:26.384  4703  4703 I PPSSPPNativeActivity: Joining render thread...
03-09 10:13:26.384  4703  4703 I PPSSPPNativeActivity: requestExitVulkanRenderLoop
03-09 10:13:26.405  4703  4703 I PPSSPPNativeActivity: Joined render thread
03-09 10:13:26.405  4703  4703 I PPSSPPNativeActivity: onPause completed
03-09 10:13:26.407  4703  4703 I PPSSPPNativeActivity: requestExitVulkanRenderLoop
03-09 10:13:26.407  4703  4703 E PPSSPP  : [SYSTEM] Render loop already exited

Platform

Android

Mobile device model or graphics card (GPU)

Ayn Odin 2

PPSSPP version affected

v1.17.1g0159102a1

Last working version

No response

Graphics backend (3D API)

OpenGL / GLES

Checklist

https://discord.com/channels/293316141479362560/480103153803460614/1216033450457567326 for more info/context

sum2012 commented 5 months ago

Maybe need to make another manifest for file permissions before install

hrydgard commented 5 months ago

The only way PPSSPP can get permissions to a folder on Android 11+ is to ask the user for it. I don't see what we can do here.

GlazedBelmont commented 5 months ago

I'd say ask the user for a games folder directly during setup and not make it an optional thing @hrydgard

anr2me commented 5 months ago

PPSSPP already did that isn't? When PPSSPP launched for the first time it will ask for the memstick/PSP folder and the games folder, right?

Edit: Oops sorry, it didn't ask the games folder the first time it ran. So, yeah we should probably ask it along with the PSP folder the first time it ran.

hrydgard commented 5 months ago

I suppose that could make sense to ask for, but this is only really needed for this use case, and even so, I think it's possible for a frontend to pass content URIs from frontends to PPSSPP that will work without doing this, something like this maybe: https://stackoverflow.com/questions/71100066/how-to-open-a-file-in-another-app-via-an-intent-using-an-uri

Undeniably, the "scoped storage" changes has made things a lot harder for frontends :/

anr2me commented 5 months ago

I see, so it's like opening an ISO file from a File Manager using "Open with" and select PPSSPP, which does works without granting permission through "Browse" on PPSSPP first.

leonstyhre commented 5 months ago

Hi! ES-DE can use the FileProvider API to pass its access permission to a file when launching an emulator, but there is currently a bug in PPSSPP that prevents this from working with .chd files specifically, as reported here: https://github.com/hrydgard/ppsspp/issues/18919

And secondly I don't think the FileProvider API can pass access to more than a single file, so I don't think this would work if the game consists of more than a single file? Not sure if that will actually happen though, could PSP games consist of more than a single file? For example I don't think you support .bin/.cue files which is normally such a use case?

Thanks! :)

GlazedBelmont commented 5 months ago

There's apparently only like 9 games that were Japan-only and were on multiple discs although you could just save, exit the game and open disc 2 with ES-DE

leonstyhre commented 5 months ago

I see, and there are no multi-file formats supported by PPSSPP, i.e. a UMD/disc can only ever consist of a single file?

hrydgard commented 5 months ago

@leonstyhre Oh right, that CHD bug. I'll try to get that fixed soon.