VOGONS

Common searches


First post, by asdf53

User metadata
Rank Member
Rank
Member

Sadly, this hasn't been fixed yet as of Dosbox 0.74-3, running Windows 10. You can try this yourself:

Use the default config file, but change this line:

priority=higher,normal

to:

priority=higher,pause

Then, start Dosbox and run any game. While playing, press alt+tab to leave Dosbox, then press alt+tab again to return. The game will drastically slow down each time you press alt+tab. This becomes obvious when you press alt+tab ten times in a row. For example, Quake will eventually run at 1 fps. Also, it doesn't have anything to do with the keyboard. You can also leave Dosbox by clicking the mouse outside the window, then bring it back by clicking the taskbar icon. Same effect.

What's interesting is that pressing the PAUSE key to pause and unpause does not slow down the game. This means that the bug is not in the code that pauses Dosbox. It must be the code that processes the events that send the window into the background and foreground. Maybe an infinite loop or recursion somewhere because of how severe the slowdown is?

I can also see that someone opened a bug ticket at sourceforge: https://sourceforge.net/p/dosbox/bugs/367/ but it hasn't been fixed yet. I'm not a programmer myself, but I will try to look at the code and figure out what the problem is. I suspect the file we need to fix is "src/gui/sdlmain.cpp", because that's where the pause functions are. Let's hope this can be fixed somehow.

Last edited by asdf53 on 2020-01-23, 08:46. Edited 1 time in total.

Reply 1 of 1, by asdf53

User metadata
Rank Member
Rank
Member

I found the problem, it's in sdlmain.cpp. When the window loses focus, it calls CPU_Enable_SkipAutoAdjust() and lowers the process priority. When it regains focus, it should call the opposite function CPU_Disable_SkipAutoAdjust() and restore priority, but this does not happen. This was responsible for the performance loss. Once you add the missing function calls, the speed is back to normal once you reactivate the window.

Before:

								// We've got focus back, so unpause and break out of the loop
if (ev.active.gain) {
paused = false;
GFX_SetTitle(-1,-1,false);
}

After:

								// We've got focus back, so unpause and break out of the loop
if (ev.active.gain) {
paused = false;
GFX_SetTitle(-1,-1,false);
SetPriority(sdl.priority.focus);
CPU_Disable_SkipAutoAdjust();
}

I submitted a patch at https://sourceforge.net/p/dosbox/patches/285/

The patch has been committed to the SVN repository, but it will only take effect with the next official Dosbox release. You can either wait for that, or download one of the SVN builds that include the newest changes before a new version is released.
Here's a list of SVN builds: https://www.dosbox.com/wiki/SVN_Builds
For example, Dosbox ECE provides a current SVN build at: https://dosboxece.yesterplay.net/download/

Last edited by asdf53 on 2019-12-10, 01:03. Edited 1 time in total.