mgba-emu / mgba

mGBA Game Boy Advance Emulator
https://mgba.io/
Mozilla Public License 2.0
5.7k stars 787 forks source link

Visual stuttering and frame drops regardless of settings #2199

Open m-orsh opened 3 years ago

m-orsh commented 3 years ago

Lowered audio buffer, tried 60fps, 59.7275fps, different renderers, everything I could attempt.

There is a consistent frame being dropped every second or two. (Yes frame skip is at 0) I have the audio buffer at the lowest setting, and sync to audio enabled.

I recorded a video to try and upload the stuttering, but amusingly enough, the video recorded at 59.7275fps has zero stuttering when I viewed it.

GTX 1080 i7-9700K

RafaelTrepaUnCarballo commented 3 years ago

I have similar issues only in Windows, while in Switch the framerrate and audio are silky smooth. The issue was present in every build I tested (dev builds, stable 0.9.1-0.7.3).

I could "fix" it by enabling video sync, disabling audio sync and enforcing Adaptative sync (half refresh rate) in mgba profile in Nvidia drivers. The downside is the audio sounds terrible (even with the highest audio buffer) and I can't fast forward beyond the refresh rate (120hz, so x2) of my laptop (I can, but it messes the video/audio flow and doesn't really go faster)

I think FPS target is buggy and raises the frame rate slightly higher than the chosen target with audio sync disabled/video sync enabled When I choose 60fps or native, mgba FPS counter shows 65-66fps. 45fps option gives 47fps, 30fps option gives 30.6fps, 90fps gives 92-94fps... only 120 seems to run at that framerate (although 2 times faster), but that's probably due to the windows compositor limiting it to the monitor max refresh rate.

Current Device: Laptop legion-5-15arh05h with ryzen 5 4800H, GTX2060 (and a Radeon disabled in BIOS), 16GB RAM, Win10 20h2 and a 120hz monitor (some emulator dislike being run at that refresh rate, forcing me to use Adaptative sync (half refresh rate)

I also have some trouble with framerate in my old computer, affecting this and other emulators. In that case, I think the root problem was the dual GPU (intel HD4600+ Geforce 820M) managed by Nvidia Optimus, giving weird frame pacing and diagonal tearing issues in many emulators and games. I think I "solved" that by enforcing regular vsync in Nvidia global settings (breaking the turbo in several emus) and running mgba with Intel igpu, but I'm not sure...

endrift commented 3 years ago

That issue sounds like #827, which I've yet to be able to reproduce even on my 144 Hz monitor. It's definitely the case that if your monitor is refreshing at >60 fps video sync doesn't work properly, but that's because if it did work the way video sync is "supposed" to work it'd be running too fast, e.g. at 120 fps for a console that runs at 59.727 fps.

RafaelTrepaUnCarballo commented 3 years ago

Why can't video sync fill the extra refresh cycles with duplicated frames? Treating refresh rates that are multiple of 60 as 60hz, the refresh rate mgba is optimized for?

endrift commented 3 years ago

That's not how drawing works here. If I don't push a frame to the GPU it doesn't update the GPU. There aren't "extra refresh cycles". And I'm trying not to push extra frames. Moreover, the point of sync to video is to use the monitor's refresh rate to clock the sync. If the monitor's refresh rate is wildly different from the GBA, then it's meaningless for clocking sync and you'd be better off just using a random software timer. Audio sync uses the audio driver to clock the sync, which is actually predicable and easy to adjust against.

endrift commented 3 years ago

Does anyone here have this issue who isn't using a high framerate monitor?

m-orsh commented 3 years ago

Does anyone here have this issue who isn't using a high framerate monitor?

To be clear, this original issue occurs on whatever monitor I use it on. 60fps, 120fps, etc. I've got two monitors attached running at 60fps currently. My TV is one of them, and it can't do anything higher than 60fps. Both show this issue.

It occurs regardless of what audio buffer is set. It occurs regardless of what game is running. It occurs regardless of whether sync to video or sync to audio is chosen. It occurs on the latest version of mgba. It occurs while running at 60fps OR 59.7275 (original) fps.

Here's a video i recorded on OBS.

https://webmshare.com/x8gxn as you can see there are little jumps and hops in the framerate. This is what I'm talking about. (Ignore the one moment i hit the speed button by accident)

Not sure what's up. But it's probably related to something related to PC configuration rather than screen. Windows 10 x64 by the way.

endrift commented 3 years ago

I can see a few little bumps, yeah. Not very many though, and I'm not sure exactly what's going on there.

m-orsh commented 3 years ago

This is the only issue that prevents mgba from looking like original hardware when running for me.

ghost commented 3 years ago

I don't mean to nag but is this getting fixed any time soon? I'm prone to headaches and this issue makes the emulator completely unusable for me. It happens in every top-down game I try.

endrift commented 3 years ago

It might have been improved recently. Please try a development build. The biggest thing holding it back from being fixed is, well, I can't reproduce it so I can't tell if it's fixed or not without other people telling me.

m-orsh commented 3 years ago

Just tried the latest development build. It still stutters, here is some additional info while on default settings opening the emulator: Audio buffer set to default (1536) -> constant stuttering, very choppy. Audio buffer set to lowest setting -> much less stuttering, but still has a stutter every 1-2 seconds.

endrift commented 3 years ago

Hmm, I think my sound card may be affecting the situation some if that's what your results are (they're much worse on my end on Windows at the lowest setting, which is bad). What sound card do you have?

m-orsh commented 3 years ago

To be clear when I say lowest setting I mean the 512 setting. Motherboard is MAG Z390 TOMAHAWK and sound output I believe is Realtek® ALC892 Codec. I don't have any specific PCIE sound card, Realtek HD audio is what drives audio on the motherboard seemingly.

endrift commented 3 years ago

Yes, that's the info I was looking for. Do you have any of the extra Realtek software installed? I do, and it's kind of terrible, but I need it for some stuff...

m-orsh commented 3 years ago

There's a "Realtek Audio Console" that brings up this when opened: image

I believe this is factory default software.

endrift commented 3 years ago

Interesting. I'll see what I can do.

RafaelTrepaUnCarballo commented 3 years ago

I think the new builds improved a little the frame times in my laptop, but it still not perfect.

Unlike @m-orsh if I reduce much the audio buffer (512) the choppiness increases and the fps counter show values lower than 60fps (around 55ish). The medium or highest values work better for me.

I don't have installed that fancy "Realtek Audio Console". I have a UWP-like app with the same name.

I have a Realtek Audio chip, but I don't know where to find its full name. My laptop is Legion 5-15ARH05H Laptop (Lenovo) - Type 82B1 Hardware id of Realtek: HDAUDIO\FUNC_01&VEN_10EC&DEV_0257&SUBSYS_17AA389E&REV_1000 Windows 10 21H1

RafaelTrepaUnCarballo commented 3 years ago

I forgot to mention the issue disappears once I connect my laptop to my 60hz TV.

ghost commented 3 years ago

Strange. I have a 60hz monitor and get the issue.

My other specs

Capture

RafaelTrepaUnCarballo commented 3 years ago

imagen imagen imagen

Another detail I should have mentioned: When I connected it to my TV, I felt some minimal hitches with the largest audio buffer that disappeared when I lowered to lower values (512, 700... I didn't test more).

Curiously, I suffer the laptop shows the opposite effect with its own 120hz monitor: 768 and specially 512 causes extra choppiness and framerate drops down to 56fps.

endrift commented 3 years ago

Can you highlight the audio devices on these? I think those are contributing more than you might expect.

I'd like to fix this for 0.9.2 but given that I can't reproduce it locally (as it varies so wildly between computers) I'm not hopeful.

RafaelTrepaUnCarballo commented 3 years ago

I'm afraid I can't give more info of the sound card. Windows and Speccy identify it with the generic name "Realtek High Definition Audio" and, besides the driver version number (v6.0.9003.1 date 11/8th/2020), I don't know how to get more information.

The Hardware id of the Realktek is HDAUDIO\FUNC_01&VEN_10EC&DEV_0257&SUBSYS_17AA389E&REV_1000 and it's in the motherboard LENOVO LNVNB161216 FP6.

endrift commented 3 years ago

Googling around makes me think it's a Realtek ALC3287, which is what I was looking for. I have no idea if that'll be helpful though. I'm still trying to figure out how to reproduce, but I'm not sure I want to hold up 0.9.2 on this.

ghost commented 3 years ago

Trying to play Zero Mission and I think the issue is causing intermittent audio crackling. Guess it's not just top down games.

RafaelTrepaUnCarballo commented 3 years ago

Trying to play Zero Mission and I think the issue is causing intermittent audio crackling. Guess it's not just top down games.

Before jumping to conclusions... -Do you have Sync to Audio enabled and Sync to Video disabled? (in the Emulation menu) -Did you try increasing the audio buffer to higher values? (Tools->Settings...)

I ask because I don't suffer "intermittent audio crackling", only some frame shuttering.

endrift commented 3 years ago

Audio crackling is an unrelated issue to this one--this one only affects visual presentation.

uardo commented 3 years ago

I'm having this issue on a freesync enabled 75hz monitor. On older Windows 10 revisions and AMD drivers the game displayed smoothly in fullscreen mode like it does on a gba screen, but now on latest versions I get visible shimmering on both window and fullscreen modes (always at native gba refresh rate). I tested older mgba versions, but the issue persisted.

This issue can be mitigated by setting the monitor to 60hz, like I had to do in Sonic 3 AIR, then both window and fullscreen modes behave correctly. The emulator core in Retroarch behaves correctly on 75hz (I have both "Sync to exact content framerate" and "Disable desktop composition" enabled).

Another thing that I found interesting on 0.9.1 openGL renderer is that the fast forward (held) is limiting itself to the display refresh rate (it even ignores AMD settings if I set vsync to Always Off). Amusingly, the content displays correctly that way (except for the audio, which sounds off at 74.9 fps).

syncIssueReport.zip

endrift commented 3 years ago

@EduardoJordao That issue is #827, which I think is a different issue.

m-orsh commented 3 years ago

It would be the best thing ever for this issue to be fixed, as having a GBA emulator run smoothly at 60FPS (or the original framerate) on my computer would be great

RafaelTrepaUnCarballo commented 2 years ago

The latest update of Retroarch's mgba core fixed frame pacing and audio cracking issues. https://www.libretro.com/index.php/retroarch-1-9-13-release/

I was wondering if the fixed issues of RA core and the active issues of standalone mgba are related...

m-orsh commented 2 years ago

This framerate judder is the biggest annoyance I have with mgba, without it it'd be perfect. The amount of judder changes depending on audio buffer size selected. However regardless of size (or if I select Qt Multimedia instead of SDL) it has judder. Even when running at 60fps.

ghost commented 2 years ago

@endrift Can you fix this please? It hurts my eyes and makes me feel sick.

endrift commented 2 years ago

Asking nicely doesn't help it get fixed. The reason it hasn't been fixed is because I haven't figured out the source of the issue, not because I don't want to fix it. I assure you, I do want to fix it.

Rings4 commented 2 years ago

Chiming in that I, too, get stutter in mGBA.

Is there a GBA emulator for Windows that DOESN'T have stutter?

GaussTek commented 2 years ago

Hello! I just wanted to report that I also get stuttering, it's more notable on vertical scrolling games and so on, like Kirby Tilt n Tumble. I do manage to fix it by decreasing the Audio Buffer from the default to the lowest setting. Increasing it just triggers heavy stuterring in my case. I do have Audio sync enabled and I have a 144Hz monitor on my Laptop, if that helps.

mcmull500 commented 2 years ago

I would like to add that I have a 60Hz monitor and I get stuttering in the same way. Audio Buffer helps, but doesn't completely eradicate it.

I would like to point out that on version 0.8.3 I do NOT get stuttering at all. I am upgrading to solve a different issue. but 0.8.3 does not have stuttering for me at all

ghost commented 2 years ago

Here's my 2 cents:

Running a laptop with 60hz monitor and Windows 8.1 64 bit. I used "Classic NES Series - Castlevania (USA)" rom demo mode as a test because it works really well for this particular case.

-Audio sync is on, sync to video is off, framerate is set to native, frameskip is zero, using OpenGL display driver. -I tried all combinations of audio buffer plus output frequency. -Increasing buffer size makes the framerate worse (at 4096 it looks like frameskipping is turned on to maximum even though it is not), and muting the volume makes it the absolute worst surprisingly.

I noticed that in my task manager while this is going on, the background process "Windows Audio Device Graph Isolation" (audiodg.exe) is spiking at around 25% for CPU usage during the worst framerates, and with the volume muted in the emulator itself it hovers around that mark the whole time Castlevania is running its demo. The title screen spikes are consistent, even though there is no sound played at the title screen until you press start. The title screen spike is also the same with just the "sync to video" option enabled, yet there is no frame dropping at all with this on. With "sync to audio" the demo framerate is all over the place, as low as under 50 fps!

Hopefully that all wasn't to hard to follow along to.

Now I am going to tell you what caused this problem. The built in Windows sound enhancements!!! Here's what fixed it for me:

Go to control panel and find "Sound" or whatever it is that controls sound in current versions of Windows. Click it, then in "Speakers properties" go to "Enhancements" tab, and then tick the box "Disable all enhancements" and apply, ok, yada yada. https://imgur.com/l5AeM7b

Odd thing is I had all of those turned off, but the box wasn't ticked. I guess Windows was still running them regardless. But the spiking is gone and everything is more silky smooth.

As a final test I ran "Famicom Mini 29 - Akumajou Dracula (Japan)" because the title is on a loop and scrolls in smoothly from the left. There is still some slight stutter but it works a lot better than it did. Framerate is always between 59.5 and 59.7 now.

Rings4 commented 2 years ago

Here's my 2 cents:

Running a laptop with 60hz monitor and Windows 8.1 64 bit. I used "Classic NES Series - Castlevania (USA)" rom demo mode as a test because it works really well for this particular case.

-Audio sync is on, sync to video is off, framerate is set to native, frameskip is zero, using OpenGL display driver. -I tried all combinations of audio buffer plus output frequency. -Increasing buffer size makes the framerate worse (at 4096 it looks like frameskipping is turned on to maximum even though it is not), and muting the volume makes it the absolute worst surprisingly.

I noticed that in my task manager while this is going on, the background process "Windows Audio Device Graph Isolation" (audiodg.exe) is spiking at around 25% for CPU usage during the worst framerates, and with the volume muted in the emulator itself it hovers around that mark the whole time Castlevania is running its demo. The title screen spikes are consistent, even though there is no sound played at the title screen until you press start. The title screen spike is also the same with just the "sync to video" option enabled, yet there is no frame dropping at all with this on. With "sync to audio" the demo framerate is all over the place, as low as under 50 fps!

Hopefully that all wasn't to hard to follow along to.

Now I am going to tell you what caused this problem. The built in Windows sound enhancements!!! Here's what fixed it for me:

Go to control panel and find "Sound" or whatever it is that controls sound in current versions of Windows. Click it, then in "Speakers properties" go to "Enhancements" tab, and then tick the box "Disable all enhancements" and apply, ok, yada yada. https://imgur.com/l5AeM7b

Odd thing is I had all of those turned off, but the box wasn't ticked. I guess Windows was still running them regardless. But the spiking is gone and everything is more silky smooth.

As a final test I ran "Famicom Mini 29 - Akumajou Dracula (Japan)" because the title is on a loop and scrolls in smoothly from the left. There is still some slight stutter but it works a lot better than it did. Framerate is always between 59.5 and 59.7 now.

Unfortunately disabling audio enhancements is not feasible for some setups . I require it for my surround sound setup, otherwise my pc will just send a stereo signal and not activate my subwoofers.

ghost commented 2 years ago

Right I understand that. I'm hoping maybe that info might provide some insight on the stuttering problem.

I never really thought much about the cpu usage that audiodg.exe was using before, just thought it was normal and it doesn't affect the other emulators I use such as MAME, snes9x, nestopia, punes, Bizhawk, or even mednafen in its psx core which is a little taxing for this laptop. I also wonder why it spikes more when there is no sound. My reasoning is, if there is no sound playing, then there is little to process so the cpu usage should be low.

60 fps setting in mGBA is perfect. I tried turning the framerate down little by little towards the native rate (59.9, 59.8, etc) and it stutters no matter how rounded the numbers are.

m-orsh commented 2 years ago

Since creating the issue I've had sound enhancements disabled.

HoratioSanchez commented 2 years ago

Did anyone lese have a solution to this? I switched to 0.8.3 win64-bit and it seemed to stop it.

zipplet commented 2 years ago

I'm having this issue with the latest release :( 60hz monitor, Windows 10. Happy to provide more information if it helps nail down this problem. I've tried all the suggestions here and I do confirm that lowering the audio buffer to 512 improves it slightly, but it's still very bad.

sleepyzer0 commented 2 years ago

I too am having this stutter issue. Even when I record at 60FPS and move the file to my phone the stutter is blatantly there meanwhile emulating the same ROM on my Android device runs butter smooth. I have a great computer and using a 170Hz 1440p Acer display. Running at 60Hz does not solve the issue. Changing FPS locks, freesync on/off, and VSYNC on/off does not solve the issue. I tried 0.8.3 and noticed improvement but it still has the judder/stutter.

https://user-images.githubusercontent.com/105520185/190065298-1fa59c85-597f-46ad-97b1-2539b9e464a2.mp4

endrift commented 2 years ago

Chiming in "me too" is not useful. It's a known issue, one I can reproduce, and one which I've yet to be able to fix despite attempts. Further replies that don't give any new information will be removed.

endrift commented 2 years ago

I attempted to fix this for 0.10.0, but ran into enough trouble that I've delayed it until 0.10.1 in the interest of finally releasing 0.10.0.

AcerUp commented 1 year ago

This stuttering problem is definitely present on my end in 0.10.1 and all development builds since then, but checking audio sync only works fine for the previous release (0.10.0).

AcerUp commented 1 year ago

I found something: adjusting the "Settings - High-resolution scale" to very high values (11x or above) causes the stuttering on newer versions than 0.10.0. Doesn't stutter at all on lower values than 9x, at least from what I can see. Interesting that scaling to 11x or above doesn't have that problem in the previous release, but that should help narrow down the culprit.

isadon commented 1 year ago

Seeing stuttering on macOS 13.2.1 with mGBA 0.10.1. For some reason OpenEmu 2.3.3 which uses mGBA 0.10.0 is much smoother with no stutter.

AcerUp commented 1 year ago

mgba development version 7947-ea345ca81 is working a lot better. Still barely noticeable, but 95% of the stuttering is gone, even on 16x high resolution scale. Game tested was super mario advance 4: hammer suit, chucking hammers, jumping, and sprinting at full speed through the first level at the same time for reference.

RafaelTrepaUnCarballo commented 1 year ago

After updating to the latest dev (0.11-7952-9b2ba64bc), the stuttering and frame drops has reduced considerably. With Audio sync and a sample rate 1024-1536 it sounds perfect, although you can notice it still skips a frame from time to time.

(I also recently updated my Nvidia drivers to 528.49, maybe that helped)