i3lock-color icon indicating copy to clipboard operation
i3lock-color copied to clipboard

Lag

Open sidequestboy opened this issue 5 years ago • 18 comments
trafficstars

I'm submitting a…

[X] Bug
[ ] Feature Request
[ ] Other (Please describe in detail)

Current Behavior

i3lock --clock seconds don't update at regular intervals, and sometimes skip seconds.

Expected Behavior

Seconds should update on screen at the correct intervals and not skip.

Reproduction Instructions

Run

i3lock --clock

and watch the seconds for half a minute, notice how they skip.

Environment

Output of i3lock --version:

i3lock: version 2.12.c.1 (2020-03-10, branch "tags/2.12.c.1") © 2010 Michael Stapelberg, © 2015 Cassandra Fox

sidequestboy avatar May 14 '20 01:05 sidequestboy

@jameh please update to the latest version (2.12.c.3) and see if the problem still exists. I just watched the clock for 75 seconds and there was no sign of skipping.

Raymo111 avatar May 14 '20 23:05 Raymo111

i3lock

I still get this behaviour on 9ada23e - note how it doesn't display 28 in this gif

sidequestboy avatar May 15 '20 00:05 sidequestboy

hmm. I'm not sure what's wrong. I certainly don't get any jumping

Raymo111 avatar May 15 '20 00:05 Raymo111

So, using --refresh-rate 0.1 seems to make the issue much less obvious, (it won't full-out skip numbers) but it still seems like it's got an uncanny lag.

sidequestboy avatar May 15 '20 01:05 sidequestboy

I honestly don't know what the issue is. If you restart your computer and just run startx i3lock --clock --noverify from a shell, does the lag continue?

Raymo111 avatar May 15 '20 01:05 Raymo111

If I log out and in to a tty and modify my xinitrc to end with

i3lock --clock --nofork

instead of my window manager, it seems pretty well-behaved, and doesn't skip full numbers. I still feel like one of the first few seconds lags though.

sidequestboy avatar May 15 '20 01:05 sidequestboy

Interesting. I also have that issue, but that's just lag at the beginning. I feel like the seconds skipping issue is something with your compositor. What wm/de are you on?

Raymo111 avatar May 15 '20 01:05 Raymo111

bspwm with compton tryone fork.

sidequestboy avatar May 15 '20 02:05 sidequestboy

I just tested without compton running, I still get a skipped number and a noticable lag in the first few seconds while launching from bspwm.

sidequestboy avatar May 15 '20 02:05 sidequestboy

But is there any lag over time? (Or just at launch)

Raymo111 avatar May 15 '20 02:05 Raymo111

The skipped numbers happen kind of irregularly, and about every 2 minutes maybe?

I just watched for 2 minutes with a metronome at 60bpm without compton running, I noticed a lag in the 2nd second, then pretty regular, I felt like it was pretty much in sync with the metronome for 2 minutes, then it displayed the same number twice in a row and continued, then skipped a number about 5 seconds later.

sidequestboy avatar May 15 '20 02:05 sidequestboy

Hahahahaha I'm reopening this issue just cause you sat there with a metronome. Talk about dedicated. Suggestions as to what might be a generic lag issue?

Raymo111 avatar May 15 '20 02:05 Raymo111

So, I found the option --redraw-thread:

Starts a separate thread for redrawing the screen. Potentially worse for security, but makes the bar indicator still do its usual periodic redraws when PAM is authenticating.

And I don't notice any jankyness when run with that (watched it for a minute lol) - do you have any idea why this is "worse for security"?

sidequestboy avatar May 15 '20 02:05 sidequestboy

Hmm, interesting. I have no idea. Maybe have a look at the code and history to see who added it? Maybe that commit will have more info. Also that's probably an upstream thing, so you'll wanna check i3/i3lock too.

Raymo111 avatar May 15 '20 03:05 Raymo111

So, it's commits 3edfb79f96254e93e5c98d54add290e789cfb60d and 59cdccb3e510c5d393cab9656b8a30efd37b45e6 which add the render thread option, which was after the fork, and i3/i3lock doesn't have either the --redraw-thread option or the --clock option, so the issue is specific to this fork. But yeah, the --redraw-thread option seems to hide the issue.

The security concern seems to be about the render thread crashing

commit 59cdccb3e510c5d393cab9656b8a30efd37b45e6 Author: Pandora [email protected] Date: Fri Dec 8 02:29:05 2017 -0500

make render thread optional

theoretical potential security concerns; no use unless using bar and you care... I hammered pretty hard on my kb for a while to try and see if it's possible to configure it poorly and get the render thread to crash, but to no avail.

sidequestboy avatar May 19 '20 08:05 sidequestboy

Interesting. @jameh I've got no idea why that's a security risk. @PandorasFox wanna weigh in on this?

Raymo111 avatar May 19 '20 20:05 Raymo111

so, primarily - I never really tested it that much and I'm not entirely confident in its safety (e.g. I probably clowned something up in a subtle way that can cause all threads to crash/exit). It's probably fine in general, though.

iirc the reason for the slight accruing lag over time is caused by a single redraw taking longer than a second. there's a lot of ways that this could potentially be optimized (e.g. identify the region of the screen that has to be redrawn, organize the different canvases better so that it's faster to composite them together, etc) but frankly I never had the time to sit down and refactor all that

PandorasFox avatar May 19 '20 21:05 PandorasFox

Ahh. Thanks. @jameh you should be ok using --redraw-thread then for now :)

I'll optimize this some day based on fox's suggestions

Raymo111 avatar May 19 '20 22:05 Raymo111