After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 756302 - (Quixote) Timer resets when pausing or ending game
(Quixote)
Timer resets when pausing or ending game
Status: RESOLVED FIXED
Product: gnome-mines
Classification: Applications
Component: general
3.18.x
Other Linux
: Normal major
: ---
Assigned To: gnome-mines-maint
gnome-mines-maint
: 757447 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-10-09 15:54 UTC by quixote.don.rocinante
Modified: 2015-11-02 06:39 UTC
See Also:
GNOME target: ---
GNOME version: 3.17/3.18



Description quixote.don.rocinante 2015-10-09 15:54:32 UTC
In the latest version of gnome-mines to hit the Arch repositories (3.18.0), any action that would normally pause the timer instead causes it to reset to zero.  That is to say pausing the game results in a displayed time of zero, and finishing the game records zero to the history.  While I am not entirely familiar with how this game is built, I had a look through the .vala files.  Apparently, in minefield.vala, the function it references as using when freezing the clock (stop_clock ()) sets the clock to NULL regardless of circumstances.  This function is referenced both for pausing and ending the game.
Comment 1 Michael Catanzaro 2015-10-09 21:42:25 UTC
Guess: could it be a regression from 0b7fde3400274cf7720d4a868718377487dd2ea2?
Comment 2 Anders Jonsson 2015-10-12 21:00:00 UTC
(In reply to Michael Catanzaro from comment #1)
> Guess: could it be a regression from
> 0b7fde3400274cf7720d4a868718377487dd2ea2?

I can confirm this. The timer is reset when the game is paused on git master, but this is fixed if 0b7fde3400274cf7720d4a868718377487dd2ea2 is reverted.


commit 0b7fde3400274cf7720d4a868718377487dd2ea2
Author: Robert Roth <robert.roth.off@gmail.com>
Date:   Fri Jun 26 02:45:16 2015 +0300

    Drastically reduce CPU usage
Comment 3 Robert Roth 2015-10-13 06:00:57 UTC
Thanks for the heads-up, I have checked the commit, my mistake there, one regression applying it (pause resets the timer) and another one reverting it (after several games CPU usage goes up). I decided to fix with a third option, but this will also need testing, if it works for you, I will push this back into the stable release. I have tested this with a couple of games, playing with pause, resume, start over, play again, and it all seemed to work at first sight, but I might be missing something, so your input is welcome.

This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.
Comment 4 Anders Jonsson 2015-10-13 09:30:07 UTC
(In reply to Robert Roth from comment #3)
> Thanks for the heads-up, I have checked the commit, my mistake there, one
> regression applying it (pause resets the timer) and another one reverting it
> (after several games CPU usage goes up). I decided to fix with a third
> option, but this will also need testing, if it works for you, I will push
> this back into the stable release. I have tested this with a couple of
> games, playing with pause, resume, start over, play again, and it all seemed
> to work at first sight, but I might be missing something, so your input is
> welcome.

Thank you, works much better now on git master.


However, there is still one minor thing I noticed. When starting to count, the timer sometimes jumps two seconds as first time-step (for example 0:00 -> 0:02). This can happen on the start of the game or when resuming the game after pausing i, which makes the counting feel unsmooth. This does not happen every time.

If the latest fix and 0b7fde3400274cf7720d4a868718377487dd2ea2 is reverted I no longer see any two-second jumps.
Comment 5 Robert Roth 2015-10-13 09:39:25 UTC
Ok, reopening to fix 2 second jumps. Reverting the commit you mention would involve high CPU usage after several games, so I will work on improving the 2 second jumps, being the only issue with the current bunch of fixes. Thanks for testing.
Comment 6 Michael Catanzaro 2015-10-27 01:11:08 UTC
Would Timeout.add(1000, timeout_cb) would work just as well as Timeout.add(200, timeout_cb)? There is a precision cost to using Timeout.add_seconds (but a power-saving benefit).
Comment 7 Robert Roth 2015-10-27 11:07:00 UTC
(In reply to Michael Catanzaro from comment #6)
> Would Timeout.add(1000, timeout_cb) would work just as well as
> Timeout.add(200, timeout_cb)? There is a precision cost to using
> Timeout.add_seconds (but a power-saving benefit).

I can try with 1000 ms timeout, wanted to use something more precise, as 1000 ms could be a bit more than 1000ms, as far as I know, due to scheduling. If we can have the 1000ms timeout run once each second, I will be fine with that.
Comment 8 Robert Roth 2015-10-29 19:10:15 UTC
Ok, I have tested with 1000ms timeout, there are visible irregularities in counting, alias some intervals are shorter than one second, others are longer (trying pause/resume several times).
Setting the timeout to 500ms seems to work fine, being less frequent than the 200ms, more frequent than 1000ms/1s showing the counting irregularities, so I am marking this as fixed. If you see any other issues with the current timing, feel free to reopen.

This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.
Comment 9 Robert Roth 2015-11-02 06:39:39 UTC
*** Bug 757447 has been marked as a duplicate of this bug. ***