OpenTTD

Tasklist

FS#6546 - Fast forward on macOS is restricted by frame refresh rate

Attached to Project: OpenTTD
Opened by Stefan Ring (Ringding) - Friday, 17 March 2017, 15:00 GMT
Type Bug
Category Interface
Status New
Assigned To No-one
Operating System Mac OS X
Severity Medium
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

On macOS, fast forward does not run as fast as the CPU can do. It runs about twice the normal speed. This happens at least on El Capitan.

Following information unrelated to OpenTTD, specifically I'm not implying that I've run OpenTTD inside DOSBox -- <http://www.vogons.org/viewtopic.php?f=32&t=46306>:
I've had the same issue with DOSBox, and I found that it behaved like this when DOSBox was compiled on a contemporary macOS machine (I think Yosemite or later), but when I compiled it on Snow Leopard, the frame refresh restriction went away, even when running on El Capitan. I have not found out what caused this. Maybe someone can enlighten me.
This task depends upon

Comment by andythenorth (andythenorth) - Sunday, 03 September 2017, 10:06 GMT
Is full-animation enabled here?

If so see FS#6469, which I suspect will at least mitigate this, or possibly eliminate it.
Comment by Stefan Ring (Ringding) - Sunday, 03 September 2017, 10:53 GMT
I can try, but I doubt it, as if this was the cause, the CPU usage would be much higher. It's showing ~30% in fast-forward vs. ~19% at normal speed.
Comment by Stefan Ring (Ringding) - Monday, 04 September 2017, 20:05 GMT
As expected, it does not make a difference.
Comment by andythenorth (andythenorth) - Tuesday, 05 September 2017, 06:35 GMT
Join IRC sometime if you want to investigate further https://wiki.openttd.org/Irc

Trading ticket comments is a non-fluid way to discuss the issue ;)
Comment by Stefan Ring (Ringding) - Saturday, 21 October 2017, 13:07 GMT
I've played around with this quite a bit, and for now I've accidentally found that setting [ this->cocoaview setWantsLayer:YES ] in wnd_quartz.mm is a cheap way to speed it up a good deal by pushing the frame rate up from 60 to 125.

Someone on the DOSbox forums hinted that this peculiar frame rate limiting behavior may already be a thing of the past on the Sierras. I'm still on El Capitan for now.
Comment by Stefan Ring (Ringding) - Thursday, 26 October 2017, 11:18 GMT
Basically, what I do now is this:

if (cur_time() - time_of_last_draw < 1/60.) continue;

right before the UpdateWindows() call in event.mm. And I record time_of_last_draw at the very end of OTTD_QuartzView:drawRect.

This works nicely, and it is also quite a bit faster than on Linux because the backbuffer does not needlessly get drawn hundreds of times each second. I just hope that the game state does not depend on anything done during UpdateWindows.
Comment by andythenorth (andythenorth) - Thursday, 26 October 2017, 11:31 GMT
Hi Stefan, got a patch / diff for that? I can test.

I'm on Sierra, speed of FFWD remains poor for both official OTTD binary and for local build.
Comment by Stefan Ring (Ringding) - Thursday, 26 October 2017, 11:54 GMT
This

Loading...