News for hackers. Stuff that matters.
Re:GNOME has no thumbnails in the file picker and my toilets... by ht85 on Sunday January 10, 2021 @05:11PM (#25720610)
Let's do another... Open any directory with 3+ items. As first item is highlighted, quickly hit <down arrow>, <enter>, <down arrow>. The 3rd item opens...

There is a lag when hitting <enter> and the last <down arrow> is processed out of order :/

Re:GNOME has no thumbnails in the file picker and my toilets... by buckminster on Sunday January 10, 2021 @05:30PM (#25720842)
This is bad but it's not unusual. There are similar issues in Firefox and Windows. Nobody gets UI asynchrony right. There are race conditions in everything. It's particularly noticeable with a slow computer.
Re:GNOME has no thumbnails in the file picker and my toilets... by danaliv on Sunday January 10, 2021 @05:32PM (#25720861)
I promise you people have gotten this right. I have a 198? Mac Plus on my desk that I can boot up and do this on and it will work properly. I’m having trouble even imagining the insane event-processing architecture that results in keystrokes being processed out of order.

Edit: Alright, alright, forget the old computer. My new ones get it right too. All of which is a red herring, because the point is this behavior is ridiculous and never should’ve shipped.

Re:GNOME has no thumbnails in the file picker and my toilets... by ivanbakel on Sunday January 10, 2021 @05:38PM (#25720931)
>I’m having trouble even imagining the insane event-processing architecture that results in keystrokes being processed out of order.

It's relatively simple: the picker executes file-opening asynchronously, and only checks which file was selected at some indeterminate point after enter is pressed. In the meantime, the down arrow input in the main GUI changes the selection. The keypresses are always in order.

Whether or not that's the correct decision, it's not an inconceivable design. That example is probably one of the only times it would matter, since you would need async code that cares about some part of the file picker state.

Re:GNOME has no thumbnails in the file picker and my toilets... by userbinator on Sunday January 10, 2021 @06:15PM (#25721401)
To sound like Linus Torvalds, "that's braindead stupid!"

I have never looked at the code in question, but it almost sounds like the developers went out of their way to create these ridiculous bugs, because the simplest solution definitely would not have something like that happen: The handler for Enter gets the current selection (which will definitely be the correct one) and opens it.

The actual opening can be slow, so that can be done asynchronously. But to interpret "Enter opens the current selection" as anything other than the current selection at the time the Enter key event was received is definitely in the realm of rookie mistake if not worse.

If getting the current selection of a UI control somehow needs to be done asynchronously, then something is seriously wrong.

As a long-time Win32 programmer, the manifestations of these bugs are definitely hard to conceive.

Re:GNOME has no thumbnails in the file picker and my toilets... by stelonix on Monday January 11, 2021 @01:41AM (#25725490)
This is an issue with X11 which I don't know exactly where it comes from and what causes it. Yes, it has to do with the async nature of it all and I agree it's stupid and it's a miracle the desktop even works. Over time, I've been wondering if Windows dodges this simply by having syscalls that interface with window procedures while Xorg deals horribly with it by being pure userland. Another issue is, there's no mapping of pid <-> X11 window. It's simply impossible with the current design of client-server.
Re:GNOME has no thumbnails in the file picker and my toilets... by account42 on Monday January 11, 2021 @04:27AM (#25726608)
> This is an issue with X11

What makes you think this is the case? X11 has an ordered event queue and there is no reason an application can't process the keystrokes in the correct order.

> Another issue is, there's no mapping of pid <-> X11 window. It's simply impossible with the current design of client-server.

What do you need this for? There is _NET_WM_PID [0] which can be set by clients.

[0] https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.h...

Re:GNOME has no thumbnails in the file picker and my toilets... by stelonix on Monday January 11, 2021 @03:56PM (#25736752)
_NET_WM_PID is optional, some clients do not set it and even then afaik the server doesn't do any sanity check and the client can set it to anything, making it inherently insecure. This is not good design.

> What makes you think this is the case? Many other ways in which async behavior happens on X11, on any machine I've tried, with the mouse cursor lagging to register a click event, for example.

Re:GNOME has no thumbnails in the file picker and my toilets... by getitstraight on Tuesday January 12, 2021 @03:30AM (#25743896)
> 'What makes you think this is the case? X11 has an ordered event queue and there is no reason an application can't process the keystrokes in the correct order.'

Frankly, it is completely fucking unacceptable for software to miss keystrokes or read them out of order. This is basic programming 101. Any code which exhibits such a problem has a shit design and needs to be rebuilt from scratch.

This sort of thing is exactly what drove me away from the mainstream Linux distros, to create my own from scratch. If and when I ever happen to boot up something like Linux Mint and use it, (shudder,) the sluggishness of gnome3/cinnamon/whatever and all the other bloatware running on the system is readily apparent. My system is always FAST and snappy. Input lag or missed keystrokes? Not on your life.

Reading through the HN comments on articles having to do with speed, snappiness, responsivness of a UI, and excessive bloat of software, it occurred to me one day that these kids (here's the root of the problem) don't actually have a clue that things could be any different than they are. And that's why we're stuck here.

They have literally grown up with slow, bloated shitware for their entire lives, so they actually think all the bloat and slowness is normal and necessary.

Notice how the GP blames X11? They grasp for excuses rather than exercising deep thought, while demonstrating low standards, complacency, and laziness. This is what happens when the common masses take over anything. Shallow thinking and low standards prevail.

These kids have a false conception that doing away with the bloat would mean losing a bunch of features. But in reality we could indeed have fast, responsive, light weight systems, with all of the same features and even more, if only programmers cared enough, or were talented enough to write good software.

Re:GNOME has no thumbnails in the file picker and my toilets... by stelonix on Tuesday January 12, 2021 @04:26AM (#25744327)
I'm not a Wayland user and do not plan to be. Instead, it is a criticism of the current abandonment of the Xorg project, which I toy with the code from time to time. I also do not use any DE and use X in the leanest way I can, and I still notice such input lag, whether it's playing games or some gui application seeming to register input at a different x,y position than it was clicked. This does not mean I'm a xorg hater, quite the opposite. Studying the codebase, it seems pretty well written and documented and it proved me the "X is unmaintainable" mantra is a lie. I can elaborate more on other issues of the async & client-server nature of X. I'm not spouting nonsense.
Re:GNOME has no thumbnails in the file picker and my toilets... by josefx on Tuesday January 12, 2021 @06:13AM (#25745309)
The problem is that neither latency nor async would explain out of order arrival of events. So even now your explanation seems nonsensical.
Re:GNOME has no thumbnails in the file picker and my toilets... by getitstraight on Tuesday January 12, 2021 @02:10PM (#25751826)
I believe the entire point of Wayland was to pull away talent from Xorg development, to keep people in a quagmire for a decade plus working on that junk instead of fixing up Xorg to be what it should be.

Just like how the entire purpose of a certain very Gimped graphics editor was probably to occupy and exploit people who could have worked on some better project. It seems to have worked for a long time; only now after many years do we finally have Krita, but it's KDE only.

It's obvious microcomputer UNIX has been under assault for a long time by those who don't want the dream of a free, open desktop to be realized.

Re:GNOME has no thumbnails in the file picker and my toilets... by stelonix on Tuesday January 12, 2021 @04:25PM (#25753957)
I do agree that there's a spread of FUD regarding X11 and its code but I believe we can win this fight if we're interested in fixing X's shortcomings and making the leap to "x12" or whatever you wanna call it. Don't know anyone else who delves into the codebase though.
Re:GNOME has no thumbnails in the file picker and my toilets... by josefx on Monday January 11, 2021 @07:15AM (#25727904)
> there's no mapping of pid <-> X11 window

There is a standard window property that anyone can set and that any halfway sane UI framework sets. I ran into maybe one that didn't and even then it was five lines of copy/paste code to add it.

Re:GNOME has no thumbnails in the file picker and my toilets... by thaumasiotes on Sunday January 10, 2021 @06:15PM (#25721402)
> Whether or not that's the correct decision, it's not an inconceivable design.

I'm having trouble with the part of the design where we recognize that a file is selected (such that pressing <enter> causes a file to open), see the <enter> keypress, and then fire an event saying "open any file, whichever one you feel like" as opposed to "open this file right here, the one we can see is selected".

If, as you maintain, the keystrokes are processed in order, then at the time <enter> is processed, we specifically take notice of which file is selected. (Because, as I said above, we only know that <enter> should open a file at all because we see that a file is selected.) We fire the file-opening event after that. This isn't a mistake we can make by accident; we'd have to be making it on purpose.

I can see where the assumption that the keystrokes are being reordered comes from; it's much less insane than what you're proposing.

Re:GNOME has no thumbnails in the file picker and my toilets... by ivanbakel on Sunday January 10, 2021 @06:22PM (#25721490)
Because the event says "open the currently selected file", not "open this file because it is the selected one". If the event is processed asynchronously w.r.t. other events which can modify the selection, you can get buggy behaviour.

I don't find such a design that surprising. If you like simplicity, you would be tempted to go for it, because it doesn't involve duplicating data (namely, the selected filepath) between the main GUI state and the event handler for opening the selected file. If you're writing in a memory-managing language like C, it's even more tempting - by not copying data, you don't risk forgetting to free it later.

Re:GNOME has no thumbnails in the file picker and my toilets... by polynomial on Sunday January 10, 2021 @08:21PM (#25722940)
This is a great example of where OOP and FP necessarily part ways.
Re:GNOME has no thumbnails in the file picker and my toilets... by FridgeSeal on Monday January 11, 2021 @08:37AM (#25728681)
That’s a cool idea, how so?
Re:GNOME has no thumbnails in the file picker and my toilets... by polynomial on Wednesday January 13, 2021 @01:15AM (#25758820)
I'm sure there are far more qualified hn users than I to elaborate, but basically you wouldn't have a dependency on an mutable object. Rather, the object would have to be directly passed to a function.

Having said that, I meant it more generally in the sense of their respective architecture design paradigms than details of a particular implementation.

Re:GNOME has no thumbnails in the file picker and my toilets... by freeone3000 on Sunday January 10, 2021 @05:58PM (#25721199)
Why does the enter keypress save the relative index instead of the actual target of the action? Even Windows gets this one right.
Re:GNOME has no thumbnails in the file picker and my toilets... by ballenf on Sunday January 10, 2021 @05:55PM (#25721155)
Why wouldn't the <enter> key interrupt or freeze the keypress queue? I don't think you need some advanced async logic to get this right.

The only potential downside would be if people expected to be able to cancel the <enter> action. But that would be unusual, I think.

Re:GNOME has no thumbnails in the file picker and my toilets... by ivanbakel on Sunday January 10, 2021 @06:15PM (#25721400)
As a rule of thumb: if you ever ask "why not", and the alternative you're proposing is more complicated - that is normally why not. Lots of UI/UX bugs can simply be attributed to the programmer taking the most simple possible design.

In this case, the async logic is not advanced. In fact, I'm willing to bet that this is what happened: at first, the file-opening was synchronous in the GUI. People complained that opening certain files locked up the file picker, so a developer sticks the file-opening code in a background thread. This produces the above bug, without complicating the input design - in fact, preventing the bug requires making additional changes to the code in some way.

Re:GNOME has no thumbnails in the file picker and my toilets... by ballenf on Monday January 11, 2021 @09:43PM (#25741586)
Thanks that makes total sense. And a good rule of thumb for me to remember.
Re:GNOME has no thumbnails in the file picker and my toilets... by toast0 on Sunday January 10, 2021 @07:08PM (#25722044)
You can't do work on the UI thread, it'll block the UI! With only half a /s
Re:GNOME has no thumbnails in the file picker and my toilets... by imtringued on Tuesday January 12, 2021 @04:28AM (#25744348)
>Whether or not that's the correct decision, it's not an inconceivable design.

It's easy to imagine. Someone kept a variable for the current selection and instead of copying it during the enter event they just read it when the delayed action happens. It often takes time for a second window to open or a page to load. If that new window references the current selection you are going to run into bugs.

It's a design that has caused many video game exploits. You can do impossible things like disassemble a Fat man barrel and put it on a pistol in Fallout. You will get a rocket launcher that has the fire rate of a pistol except it shoots nukes and only uses bullets as ammo.

Re:GNOME has no thumbnails in the file picker and my toilets... by viraptor on Sunday January 10, 2021 @05:42PM (#25720985)
That Mac cannot multithread the UI interactions. It doesn't have to be a keystroke processing issue. It can be "hey window parent, I've got your result in my properties, pick it up" which doesn't get processed before the next event changes the related property.

It's almost a classic TOCTOU issue.

Re:GNOME has no thumbnails in the file picker and my toilets... by edoceo on Sunday January 10, 2021 @06:55PM (#25721886)
Re:GNOME has no thumbnails in the file picker and my toilets... by buckminster on Sunday January 10, 2021 @05:41PM (#25720967)
All old computers get it right. They are not doing UI asynchrony. It's a fairly recent problem.
Re:GNOME has no thumbnails in the file picker and my toilets... by danaliv on Sunday January 10, 2021 @05:42PM (#25720988)
My new computers get this right too. This is a design flaw.
Re:GNOME has no thumbnails in the file picker and my toilets... by mkl on Monday January 11, 2021 @01:53AM (#25725574)
Keyboard maybe. That same old Mac probably processes mouse events out of order: when it was being slow you could click on something then move the mouse somewhere else, and it would click the new place instead.
Re:GNOME has no thumbnails in the file picker and my toilets... by masswerk on Monday January 11, 2021 @01:42AM (#25725503)
However, the Mac was about the only system getting this right by rigorously prioritizing UI events on the system level.

(Which is also, why applications like Photoshop on Windows weren't a viable option for professional users for some time, until hardware became faster. How do you draw or paint, if the events representing your gestures are not synchronized, as they are subject to system load?)

Re:GNOME has no thumbnails in the file picker and my toilets... by Ndymium on Monday January 11, 2021 @03:32AM (#25726244)
LibreOffice had (has?) a similar strange race condition when typing. When the computer was acting slow and LibreOffice Writer was lagging, the Finnish layout's characters äöå would jump to the front of the typing queue somehow. So if I typed "menkäämme", I might get "äämenkmme" when LibreOffice finally renders the typed text. I don't know if it still occurs but it was really annoying and I always wondered how on earth it could happen.
Re:GNOME has no thumbnails in the file picker and my toilets... by jfoster on Sunday January 10, 2021 @06:24PM (#25721525)
It's akin to typing and having the characters appear out of order, isn't it? Are those particular keys more difficult to process?
Re:GNOME has no thumbnails in the file picker and my toilets... by efreak on Sunday January 10, 2021 @09:16PM (#25723468)
Only if each key has its own function to process that keystroke, and some keystrokes had to do more processing and thus take more time about it. Selecting an item in a list view is a fast, simple process; what happens after that isn't up to the list view anymore.
Re:GNOME has no thumbnails in the file picker and my toilets... by j1elo on Monday January 11, 2021 @04:15AM (#25726536)
Assuming an asynchronous UI programming model, I can only conceive this happening because they skipped having a proper Model and instead the View is accessed directly (in the Mode-View-Controller way of thinking).

However the most disturbing thing is that events might get to be processed our of order. Even if you stored current state in a proper Model, there is nothing you can do if your event queue ends up being "<down>, <down>, <enter>".

I guess that's why Qt prefers to do all UI event processing exclusively in a single thread. The event queue will always be serviced in order.

Re:GNOME has no thumbnails in the file picker and my toilets... by tomsmeding on Sunday January 10, 2021 @05:43PM (#25720996)
Incidentally, that lag is there independent of how fast your disk is, it seems. It's kind of annoying.
Re:GNOME has no thumbnails in the file picker and my toilets... by formerly_proven on Sunday January 10, 2021 @06:18PM (#25721457)
That's likely the fault of the GVFS and other virtual-fs-on-top-of-kernel-VFS layers. Gtk seems to be slower than others (such as KIO/KDE), but all of them are pretty slow. E.g. the KDE file picker takes about a second or so to finish listing the contents of my home directory (though it is usable while it is doing so, unlike the Gtk dialog), where the Gtk takes quite a bit longer (perhaps on the order of 3-5 seconds). Meanwhile ls is essentially instant, as you'd expect for just a few thousand files or so.
Re:GNOME has no thumbnails in the file picker and my toilets... by ubercow13 on Sunday January 10, 2021 @06:36PM (#25721651)
KIO is pretty fast I think. Dolphin is insanely fast at least - if you list a large directory almost everything that can't be loaded instantly is loaded asynchronously and streamed in to the UI after the UI becomes responsive. I think the KDE file picker is using other code altogether, I'm not sure why it's so much slower. GIO is horribly slow and makes everything that uses it next to useless, eg [1]

[1] https://github.com/lxqt/pcmanfm-qt/issues/462

Re:GNOME has no thumbnails in the file picker and my toilets... by InfiniteRand on Monday January 11, 2021 @09:07AM (#25728989)
Interesting explanation at the end of the bug report:

The slowness is only caused by the GIO's G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE and g_file_info_get_content_type. Wherever they are used, there will be a slowdown because the contents of files, that lack extensions, should be read for finding their mimetypes. Almost all the time is taken by that; the other operations are done pretty fast — particularly, the Qt GUI takes no time in comparison.

Re:GNOME has no thumbnails in the file picker and my toilets... by ubercow13 on Monday January 11, 2021 @01:15PM (#25733185)
Yes, actually reading that it makes it sound like the file manager itself is just badly architechted - of course you shouldn't load mimetypes synchronously before listing a folder in the UI, that seems obvious.

So maybe I'm not right about GIO as such. But Nautilus is also excruciatingly slow despite being more fully asynchronous.