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

Scoped Storage on Android - new and remaining issues #17683

Open
hrydgard opened this issue Jul 10, 2023 · 6 comments
Open

Scoped Storage on Android - new and remaining issues #17683

hrydgard opened this issue Jul 10, 2023 · 6 comments
Labels
Platform-specific (Android) Scoped Storage Related to scoped storage on Android
Milestone

Comments

@hrydgard
Copy link
Owner

hrydgard commented Jul 10, 2023

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

  • Poco F4: Pedro made a report over e-mail.
  • Quest (though we've worked around that for now by targeting a lower Android version on these)
  • A few more (will collect as I find them again)

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: #16865

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

  • On startup, choose the "setup later" option which will locate the memstick in /Android/data/org.ppsspp.ppsspp/PSP
  • Add a shortcut to open /Android/data/org.ppsspp.ppsspp conveniently from the Games screen, and put games there through an USB cable (in latest Android, file managers are restricted from messing in that directory tree unfortunately)

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 hrydgard added this to the v1.16.0 milestone Jul 10, 2023
@hrydgard hrydgard added the Scoped Storage Related to scoped storage on Android label Jul 10, 2023
hrydgard added a commit that referenced this issue Jul 12, 2023
This handles some cases better that I don't really see how they can
happen, but who knows. Intended to help #17683
@hrydgard
Copy link
Owner Author

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 added a commit that referenced this issue Jul 15, 2023
To protect against disappearing activities or whatever is causing the
lost value, I could make it static, but instead I just pack the two
values together into the requestCode.

Will hopefully help the main issue from #17683
@hrydgard
Copy link
Owner Author

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.

@hrydgard hrydgard modified the milestones: v1.16.0, v1.17.0 Jul 16, 2023
@stzokev
Copy link

stzokev commented Aug 4, 2023

@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
Copy link
Owner Author

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

image

Reported on Discord by AloneGamer, on an A21s

@hrydgard
Copy link
Owner Author

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
Copy link
Owner Author

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

@hrydgard hrydgard modified the milestones: v1.17.0, Future-Prio Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform-specific (Android) Scoped Storage Related to scoped storage on Android
Projects
None yet
Development

No branches or pull requests

2 participants