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

Fix clock display (regression from conflict resolution for #106) #128

Merged
merged 2 commits into from
Nov 28, 2023

Conversation

hartwork
Copy link
Collaborator

Regression from merge commit 95467bf related to #106.

# git diff 4901969fcebb0518f01932e7c7a2d38961d68b99 95467bf56dc23af61013c6ccc21791aba0a97569 | tail -n6

    redraw_and_continue:
-           time(&t1);  // to animate the clock display
            redraw_screen(errstr);
        }

@hartwork hartwork requested a review from edgar-bonet November 27, 2023 02:57
@hartwork hartwork changed the title Fix clock display (regression from #106) Fix clock display (regression from conflict resolution for #106) Nov 27, 2023
@edgar-bonet
Copy link
Collaborator

Thinking about this after a good night... it is not a good idea to depend on execution timing for a CI test to succeed. A better approach would be to remove the display of the time altogether, or replace it with a fixed, dummy string. For example, replace commit af9827c with something like this:

// In paint_plot:
if (!keep_time_fixed)
    asctime_r(lt, ls);

// In main:
keep_time_fixed = getenv("FIXED_TIME") != NULL;
if (keep_time_fixed)
    strcpy(ls, "Thu Jan 1 00:00:00 1970");

@hartwork
Copy link
Collaborator Author

hartwork commented Nov 28, 2023

it is not a good idea to depend on execution timing for a CI test to succeed

@edgar-bonet I would like to agree but:

  • unfortunately even without any clock display the CI will still rely on close-enough timing, e.g. without considering timing we could end up making screenshots right in the middle of a redraw and then we end up with a half-drawn screen and a mismatch in images; also
  • if we freeze or remove the clock, the CI can no longer catch when we break the clock next time, which already proved helpful once (except that it made us aware that the clock started moving again, but that's a detail). So we'd lose value.

I'm happy to sleep over this more, but right now I'm in favor of keeping a moving clock display. But maybe we can make the UI testing CI more robust some other way in a follow-up pull request? What do you think?

Regression from merge commit 95467bf:
> # git diff 4901969 95467bf | tail -n6
>
>  redraw_and_continue:
> -        time(&t1);  // to animate the clock display
>          redraw_screen(errstr);
>      }
>
@hartwork hartwork added this to the 1.6.0 milestone Nov 28, 2023
Copy link
Collaborator

@edgar-bonet edgar-bonet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even without any clock display the CI will still rely on close-enough timing [...] we could end up making screenshots right in the middle of a redraw

I didn't think about that. Actually, I don't event know how agg works. Ideally, it should be able to sync itself with ncurses' paint events, but I guess that's not easy...

On the other hand, I am planning to break this again in the future by making the clock display more “correct”, i.e. updating on the edges of system clock seconds.

Anyway, this PR is really not disruptive. Let's get it merged, even though we may have to rethink it later.

@hartwork hartwork merged commit 9870d5b into tenox7:development Nov 28, 2023
6 checks passed
@hartwork
Copy link
Collaborator Author

Anyway, this PR is really not disruptive. Let's get it merged, even though we may have to rethink it later.

@edgar-bonet thanks!

On the other hand, I am planning to break this again in the future by making the clock display more “correct”, i.e. updating on the edges of system clock seconds.

We can keep this for later, but if you feel like elaborating already now, I'd be curious to learn more about it.

@edgar-bonet
Copy link
Collaborator

My idea is to set the timeout as the time remaining until the next full second. This way pselect would timeout only at the most appropriate moment: right after the “seconds” digits of the system clock has changed. The clock will never be late, not even 0.2 seconds late, and there will be no “useless” redraws at all.

But yes, this will be for later...

@hartwork
Copy link
Collaborator Author

@edgar-bonet that is an interesting idea, but it seems to assume that the process runtime between pselect returning and the redraw of the screen would be exactly zero. Maybe it's close enough. it would allow us to sleep for up to a second, e.g. <=500ms more than currently. I saw the same idea as a bug in stresstest.c ealier but considered it good enough: The rate will be more exact the same way.

@hartwork hartwork deleted the fix-clock-display branch November 29, 2023 21:52
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

Successfully merging this pull request may close these issues.

2 participants