UI race conditions
I’m sure this has happened to you once in a while: You’re doing several things at the same time on the computer, e.g. perhaps you click to launch some slow program, and while that is launching you go over to your web browser to kill a few seconds reading something. You try to click a link, but oops – just when you were about to click it, the other program finishes loading, and you have accidentally clicked something in it.
A variation of that happened to me just today. I decided to try Yahoo Chess (and I’m proud to say I won my game). You enter a room, e.g. the beginner room, and then there is a list of tables; you click to join a particular table. But every few seconds, the list of tables keeps refreshing, so the button you were about to click could have suddenly disappeared — or worse, turned into a button for a different table you didn’t intend to join.
What’s interesting to me (I don’t know why, maybe because I’m a geek) is that this is a real-life version (if using the computer is considered real life) of the sort of race condition horribleness we all run into when we write multithreaded code. Thread 1 tries to increment a variable, but oops, thread 2 sneaks in there and changes it! Urgh.
Does this ever come up in real real life (as opposed to real life while using a computer)? Yes, of course — one good example is the awkward little dance we all do once in a while when trying to walk past someone else who is coming the other way. Both step to the right, oops, both step to the left, oops!
In the case of computer UI, I can think of two ways to alleviate this problem (I am not claiming any incredible insight here, I think these are pretty obvious):
- Animation can help. E.g. in the example of the Yahoo Chess list of tables, when the list redraws, rather than having it redraw instantly as it does now, maybe the individual rows of the list should slide to their new positions. That gives a person’s eye the visual feedback, “Wait, don’t click just now.” Animation is sort of the computer equivalent of what usually helps avoid this problem in real-life scenarios: Most of the time, the fact that you can see the other person moving and adapt to their movement gives your brain enough time to avoid a collision.
- Maybe disable the mouse (and keyboard if appropriate) for a fraction of a second, e.g. maybe 1/4 second, immediately after a change, e.g. immediately after the list of chess tables was updated, or immediately after a program opens a new window or dialog.
Of course, it would often be appropriate to combine both of those techniques: disable the mouse, do the animation, and then re-enable the mouse. If done that way, the mouse could be immediately re-enabled when the animation was done — no need to wait for 1/4 second more after the animation is done, because the person has already had sufficient time to process what is happening and avoid an accidental click.
What do you think? I’m sure none of this is terribly original — I imagine lots of research on this topic has been done. I just haven’t come across it. (Sometimes blogging scares me, because the Internet is so huge that no matter how original a particular thought of mine might be, the odds are extremely good that someone else has already had it, and has said it on the Internet, and thus it’s already in the Google index, and so should I really bother. Reminds me of a joke that A. Whitney Brown made many many years ago in Saturday Night Live: “There are a billion people in China. Think about that. That means if you’re a one-in-a-million kind of guy, there are a thousand other people exactly like you.”)
Comments(6)
I’m always a bit uncomfortable when it comes to doing stuff with the mouse. I think users think of it as completely hardwired to them, and not under software control at all. Ignoring mouse clicks I think would just end up feeling like a bug. Animation seems like a better solution.
I think a best way to do this would be to activate the electroshock feature that most mice should have – touch the button, get a big shock to your hand, and users will learn to be well-behaved :-).
I think better UI design would help this situation. In the case of the Yahoo chess games, a better option would be to disable the click on that game for a moment and then have the game disappear. Perhaps the list could fill in empty spots and then add "new" spots to the bottom of the list. As far as one program coming up on top of another — I have had this happen where I have pressed a button on a confirmation window that I didn’t even read because I was clicking something else. The "fix" for this, I think, would be for an message box to not come from one program on top of another but rather the Windows task bar blink to let you know a message is "waiting" for you.
I don’t see any problem with temporarily disabling the mouse as long as it’s accompanied with an appropriate mouse cursor that indicates it’s disabled.
Another possible solution would be to either scroll the window or move the mouse so that the mouse stays over the same element. This could be very disconcerting, so it should probably only be done in the case that there are mouse click events while the view is updating.
Hey get this: The United States of America exists because of a race condition!
Yeah, King George finally agreed to the demands of the colonists to end taxation w/out representation and all that stuff. But by the time his communication reached America (3 months by boat), the British already got their clocks cleaned.
I think it’s totally wrong for anything to popup something in the middle of what you’re doing. Every time it does that, I look at my screen and I say "you had all that real estate on my screen, and yet you chose to disrupt what I’m doing by popping up in the one place where I was working!"
So if you write things that popup in front of the user, try to remind yourself that your opinion of what should be in front of the user at that moment is not as important as the user’s opinion about what should be in front.
Have you ever had a coworker step right in front of you, blocking what you are doing just to tell you that the printer is out of ink?
The "originality" question is an interesting one. I remember when I was in college a friend on AOL IM asked a similar question about his existence and thoughts. So at least the questioning part of your blog posting is not original. However, I believe that the focus may be on the wrong track. It is not whether your idea is original, but whether your implementation is. What I am trying to say is it is important to take risks and to finish things, and ideas are only the first step.
I also find it very understandable to say that parts of one’s life is not real, or something that exists in the "real world." However, computer interactions are real, so is school life. I guess it is all in the manner in which you live. Are you acting differently because the world is more insulated from you because you are writing on a computer screen?
I like being exposed to the idea that inadvert actions to an open internet window may show how our inadvert actions (i.e. cutting someone off in traffic, doing the hallway tango with a co-worker) can have "real" consequences.
I’m in the no-disable boat, personally. The problem could be more properly solved by writing code with less bloat and better UI design from the start
- Wait until the view is compiled before attempting to draw it.
- Load the view before the corresponding click-map.
- Give the user appropriate feedback when activity is being processed to allow them to make an intelligent choice about whether they should be clicking or not.
Just my two-cents.