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

Better display framerate support on Android #14074

Closed
hrydgard opened this issue Feb 7, 2021 · 6 comments
Closed

Better display framerate support on Android #14074

hrydgard opened this issue Feb 7, 2021 · 6 comments
Labels
User Interface PPSSPP's own user interface / UX

Comments

@hrydgard
Copy link
Owner

hrydgard commented Feb 7, 2021

High-end Android 11 devices such as the Galaxy S21 family support 120hz displays. PPSSPP works fine with this, but the framerate sometimes feels slightly uneven - PSP games never run at more than 60Hz, and I suspect we sometimes get cadences like 1,2,1,3,2,2,2,2,1,3,2,2,2,2 frames (and similar).

Android 11 (SDK 30) adds a new API, Surface.setFrameRate that lets the app set a preferred framerate, and the system will try to accomodate.

We should have an option to switch down to 60Hz, for a more even framerate but probably slightly worse latency than you can get with 120Hz.

Unfortunately, using this API means that we have to target SDK 30, which starts enforcing Scoped Storage Hell. So we're essentially blocked on that. We will have to do that after August anyway though...

There's also some interesting stuff here:
https://developer.android.com/games/sdk/frame-pacing

PPSSPP is certainly guilty of "buffer stuffing", and using the choreographer API we might be able to effectively reduce display latency a little.

@hrydgard hrydgard added the User Interface PPSSPP's own user interface / UX label Feb 7, 2021
@hrydgard hrydgard added this to the v1.12.0 milestone Feb 7, 2021
@hrydgard
Copy link
Owner Author

hrydgard commented Feb 7, 2021

Apparently there's also an older API that could be useful, which according to https://android-developers.googleblog.com/2020/04/high-refresh-rate-rendering-on-android.html is deprecated by setFrameRate:

On Older Android versions (before Android 11) where the setFrameRate API doesn’t exist, applications can still influence the refresh rate by directly setting WindowManager.LayoutParams.preferredDisplayModeId to one of the available modes from Display.getSupportedModes"

@hrydgard hrydgard changed the title Should support choosing framerate on Android Better display framerate support on Android Feb 7, 2021
@hrydgard
Copy link
Owner Author

hrydgard commented Aug 6, 2021

Note to self: Now that the scoped storage PR is merged and we target SDK 30, this is unblocked.

@unknownbrackets
Copy link
Collaborator

I wonder if it'd work out to simply call setFrameRate(59.94, FRAME_RATE_COMPATIBILITY_FIXED_SOURCE). Feels like we'd want to avoid sending detected frame rates if possible, since those are already delayed heuristics.

-[Unknown]

@hrydgard hrydgard modified the milestones: v1.12.0, Future-Prio Aug 29, 2021
@ghost
Copy link

ghost commented Jan 23, 2023

This is kinda related to this #15081?

@unknownbrackets
Copy link
Collaborator

In a way, but it'd be kinda terrible to simply do that. If the device is 90Hz and you just "sync to host framerate" blindly, then that means in other words you're stuck at 150% speed. You'd then have to enable alternate speed at 75% to get "normal" speed but it probably would have uneven frames still.

Force sync to host frame rate is basically the strategy PAL SNES games used when they were written for NTSC regions and lazily release for PAL. In that case, the games just ran 16% slower on 50Hz displays.

-[Unknown]

@hrydgard
Copy link
Owner Author

hrydgard commented Dec 13, 2023

I've tried this in #18529 now and it does not do anything meaningful for us on 120hz devices. However it prevents 90hz devices from going down to 45 when they want to save power, as reported in #18480 . Closing.

@hrydgard hrydgard removed this from the v1.17.0 milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User Interface PPSSPP's own user interface / UX
Projects
None yet
Development

No branches or pull requests

2 participants