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

Micro Stuttering/Frame Pacing issue #9736

Open
BParks21 opened this issue May 29, 2017 · 172 comments
Open

Micro Stuttering/Frame Pacing issue #9736

BParks21 opened this issue May 29, 2017 · 172 comments
Milestone

Comments

@BParks21
Copy link

BParks21 commented May 29, 2017

NOTE: If you are experiencing this issue, it may have multiple causes. See this comment:
#9736 (comment)


Using any API there is in every game a micro stutter or frame pacing issue that occurs randomly. This may be exclusive to windows. I've tested windows 7-10 and many different systems with the same results. It is more prevalent using a monitor at 60hz. The issue is almost gone using a 120hz display. Currently that is the only way to resolve the issue in all my testing. The easiest way to test this is to play a game with complete 360 camera control stand in place and slowly spin the camera around. You will see random stutters or inconsistent frame pacing. This occurs with games running at full speed at all times, vsync on, and frame skipping off. I believe ppsspp is suffering from the same issue the PCSX2 team is trying to resolve here.
PCSX2/pcsx2#1437

It would be worth looking into. This is my biggest issue with ppsspp and is very noticeable and unpleasant imo. I've been trying to find a solution to this for years and it is driving me mad. I think the pcsx2 team has pinned it down though. Thanks for your time i really hope you guys look into this and hope it is resolved. I love ppsspp except for this :)

System Specs:
Operating System: Windows 10 Pro 64-bit
MOBO: Asus Maximus IX Code
Processor/CPU: Intel(R) Core(TM) i7-7700k @5ghz
Video Card/GPU: MSI GTX 980
Memory/RAM: 32GB DDR4 @3000MHZ

@unknownbrackets
Copy link
Collaborator

Just to note a few things that could be slightly related:

  1. We time at 59.94 FPS (so that games run the same speed as on the PSP), which can cause a slight variance at 60 Hz. I would expect it to be much less noticeable at 120 Hz.

  2. Windows (not sure if this may have changed in 10, though) is not capable of delaying a thread more accurately than 1ms (5.99% of a frame.) When video drivers are multithreaded, etc. it can be hard to avoid slight timing inaccuracy because of this.

I haven't carefully studied the pcsx2 issue, but it sounds like the assumption is that this is related to the DWM. Do you have access to Windows 7 or lower (i.e. dual boot), or know someone who is able to detect this issue accurately on Windows 7? It seems like disabling DWM would be a simple way to validate that assumption.

Unfortunately, although I am using Windows 7, I'm probably not very able to notice microstutter - or else it's not happening to me. I did just try rotating the camera around. It seemed smooth, but then I don't really mind that much when games are an even 30 FPS so you probably don't want to listen to me on that.

You can also enable "frame drop" logging in the settings, and keep the log open. This will make PPSSPP log whenever a frame takes longer than expected from its perspective. It shouldn't happen when just spinning the camera (unless maybe you have crazy texture scaling settings or something.)

You can also enable real clock sync, which will try to sync PSP time and real time more closely (without it, we only sync on the frame, but with it, we sync about every 2ms.) Can't say if this will help or hurt, but if it alters it, it may be interesting.

-[Unknown]

@LunaMoo
Copy link
Collaborator

LunaMoo commented May 29, 2017

I kind of can reproduce it, definitely not bothersome even on my slower system, drops are rare and tiny I can see frames being dropped only by looking in the log when moving camera around fast for example:

23:15:780 idle0        N[SCEDISP]: HLE\sceDisplay.cpp:484 Dropping frames - budget = 33.37ms / 30.0fps, actual = 33.65ms (+0.28ms) / 29.7fps
Kernel processing time: 7.25 ms
Slowest syscall: sceGeListUpdateStallAddr : 1.13 ms
Most active syscall: sceKernelLibcGettimeofday : 3.90 ms
DL processing time: 1.21 ms
Draw calls: 16, flushes 1
Cached Draw calls: 0
Num Tracked Vertex Arrays: 0
GPU cycles executed: 796 (20.000000 per vertex)
Commands per call level: 78 0 0 0
Vertices submitted: 32
Cached, Uncached Vertices Drawn: 0, 32
FBOs active: 1
Textures active: 1, decoded: 1  invalidated: 1
Vertex, Fragment, Programs loaded: 1, 1, 1

Worth noting it never drops frames with unthrottle so it probably is something related to frame limiter, maybe limiting to 60 as an option instead of 59.94 would work around it.

Edit: NVM I think that's just me being unlucky grabbing first game under hand to test - wolfenstein 3D which yeah is a homebrew and might be buggy;p, I can't reproduce it in any commercial games tested soo far despite still seeing it in Wolf, but that one runs at weird fps by design and this might cause it's problems:]. Maybe the problem here is nvidia specific like with some driver settings/hack. I have only amd, but tested on two windows - 7 and 10 neither had any problems.

@mirh
Copy link

mirh commented May 29, 2017

Unfortunately, although I am using Windows 7, I'm probably not very able to notice microstutter

I think you can use PresentMon or GPUView to nail just about any problem that may hit the display chain.

Anyway, the problem we are having there now is the insanely retard nvidia driver when going fullscreen.

@mirh
Copy link

mirh commented Jul 2, 2017

PCSX2 forum base is pretty retard
If you:

  • are on Windows
  • have a nvidia card
  • can try 378 or nearly older driver
  • put "vertical sync" forcibly off in the settings

Can you try these samples to see if any of them presents tearing (press SPACE to start the animation)?
Thank you.

@Marcelo20XX
Copy link

Have the same exact problem, followed the GIT builds too and experience the same stutter in any 3d games as the OP, I am on windows 7 and a Nvidia video card. Have free time to test anything as long as I can get rid of this problem. Also I am interested if Unknown Brackets can show us how to sync to 60Hz just to test if this help with this problem, thank you and sorry for the bump...

@BParks21
Copy link
Author

I want this issue fixed so badly. The only thing that prevents ppsspp from being enjoyable for me. Glad to see another person who can confirm the problem.

@mirh
Copy link

mirh commented Jan 12, 2018

If you are on windows 7, try to start the emulator with "disable desktop composition" compatibility property checked.

As for the pcsx2 issue, final consensus was that fix is making sure rendering window has WS_POPUP style.

@Marcelo20XX
Copy link

I tested both with WDC on and off, same thing, I followed this issue by years and the oldest revision I remember that haven't this (yeah at some point PPSSPP wasn't suffering from this) was version ppsspp-v0.9.1-2005-gdea4668-windows-x86. This version hasn't the microstutter every few seconds BUT has a constant stutter once it gets desynced with the audio, back then Atract3 plugin was new and the core was adapting to it...

One thing that got rid of the microstutter for good was an option called "Atomic Audio Locks" with this you will always get smooth video syncing at the cost of jerky audio...

@mirh
Copy link

mirh commented Jan 12, 2018

Well, if you are that into the issue, and you have a "stable" version, then bisecting really is what you could do in the meantime devs check if the window is "properly configured".

@Marcelo20XX
Copy link

That's why I am interested in testing Unknown Brackets suggestion, but I don't know where in the source I can set the video to 60Hz...

@mirh
Copy link

mirh commented Jan 12, 2018

You can create a custom resolution with custom refresh rate if really any.
But it's pretty low probability given this seems a lot of other NTSC emulators (not to mention when PAL is brought in) never reported problems.

As for the audio.. Can't you just "null" it like on pcsx2?
(sorry I know nothing about ppsspp)

@Marcelo20XX
Copy link

I think I found a way to get rid of the stutter, please test the following build https://drive.google.com/open?id=16-jJjtM3bPAZuxt2Ix_zKZ4Ze6forJzM and report any problems. At least on my end I have butter smooth frame pacing, you need to enable the "Audio Sync (Resampling)" for it to work correctly...

@BParks21
Copy link
Author

@Marcelo20XX Yeah this definitely fixed it. Tested Daxter, Valkyrie Profile Lenneth and Crisis Core. No hitching no stutter no frame pacing issues at all.

@hrydgard
Copy link
Owner

@Marcelo20XX What have you changed in that build?

@Marcelo20XX
Copy link

Marcelo20XX commented Jan 13, 2018

Basically this:

diff --git a/Core/CoreTiming.cpp b/Core/CoreTiming.cpp
index 78ca1d2..75a88c4 100644
--- a/Core/CoreTiming.cpp
+++ b/Core/CoreTiming.cpp
@@ -123,7 +123,7 @@ u64 GetGlobalTimeUsScaled()
float vps;
__DisplayGetVPS(&vps);
if (vps > 4.0f)

  •   	freq *= (vps / 59.94f);
    
  •   	freq *= (vps / 60.00f); //Marce 59.94f
    
    }
    s64 usSinceLast = ticksSinceLast / freq;
    return lastGlobalTimeUs + usSinceLast;

@Marcelo20XX
Copy link

Marcelo20XX commented Jan 13, 2018

Well here is the complete diff: https://pastebin.com/taWSHJZs if you are interested. There is a problem though, at least on my end there is constant stuttering after some time of playing (similar to the one I found on the revision 0.9.1) that only goes away after you make the game load a new area or zone or whatever it makes to update it, it can be only in my rig so I need others confirm if they are suffering from the same thing...

@BParks21
Copy link
Author

How long did you play before it happened?

@Marcelo20XX
Copy link

Marcelo20XX commented Jan 13, 2018

I am testing this on FF3 and did the intro cave part until Luneth goes to the open world...15 mins or so

UPDATE: I tested this build like one hour straight running around the town of "Ur" in FF3, entering and exiting buildings and here are my findings: You will get heavy stuttering after entering and exiting a building a number of times or by triggering the game to load data, the stuttering seem tied to the load data routine as I only encounter this problem while zoning...No amount of tweaks or configurations can fix this issue on Windows 7 on my rig BUT...

After battling another hour or so with this stuttering I rebooted this time on Windows XP and as you can guess I got finally no stuttering at all in the OpenGL backend (on the Direct3D it stutters briefly every now and then)...

Well that concludes my testings, I used the following rig: Windows XP SP3 32bits, Windows7 64 bits on a Core 2 Duo Q9660 with a Nvidia 9600GT and 2 GB of RDRAM, I want to point out that the issue may be only on my side as I currently don't have access to a more powerful rig...

I will update if I encounter any remaining issues...

@BParks21
Copy link
Author

I will do some more testing later and get back with you.

@unknownbrackets
Copy link
Collaborator

You're not using the timer hack, right? One of those changes for it, so just want to confirm.

-[Unknown]

@Marcelo20XX
Copy link

Marcelo20XX commented Jan 15, 2018

No, I am not using that hack and about the heavy stuttering I was suffering is maybe only on my system because it only happens when there is too much action or there is data that is being loaded from my HD ( which is mechanical BTW) because it doesn't happen in all games, for example I can play Project Diva and the Megamans game without a single hitch from start to finish...

[Unknown] the microstuttering is because as you said before the emu is syncing at 59.94 instead of the common 60hz that most desktop PCs uses, I had the same problem in other emus, for example in DesMume i got the same stuttering every few seconds disregarding if the game ran at full speed or not, but after using the same emu on the retroarch frontend I got smooth scrolling mainly because RA forced the emu to sync at 60hz and resample the audio to not have any issue, like PPSSPP is now doing after the changes I made...

I know the correct refresh is the currently used but there could be an option to force PPSSPP to sync at 60Hz for the people who plays on a desktop PC, just saying...

@BParks21
Copy link
Author

BParks21 commented Jan 15, 2018

I also get the same stuttering in the standalone Desmume and not the RetroArch version.

@BParks21
Copy link
Author

@Marcelo20XX So far your fix for ppsspp has worked perfectly. I've had no stutter in Valkyrie Profile and I've played for over an hour in one session and my game is running off a mechanical drive. Also i switched to another monitor with the game running and still no stutter at all. I'm gonna play a few other games for roughly an hour. So far so good.

@BParks21
Copy link
Author

@Marcelo20XX After playing Daxter and Kingdom Hearts Birth By Sleep for an extended period of time i did see stutter return. I wonder why it didn't return in Valkyrie Profile. Maybe because VP is 60 fps and the other two are 30 fps?

@Marcelo20XX
Copy link

Marcelo20XX commented Jan 15, 2018

I reduced the issue by checking IO on thread and IO timing method "host" on games that are 30 FPS, 60FPS games doesn't have any visible issues...

@BParks21
Copy link
Author

Doesn't that have potential negative side effects?

@unknownbrackets
Copy link
Collaborator

unknownbrackets commented Jan 15, 2018

One piece of this puzzle is that some PSP games will internally time themselves based on 59.94, instead of relying on the hardware timing. Since the hardware was 59.94 anyway, it was fine even if you assumed it would never change.

This is why we time based on 59.94, mainly.

Also, if changing IO timing has impact on this, then you've got something else going on than FPS timing. Possibly your disk going to sleep.

The "Fast" IO timing is the same for everyone: you will always get the same bugs. The "Host" IO timing is different depending on your hardware, and other applications running on your system - but definitely won't stutter as much. It's known to (possibly inconsistently) both fix and introduce bugs in various games. It might work 10 times you do something, and then bug out the 11th, only because that 11th time, the timing was vastly different from what real PSP hardware would've had.

Maybe instead of changing all those places, try changing these in sceDisplay.cpp..

float scaledTimestep = timestep;

Change to:

float scaledTimestep = timestep * 1.001f;

And also:

float scaledVblank = timePerVblank;

Change to:

float scaledVblank = timePerVblank * 1.001f;

That would keep the internal game time running at 59.94, but time the "outside world" at 60fps. Make sure you have real clock sync disabled, or adjust that one too.

(not tested.)

-[Unknown]

@BParks21
Copy link
Author

I haven't tested the IO timing but i have this issue even when games are running on my standalone ssd or my m.2 raid config.

@Marcelo20XX
Copy link

Marcelo20XX commented Jan 15, 2018

[Unknown] That could be very possible the cause why I am having smooth scrolling in some games and a little stuttering in others, I saw the same issue in SNES emulation, for example with Super Mario World, no matter the amount of tweaks/hacks on the core emulators it wont give you a perfect smooth scrolling on a LCD monitor, you will get stuttering every few seconds BUT on the other side you could play Donkey Kong Country without any scrolling issues. Seems that Super Mario syncs to the internal 59.97Hz while DKC being a RARE game doesn't care...

One of the games that its stubborn and still give me little stutters from time to time is Dracula X the main game...

Will test your suggestion asap, thanks!

@BParks21
Copy link
Author

BParks21 commented Jan 15, 2018

What snes emulator, all the snes cores i use in RetroArch are stutter free. Emulators like PCSX2, epsxe, DeSmuME and vba-m give me stutter. Standalone higan gives me a ton of stutter with snes emulation but absolutely zero with the new libretro core. I know that Super Mario World stutter you're talking about. It happens on real hardware too, usually happens when you start running full speed. Thats just how the game is.

@hrydgard
Copy link
Owner

Cool. I'll fix it soon: #12720

@pitrako
Copy link

pitrako commented Mar 23, 2020

When "Render duplicate frames to 60hz" and "Vsync" are enabled in the emulator If I enter Fullscreen with alt+enter or F11 the game keeps running but keyboard/mouse doesn't respond.

@unknownbrackets
Copy link
Collaborator

Does alt-enter work to exit out of it, or are you stuck at that point? What graphics card are you using, and do you have the latest drivers?

I don't experience this on NVIDIA. That said, I have a multi-monitor setup (the only way to live), which sometimes makes fullscreen behave differently.

-[Unknown]

@pitrako
Copy link

pitrako commented Mar 23, 2020

Stuck in fullscreen, RTX 2080, Nvidia Drivers 442.74, PPSSPP v1.9.3-554-gc6948561f

Edit: I changed to drivers 445.75 and It's still the same.

@unknownbrackets
Copy link
Collaborator

Okay, that sounds like a separate issue and maybe it's somehow AMD only. Doesn't really belong here, though.

It sounds like for some people, the vsync improvements (which haven't really changed) helped, and for others the duplicate frames option helped. That said, apparently vsync has not (consistently) helped, possibly for driver heuristics/updates reasons.

This issue has become very long, but I've updated the notes in #9736 (comment) to account for the duplicate frames option.

-[Unknown]

@pitrako
Copy link

pitrako commented Mar 23, 2020

But I have a Nvidia card not an AMD card.
https://im3.ezgif.com/tmp/ezgif-3-d75cdc7e6251.gif
No input from mouse, I think Its just when I enable vsync inside emulator not with the other option, but if I dont enable both I get the stuttering.

Edit: It happens with vulkan, Directx 11 works normal.

@hrydgard
Copy link
Owner

Please open a new issue about that, I'll try to take a look soon.

@BParks21
Copy link
Author

I don't have that issue. Mouse and keyboard work fine with all backends with fullscreen and duplicate frames on.

@ghost
Copy link

ghost commented Mar 25, 2020

In the end the vsync changes work now on Vulkan too and i get consistent performance and FPS now.
Dont know why I had issues with one of the previous builds.
You did some black magic with Vulkan because its the only emulator I dont get tearing with vsync on.

@JetSetter1984
Copy link

I got my vita out yesterday to play some of my psp games and what I found was interesting. Games which are running at 60fps seem to use adaptive vsync. When they are maintaining 60fps there is no tearing. When they drop below they allow tearing. 30fps games lock to 30 with vsync. Thought I'd just add this here it might explain tearing in some situations.

@JetSetter1984
Copy link

Unless the psp had a vrr screen

@hrydgard
Copy link
Owner

It didn't, some PSP games indeed tear on the real hardware. That behavior is not easy to emulate, and I'm not sure it would even be very meaningful.

@NecFan
Copy link

NecFan commented Apr 8, 2020

I found a solution to remove at 100% micro stuttering in games like Castlevania X Chronicles, Ao no Kiseki, Ys: The Oath in Felghana and many many others (often XSEED games). I tested only on PC Windows, using "Retroarch" and its PPSSPP core.

Retroarch is here important, because one of its settings eliminates micro stuttering in games above: in video setting (Retroarch), at sync option, I indicate '2' to half refresh rate screen by 2.
In games like these ones, screen movements become absolutely smooth. No more micro stuttering at all.

@Marcelo20XX
Copy link

What is the name of the parameter that halves the refresh rate, I don't have the sync option on the Video options?

@JetSetter1984
Copy link

It's called vsync swap interval, and you must also enable vsync for it to work

@Anuskuss
Copy link
Contributor

Anuskuss commented Jun 28, 2020

This was a long but interesting read but I still don't understand the gist of it. It started with people claiming to notice micro stuttering but shifted to "only on 30 fps games" in the middle. Is the latter fixed with duplicate frames (#12460 is still open)? I've done my own tests and I don't see any micro stutters. I've tested Daxter (30fps) and rotated the camera and although it looks pretty bad (I guess that's a 30 fps thing though) I can't see any stutters (maybe some small slowdowns/speedups but that could be the game). Duplicate frame doesn't do anything to change that, so either my eyes are bad or it just doesn't happen to me.
I've also tried setting my TV to 59.940 Hz but apparently that's not a thing anymore on Windows so there's that. Hope to hear some updates from you guys.

Edit: According to this Refresh Rate test setting it to 59 Hz does indeed result in 59.940 Hz. I mainly play retro games on my machine, would it be recommended to set the display to 59 Hz? Vsync should work fine either way (right?) but are there any compatibility problems?

@SaltyBet
Copy link

SaltyBet commented Jul 5, 2020

Just tested:

  • PPSSPP 1.10.1
  • RetroArch 1.8.8 with latest PPSSPP core.

The stuttering only happens in PPSSPP 1.10.1.

Not sure how to interpret that information.

@ghost
Copy link

ghost commented Aug 23, 2020

Tearing is back with Vulkan on the latest PPSSPP git version :X .

@unknownbrackets
Copy link
Collaborator

What's the first git build seeing it again, and the last one where it worked?

If you can't find one where it works, testing again now, it makes it much more likely this is caused by a driver update.

-[Unknown]

@hrydgard
Copy link
Owner

If tearing is back, it's the driver, not PPSSPP.

@ghost
Copy link

ghost commented Aug 23, 2020

literally 1 build away from tearing.
meaning 473 does not have tearing while 474 does have.
If it is the driver like you say I will stay on 473 for now.

@hrydgard
Copy link
Owner

Wait what, 474 tears but 473 doesn't? That would make it caused by this, which seems utterly bizarre:

d465ce5

@mojojojodojo Please mention what GPU and platform you are on.

@BParks21
Copy link
Author

@hrydgard So what's the verdict is this good to close?

@ghost
Copy link

ghost commented Apr 14, 2022

@hrydgard So what's the verdict is this good to close?

Maybe? And focused more on sync to host refresh rate feature request #15081

@ghost
Copy link

ghost commented Sep 26, 2022

How about this now after #16104

@hrydgard
Copy link
Owner

I don't think those will solve microstutter, rather bigger stutters that happen when new shaders are compiled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests