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
11.04k stars 2.15k forks source link

Scoped Storage on Android - new and remaining issues #17683

Open hrydgard opened 1 year ago

hrydgard commented 1 year ago

Gotten a bunch of reports recently that the "browse folder" action isn't completing properly, on a bunch of devices.

Additionally, on Android TV this is fairly common because for whatever reason, the device makers don't bother including this dialog, which basically ruins things for us: https://github.com/hrydgard/ppsspp/issues/16865

It would be possible to get things working without the folder browser:

So we should probably implement that as a fallback.

Also, getting user reports on random failures when loading from the Downloads folder on Samsung A22, apparently sometimes it works (1.15.4, it's possible it's since been fixed):

image

We should at least improve the error message..

hrydgard commented 1 year ago

I added some more logging and debug messages, and this shows up on the user's problematic device (Poco 4):

Screenshot_2023-07-15-11-32-40-523_org ppsspp ppsspp

Note that the "result code" -1 actually means success

That's just bizarre? It's like parseInt failed silently and didn't write the result to lastRequestId for no good reason, when parsing the request number from the params string: https://github.com/hrydgard/ppsspp/blob/master/android/src/org/ppsspp/ppsspp/NativeActivity.java#L1389C10-L1389C10

We set it before spawning the dialog that in turn will end up calling onActivityResult.

So it's like the value is either not written - or reset somehow..

hrydgard commented 1 year ago

The Poco F4 issue is solved - I stored temporary data in the Android activity for the dialogs, and that didn't work since somehow the activity was destroyed in the background. Fixed that, but still don't know why the user kept losing the activity, oh well.

stzokev commented 1 year ago

@hrydgard SAF is not supported on Android TV by design (on purpose, not a bug). Therefore not only file picker is missing, but file.uri, required by most emulators, is not supported. The workaround would be to have a fallback to manually enter the uri as it was prior to v.1.11. For example I am currently using PPSSPP on CWGTV (Chromecast with Google TV) which is Android 12 and I am using v.1.10.3 successfully. All I do is enter the path to the SD card manually and done! Similar workaround is used for Retroarch. So it shouldn't be too much work for you to support this either by graceful fallback on these systems, or if you ask me even better to have 2 buttons - 1) Browse 2)Enter uri.

Regards and keep up the excellent work.

hrydgard commented 8 months ago

If the folder picker is missing on Android, here's the exception, for reference:

image

Reported on Discord by AloneGamer, on an A21s

hrydgard commented 8 months ago

Made a slightly disconcerting discovery that could explain some reported data loss. Removing a directory on scoped storage works whether there are files in the directory or not. My memstick directory moving algorithm relied on being unable to delete a directory with files in it to make sure we don't delete data without having moved it. Will fix that (and also optimize removing of directory trees to a single call, due to this ability, which will speed up app uninstalls probably...)

hrydgard commented 8 months ago

18744 will help prevent data loss when moving the memstick folder. moving any further work on this to future versions.