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

Android 11 lag/perf problems - probably related to scoped storage #13847

Open
NeverSm1le opened this issue Jan 1, 2021 · 86 comments
Open

Android 11 lag/perf problems - probably related to scoped storage #13847

NeverSm1le opened this issue Jan 1, 2021 · 86 comments
Labels
I/O Affected by I/O timing settings, or other kind of I/O issue. Performance Unexpected slow performance issues Platform-specific (Android) Scoped Storage Related to scoped storage on Android
Milestone

Comments

@NeverSm1le
Copy link

What happens?

I just upgrade to Android 11. Each game encounter heavy lag when trying to load in-game saves.

What should happen?

There should be no lag when trying to load in-game saves like in Android 10.

What hardware, operating system, and PPSSPP version? On desktop, GPU matters for graphical issues.

My phone is a Redmi K30 running android 11, SD730G, 6GB ram. PPSSPP version 1.10.3.

@NeverSm1le NeverSm1le changed the title Some Android 11 issues - probably related to scoped storage Android 11 issue - probably related to scoped storage Jan 1, 2021
@Panderner
Copy link
Contributor

Maybe related to #11997 and #13827?

@nassau-tk
Copy link
Contributor

Yes, I feel too that slow response.
I'm saving save data on internal ROM.
Not SDcard.

My phone is Galaxy S20.
SD 865 / RAM 12GB

@NeverSm1le
Copy link
Author

Maybe related to #11997 and #13827?

I don't think so. All games and saves are stored on the internal storage. I suspect about the scoped storage because it's the only thing changed when go from 10 to 11.

@NeverSm1le
Copy link
Author

Here is the screen record about the lag. Sorry for the low quality. The game ran on the default settings of PPSSPP.
https://user-images.githubusercontent.com/45039938/103436392-712e8900-4c4d-11eb-8764-d65488052a9b.mp4

@hrydgard
Copy link
Owner

hrydgard commented Jan 1, 2021

Wow, really weird that it's lagging while you are choosing save slot! Does Vulkan/OpenGL make a difference? This might be rendering related..

@hrydgard hrydgard added this to the v1.12.0 milestone Jan 1, 2021
@NeverSm1le
Copy link
Author

Wow, really weird that it's lagging while you are choosing save slot! Does Vulkan/OpenGL make a difference? This might be rendering related..

I also thought of this and tried switch to OpenGL but it still lag.

@nassau-tk
Copy link
Contributor

I tried to get a logcat. (Is this OK?)
https://gist.github.com/nassau-tk/5a7414e1edbcc767027472b0dec697ab

Tested on BLEACH SC1 Save Data Loading.
My case is not goes down FPS counter. (it means just seem.)
It is just petit-freez.

@nassau-tk
Copy link
Contributor

I tried video recording on Windows10 & Android 11(Galaxy S20 5G).
Be careful to listening "Title call / sound" of (BLEACH SOUL Carnival).
Normally, If push the "Load Game" at playing sounds&voice then any sounds&voice will not stop.

[Windows10-Non lagging.]
https://user-images.githubusercontent.com/48179091/104463607-536e0600-55f5-11eb-96e1-777cea19348a.mp4

[Android11-Petit Freeze.(Sound will stop.)]
https://user-images.githubusercontent.com/48179091/104464041-d5f6c580-55f5-11eb-9885-0113d74b804c.mp4

@nassau-tk
Copy link
Contributor

My case & case of @NeverSm1le seems different working.
But, it's same cause isn't it?

@nassau-tk
Copy link
Contributor

nassau-tk commented Jan 13, 2021

Everybody love it "Janne d'Arc".:grin:
Freeze time is shorter than BLEACH_SC.
And, My case is not goes down FPS in screen of save data list.

[Android11-Petit Freeze.]
https://user-images.githubusercontent.com/48179091/104465617-90d39300-55f7-11eb-93e7-57d9dc341ac1.mp4

@unknownbrackets
Copy link
Collaborator

If you change IO timing method to "Host" does the lag go away?

This isn't a fix and makes timing different depending on the system, which might make new bugs other people can't reproduce. But it would help confirm the cause.

-[Unknown]

@nassau-tk
Copy link
Contributor

@unknownbrackets

It's not change to response of loading in my case.
"Simulate UMD delays" too.

@nassau-tk
Copy link
Contributor

Android11 is very unpleasant by this issue. 😩

@hrydgard
Copy link
Owner

hrydgard commented Feb 1, 2021

Really very odd this.. Maybe direct access to storage already is simulated by some horrible Java layer, and lots of very small freads are slow (if that's what's happening, no idea...)

Think I'll have to investigate this

@hrydgard hrydgard added I/O Affected by I/O timing settings, or other kind of I/O issue. Platform-specific (Android) labels Feb 1, 2021
@nassau-tk
Copy link
Contributor

I felt about this issue, Android system is perfect freezing by this issue.

"Why I think so?"
I took a recording the working movie. (BLEACH SC Loading the save data movie.)
And, I tried to editing the movie, but it's can't do that.
Probably, The movie file was not saving correctly.
So, I think the screen recording app is freeze too.
And, Android system too?

I don't know about this report has important or not.
Android11 is so bad condition on link to storage.
Maybe, this problem will relate with Scoped Storage isn't it?
I hope coming the good solution.

When I can help something, please say. 😁
I will check by Galaxy S20 5G / Android 11.

@GamerzHell9137
Copy link

On Snapdragon 860 and Android11 and im experiencing similar issues. On some games its more heavier and on others its smaller.
Here's how Persona 3 Portable acts with no save but its actually seen everytime a new sound is being played(?) and when new scenes happen https://cdn.discordapp.com/attachments/480103153803460614/833419315457556561/Screenrecorder-2021-04-18-21-00-22-392.mp4

@hrydgard
Copy link
Owner

hrydgard commented Apr 18, 2021

@GamerzHell9137 Looks like you are using a high res texture pack - do you get the same if you turn off texture replacement?

@GamerzHell9137
Copy link

@GamerzHell9137 Looks like you are using a high res texture pack - do you get the same if you turn off texture replacement?

Happens on games that have no texture pack or anything. Project Diva Extend does the same when accessing the loading screen but in gameplay its fine.
I've realized the issue is less when Force real clock sync is off too but its still happening and every game has different amount of the stutter.

@unknownbrackets
Copy link
Collaborator

I've realized the issue is less when Force real clock sync is off too but its still happening and every game has different amount of the stutter.

That makes sense, because if IO operations are taking a weirdly long amount of time, "force real clock sync" only gives 2ms of buffer to recover from that. So, if IO operations are somehow taking 4ms, with that enabled it will much more frequently impact overall speed.

We would be writing to multiple files when creating or loading savedata, but I think they're mostly complete reads and writes?

-[Unknown]

@hrydgard
Copy link
Owner

hrydgard commented Aug 6, 2021

I've added full scoped storage support now, and who knows, it might even perform faster if you move the PSP directory to somewhere using it, now that we've implemented the fast way to do directory read. Previously this probably behind the scenes went through a slow wrapper on Android 11....

I don't think there's much more we can do here :(

Maybe there are some file operations that can be avoided by relying more on error returns, like for avoiding separately checking files for existence. But it'll be marginal.

@hrydgard hrydgard closed this as completed Aug 6, 2021
@nassau-tk
Copy link
Contributor

How can l get to give permission???
I tap center...but it's no happen.

Screenshot_20210807-082159_PPSSPP

@nassau-tk
Copy link
Contributor

@hrydgard
Like this...

20210807_110516.mp4

@Saramagrean
Copy link
Contributor

could try uninstalling and then reinstalling, which might allow you to use the new way. :)

@nassau-tk
Copy link
Contributor

@Saramagrean

Oh...
Ok I'll try later...

@ghost
Copy link

ghost commented Aug 7, 2021

could try uninstalling and then reinstalling, which might allow you to use the new way. :)

I recently updated my Redmi Note 9 to android 11 and installing ppsspp latest build apk
But I can't locate my sdcard 😅
Screenshot_2021-08-07-13-47-24-253_org ppsspp ppsspp
Screenshot_2021-08-07-13-48-41-748_org ppsspp ppsspp

@ghost
Copy link

ghost commented Sep 11, 2021

Loading time it takes to so slow. if there is a large amount of savedata or shaders in PSP folder.
https://youtu.be/Vekjz6B08jw

Maybe it's depends on the sdcard class? read/write speed 🤔

@hrydgard
Copy link
Owner

There are some really bad cases of this - games like Wipeout Pure and Pulse scan through all of PSP/GAME on startup, issuing a sceIoDopen on each directory recursively. If you have a lot of stuff there, this is now unbearably slow and there's no way to parallelize.

Considering simply hiding directories the game shouldn't care about from itself... I guess it's looking for level packs or updates?

hrydgard added a commit that referenced this issue Sep 11, 2021
Stops some games from spending lots of time iterating over files they
should not care about. Helps the performance issues in #13847 quite a bit.
@hrydgard
Copy link
Owner

Argh, I think I finally realized why some get such heavy slowdowns in save dialog. It's our virtual free disk space simulation in MemoryStick_FreeSpace, which, yes, you guessed it - loops through all directories in SAVEDATA, summing up the sizes, which is now dog slow.

@hrydgard
Copy link
Owner

OK, I got some optimizations in through #14824, which should help the issue @Saramagrean had there, plus some game startup times.

Still have many things to improve, including the previously mentioned MemoryStick_FreeSpace.

@Saramagrean
Copy link
Contributor

Latest git build (1313+), Improve speed loading time a lot, thanks!

@hrydgard
Copy link
Owner

The next couple of builds are gonna improve it even more I think, though not sure by how much.

@hrydgard hrydgard changed the title Android 11 issue - probably related to scoped storage Android 11 lag/perf problems - probably related to scoped storage Sep 11, 2021
@hrydgard hrydgard added the Performance Unexpected slow performance issues label Sep 11, 2021
@hrydgard
Copy link
Owner

Note to self: Outrun is still very laggy when loading/saving.

@hrydgard
Copy link
Owner

That's another couple of performance fixes in. I'm not saying that things are good, but they should at least be far better now.

@hrydgard
Copy link
Owner

I'm gonna move remaining work to future versions. Maybe I'll get another fix in or two still, but need to move on to the other remaining issues blocking the release.

@SMNFXCN
Copy link

SMNFXCN commented Feb 4, 2022

I'm not sure if this is related to my issue, but it's the only thing I can consider.
I'm using a device with a SD845 and 8GB ram, and I'm loading both the game rom and the HD texture pack for the game on internal storage. The game I'm using is Persona 3 Portable.
Back on the phone's original rom, it was on android 9. back when scoped storage wasn't a thing. It ran perfectly, but i've recently been running custom roms on the thing to try and get it up to date. But trying to play this game on android 12 (same on 11), i seem to get lag.
I've done all sorts of optimization by toggling different settings and trying different renderers, etc. It works fine when I turn off the packs,
i don't think it's an issue regarding the hardware. The way the fonts are stored in the hd pack are in single images, each glyph is a single image. When i remove the hd font, the game stops lagging while trying to render text. When i put them back in, the game lags.
This is likely not an issue with specs, because it has ran better in the past.

@unknownbrackets
Copy link
Collaborator

unknownbrackets commented Feb 5, 2022

No one is saying it's related to specs. Unfortunately, it's a software problem in the operating system (Android.)

Imagine that you lived in an area where you drove across a bridge on a daily basis.

One day, the people who control the bridge decide to increase security. Now, to cross the bridge you must:

  • First present 8 forms of paperwork that must be inspected at the starting end of the bridge.
  • Drive to the end of the bridge and obtain a one-time permit to cross the bridge.
  • Return to the start of the bridge and have the one-time permit cross checked, stamped, and approved.
  • Drive across the bridge a third time to the end of the bridge, and present the approved permit and 8 forms of paperwork for thorough inspection.
  • Finally exit the bridge.

Now, even if you had a high-performance sports car, you'd find that these extra steps and back and forth would slow you down. This is what has happened with scoped storage - it is inarguably much slower, but Android (the people who control the bridge) have decided this increased security is necessary to protect the data on your storage.

Try the latest git, though. It's not faster, but #15025 loads the replacement data in the background. This changes the lag/stalls to just show non-HD textures while the HD texture is still loading. The HD texture is used as soon as it loads.

-[Unknown]

@unknownbrackets
Copy link
Collaborator

How does this look now with a recent git build and recent Android version? I know texture dumping has also been improved.

-[Unknown]

@hrydgard
Copy link
Owner

It's definitely better now but I think there's more tweaks that can be done. Let's keep this assigned to Future-Prio, I'll consider it again for more work for the next version.

@jcchikikomori
Copy link
Contributor

jcchikikomori commented May 29, 2022

@unknownbrackets @hrydgard
I've been thinking about downloading the texture pack either thru Git or by a ZIP file then install inside the app. And it will depends on a ID of the game. What do you think?

Edit: I know this is a workaround

@unknownbrackets
Copy link
Collaborator

Well, I think it could make sense to support a zip file (ideally uncompressed) or tar or something. It should be faster to find the files.

I think that should be optional though, because when creating a texture pack it's handy to be able to iterate quickly and directly interact with the files, as well as add files while PPSSPP is running.

That doesn't really help saves, although we could entertain an option to use a "memory stick image" file. It just means creating a whole file explorer and etc. You know, the things an operating system normally exposes.

-[Unknown]

@ghost
Copy link

ghost commented Mar 14, 2023

How about this now?
Does ppsspp already do like this https://github.com/citra-emu/citra/pull/6344? Just asking.

@hrydgard
Copy link
Owner

Well, we do what we can to minimize i/o. Our shader cache has always been efficient so that citra change doesn't really apply.

@unknownbrackets
Copy link
Collaborator

There were also some improvements with savedata, although more are possible. I think most of the IO is already on a thread, but we could be less deterministic about timing and probably reduce stutter.

-[Unknown]

@hrydgard hrydgard added the Scoped Storage Related to scoped storage on Android label May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I/O Affected by I/O timing settings, or other kind of I/O issue. Performance Unexpected slow performance issues Platform-specific (Android) Scoped Storage Related to scoped storage on Android
Projects
None yet
Development

No branches or pull requests

9 participants