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.15k stars 2.16k forks source link

Bad performance in Bleach Heat The Soul 7 (v1.01+DLC) [Android/Scoped storage relate?] #18887

Open Benda450 opened 7 months ago

Benda450 commented 7 months ago

Game or games this happens in

UCJS10110

What area of the game

FPS so horrible in Intro/Main menu. (maybe overall of game)

Screenshot_20240224-165820_PPSSPP

Speed seen in PPSSPP

stick around 10% (4/30)

GE frame capture and debug statistics

No response

Platform

Android

Mobile device model or graphics card (GPU)

Redmi Note 8 (Snapdragon 665, Adreno 610, Android 14)

PPSSPP version affected

v1.12.0-1.17.1 (v1.11.3-1027 or since scoped storage support)

Last working version

v1.11.3 (v1.11.3-991)

Graphics backend (3D API)

Vulkan

Any other notes or things you've tried

Compare.

v1.11.3-991 (before scoped storage support) Screenshot_20240225-170918_Permission controller Screenshot_20240224-181225_PPSSPP

v1.11.3-1027 (after scoped storage support) Screenshot_20240224-181825_PPSSPP Screenshot_20240224-183335_PPSSPP

No response

Checklist

anr2me commented 7 months ago

Please test the latest version from https://buildbot.orphis.net/ppsspp/ since 1.12 is rather old and may have bugs that already fixed on the latest version.

Benda450 commented 7 months ago

In first picture I tested with 1.17.1 stable and still happen in v1.17.1-20 too.

game is run fine on my android 9 device but on android 14 device is so slow.

anr2me commented 7 months ago

Right, it might be related to scoped storage.

Btw, are you using a single ISO/CSO file or an extracted files? If i'm not mistaken, working on many files on scoped storage is much slower than working on a single file, so if you're using extracted files... that might be the reason.

LunaMoo commented 7 months ago

Does the slowdown happens in-game or only in that screen? The game probably checks the external files there as the menu if I recall allows choosing between dlc and standard game(unavailable with patched iso).

Benda450 commented 7 months ago

Right, it might be related to scoped storage.

Btw, are you using a single ISO/CSO file or an extracted files? If i'm not mistaken, working on many files on scoped storage is much slower than working on a single file, so if you're using extracted files... that might be the reason.

I compressed all file game to .cso file via maxcso.

Benda450 commented 7 months ago

Does the slowdown happens in-game or only in that screen? The game probably checks the external files there as the menu if I recall allows choosing between dlc and standard game(unavailable with patched iso).

slowdown in-game too.

Screenshot_20240225-143004_PPSSPP

LunaMoo commented 7 months ago

Well I don't think it has anything to do with scoped storage, the game runs like shit even on gaming pc, however on windows it shows 6/30(100%) so it appears some logic is broken.

UCJS10110_00002

LunaMoo commented 7 months ago

Dunno what it was, but probably temporary regression, please test latest version from https://buildbot.orphis.net/ppsspp/index.php it works well again. UCJS10110_00003

Benda450 commented 7 months ago

Like I said before it still happen even in v1.17.1-20. 😅

but this issue not happen on my laptop or my another android 9.0 device (Huawei P10+), can run full speed without any problem.

Screenshot_20240225_165411_org ppsspp ppsspp

anr2me commented 7 months ago

Btw have you tried changing the I/O Timing method? (all of them)

Benda450 commented 7 months ago

I tried but not help at all.

LunaMoo commented 7 months ago

Well a strange coincidence the build I was using was affected by similar issue ;o.

I see it now, the game does spam sceIoDopen/sceIoDclose every frame.

LunaMoo commented 7 months ago

Could you try using this cwcheat on affected device?

_S UCJS-10110
_G Bleach Heat The Soul 7 v1.01
_C0 Remove Unnecessary IO
_L 0xE002E13A 0x00159C98
_L 0x20159C98 0x00000000
_L 0x20159CB0 0x00000000

It removes the spammy IO calls, just curious if that's going to help you, shouldn't affect the game otherwise.

Benda450 commented 7 months ago

_S UCJS-10110 _G Bleach Heat The Soul 7 v1.01 _C0 Remove Unnecessary IO _L 0xE002E13A 0x00159C98 _L 0x20159C98 0x00000000 _L 0x20159CB0 0x00000000

Wow, game is run full speed on A14 device with this cheat. thanks!

LunaMoo commented 7 months ago

That would confirm it's scoped storage issue.

For a proper solution maybe DLC folders should be optionally cached to RAM, there's at least one game where DLC is over 3gb that might be a problem on some devices, but it's probably not that common for game to check if folder exists every frame long after loading files from it as it doesn't really have much sense.

anr2me commented 7 months ago

The OS itself should have disk/storage cache isn't? to cache files or sectors that have been read. If the game only checks whether a file existed or not, without reading the data, it shouldn't cost too much memory in the cache.

Edit: according to this , we should probaby cache it ourself (as LunaMoo suggested), probably only need to cache when dealing with external storage. image

Edit2: based on the mentioned issuetracker , using /storage/emulated/0/ should've better performance than /storage/XXXX-XXXX/

FUSE performance loss cannot be mitigated for external private directories on SD card (External Removable) according to the current Android 11 policy. This is not the Samsung change but common in all the AOSP devices. Because everything under the SD card (External Removable) works on FUSE. It is possible to mitigate the performance loss on emulated private directories on the internal storage only.

· Emulated private directories: /storage/emulated/0/Android/Data -> (bypass FUSE)

· External private directories on SD card (External Removable): /storage/XXXX-XXXX/Android/Data -> (FUSE)

hrydgard commented 7 months ago

Urgh. If we cache file accesses, when do we invalidate the cache?

Also, what check specifically is it that needs to be cached? just check for file existence?

LunaMoo commented 7 months ago

This case scenario(and it could as well be the only game with such problem), the game just spams:

26:57:565 Main         D[SCEIO]: HLE\sceIo.cpp:2417 sceIoDopen("ms0:PSP/GAME/UCJS10110")
26:57:565 Main         D[SCEIO]: HLE\sceIo.cpp:2558 sceIoDclose(275)

And does so every frame, if I understand it correctly it only tries to open the folder itself possibly to panic, if it stops being able to do so which is dumb as it can also panic when it actually tries to load specific DLC file and it doesn't exist. Limited to android or even game specific compat, it would be safe to just invalidate on savestate load and game exit, maybe also on memstick change through PPSSPP options. It's not like someone would accidently unplug emulated memory stick while playing a game on modern android device where most of them don't have sd card support at all and those which do have it together with sim card on a tray that requires needle to access.

hrydgard commented 7 months ago

That would explain why it's slow, yeah. Unfortunate.

I suppose a compat setting is motivated here, to avoid any risk of caching problems in other games.