lichess-org / lila

♞ lichess.org: the forever free, adless and open source chess server ♞
https://lichess.org
GNU Affero General Public License v3.0
15.54k stars 2.27k forks source link

Game start notification sound plays too late #11596

Closed JakeQZ closed 1 year ago

JakeQZ commented 2 years ago

Exact URL where the bug happened

https://lichess.org/

Steps to reproduce the bug

  1. Create a private tournament
  2. Join it
  3. Have another player join (using link you sent them)
  4. Wait until you are paired and a game starts

What did you expect to happen?

The game start alert sound plays as soon as you are paired, when the web app first switches to showing your new game with the board in the starting position, when you have 20 seconds to make your first move (or lose the game), so that you are alerted that the game has started in case (as is likely) you'd been doing something else whilst waiting.

What happened instead?

The game start alert sound does not play until you've made your first move - whether you are playing white or black.

Operating system and browser version

Windows 10 Home, 21H1, 19043.2006 Firefox 105.0 (64-bit)

Please note

  1. This is a regression. The expected behaviour (as described above) was the case until around some time in August.
  2. As a result of this, we are finding many more games failing to start, with victories and rating points being awarded randomly but favouring those who are just starting at their screen while waiting to play, or who have a second monitor they can use for other activities whilst waiting, as opposed to being based on actual chess prowess.
  3. The severity and urgency for this issue should be high. Whilst not everyone has sound on, most do, and we have become accustomed to relying on it to let us know when we have been paired and need to make our first move. Have you noticed an increase in failed starts recently? This bug perhaps explains why.
TBestLittleHelper commented 2 years ago

Can you try this? It's likely that your firefox settings are the issue here.

https://lichess.org/forum/lichess-feedback/no-sound-because-audiocontext#6

JakeQZ commented 2 years ago

Can you try this? It's likely that your firefox settings are the issue here.

That sounds like (pardon the pun) it's the issue. Thanks. I've changed the setting and will confirm when we play next Thursday.

In the meantime, can we file a bug against Firefox (on Bugzilla)? I'm happy to try that, though no doubt they'll say they they made the change for "security reasons". (They keep making these sort of changes that make the browser less usable, yet still don't get round to fixing bugs over 20 years old. Do they really want everyone to use Chrome instead?)

In expectation of the result of the above (it's probably in the W3C pipeline anyway), should Lichess put up a dismissable notice to instruct users to change their settings so that they can still get a sound alert on game start?

Will let you know if the above setting change resolves the issue this time next week. (Remind me if I forget.)

PS. I've previously gone via the forums initially, but never had a response. Also, the search function there is not very good. So I'd rather not waste my time there for pertinent issues, and doubt I'd have found your post about this however hard I searched. Sorry.

JakeQZ commented 2 years ago

If I start playing audio on one tab, and switch to another, the audio carries on (except for sites like YouTube which detect loss of focus, because it means you won't see their ads). Surely Lichess can open a permanent audio channel (mostly silent) to avoid this problem? (I know it's utterly silly what Firefox and W3C are doing - just making developers jump through hoops, and wasting all our time.)

benediktwerner commented 2 years ago

This only works when you stay on the same page. When a game starts, you're on a new page.

PS. I've previously gone via the forums initially, but never had a response. Also, the search function there is not very good. So I'd rather not waste my time there for pertinent issues, and doubt I'd have found your post about this however hard I searched. Sorry.

I've probably seen at least 5 different forum posts about the issue with answers pointing out the solution and the search function finds most of them: https://lichess.org/forum/search?text=game+start+sound

JakeQZ commented 1 year ago

Can you try this? It's likely that your firefox settings are the issue here.

https://lichess.org/forum/lichess-feedback/no-sound-because-audiocontext#6

It seems the permission setting has been reset by a Firefox update, so I've had to change it again.

JakeQZ commented 1 year ago

Can you try this? It's likely that your firefox settings are the issue here. https://lichess.org/forum/lichess-feedback/no-sound-because-audiocontext#6

It seems the permission setting has been reset by a Firefox update, so I've had to change it again.

The permissions have reset themselves again. This is not a viable solution.

schlawg commented 1 year ago

Not viable?

JakeQZ commented 1 year ago

Not viable?

Doesn't work. Unless you remember to change the setting every time you play (and how to do it), which is a bit of an imposition.

JakeQZ commented 1 year ago

The 20-second game-start timeout continues to be a major issue for us, because players are not adequately alerted that their game has started. See also #11601.

schlawg commented 1 year ago

Well that really stinks. I wonder if a push notification would work around this? There is a bunch of code in an upcoming (imminent) PR that lets you configure whether or not you want browser push notifications for various events (inbox messages, challenges, etc) and I could certainly add tournament game about to start to that list.

This would result in an OS/browser style notification badge appearing in the upper right that, when clicked, would take you to the tournament game. The downside is that users must allow push notifications from lichess.org to get them.

Thoughts?

JakeQZ commented 1 year ago

I wonder if a push notification would work around this? ... I could certainly add tournament game about to start to that list.

Thoughts?

I think that may be the best way forward. Social media sites like Facebook use these, though I've always rejected them, because I don't want their notifications. I think it would need to be configurable so that the user can, for example, select only to receive game start notifications. I've no experience of how these work, but assume that the browser needs to be open though not necessarily in the foreground, and they will appear like new mail notifications do for some email clients.

I'd still like the option to disable the game start time-out for private tourneys - so after 15/20 seconds, the player's clock just starts running down, rather than them losing outright. In our private tourneys we only have around 4-6 players, so there is often a wait between games in which players start doing something else, but don't pause because they don't want to miss out on a game as soon as someone becomes available. Then they miss out anyway and get penalized.

I tried restarting Firefox and found the setting still persisted. But twice now it has been reset to the default for some reason. I might log a bug on Bugzilla, if you think it's worth it, but doubt it will get much traction, as it would be hard to define the steps to reproduce.

schlawg commented 1 year ago

Now that I've looked at this a push notification doesn't make sense. They share site permission with the existing notification you get when the tournament is backgrounded, so unfortunately they would have the same drawbacks for you.

Seems like the only thing that makes sense for you would be a configuration option for the first move timer. If there's not already a feature request for that, you should make one.

JakeQZ commented 1 year ago

Now that I've looked at this a push notification doesn't make sense. They share site permission with the existing notification you get when the tournament is backgrounded, so unfortunately they would have the same drawbacks for you.

Yes, from reading how the Push API works, it seems it would be running a background listening service even when the browser is closed. It's a shame there doesn't seem to been an API or other simple solution more suited to when there are multiple tabs/windows of the app open at once, rather than when the app is closed. (I guess the music player apps implement their own inter-tab comminucation mechanism.)

The autoplay permission has held out for a few weeks now. I don't know why it seemed to have reset itself at least twice in the past.

Seems like the only thing that makes sense for you would be a configuration option for the first move timer. If there's not already a feature request for that, you should make one.

OK, I'll have a look. An option that might be useful for a tourney with friends would be to allow either player to abandon the game (so it doesn't count to the tourney or rating) after their opponent has failed to make their first move in time, but not to automatically time them out.

JakeQZ commented 1 year ago

More issues with the UX in a small (e.g. 6-player) tournament:

Scenario: Player without sound gets bored of waiting for a pairing, even though it seems 3-4 players are available and not paused. They look away from their screen to do something on their phone for 20-30 seconds. During that time, the system decides to pair them with one player who has become available, but the game fails to start and they are awarded a loss. In that time, other players have been paired or decided to call it a night (and paused themselves). Now the system will not pair those two players again, because it thinks they've just played each other (even though they haven't, because the game was not started) and there are enough other players who it thinks might become available soon. A frustrating experience.

If some if these secondary issues could be fixed, the game start timeout would be less of a problem (though still an unwanted annoyance in tourneys with friends).

JakeQZ commented 1 year ago

12749

Pretty sure today I had Lichess in the foreground, but was replying to a message on my phone when I missed the game start (i.e. just happened to be looking away from the screen at the wrong time). Incredibly frustrating for everyone, and skews the results.

mageshkumaar commented 1 year ago

I'd like to also say that this happened to me today and was about to file a bug and found this existing bug.

I was not playing in a any tournament and it was a regular 10+0 game in the home page and the sound was not played because I was in another tab analyzing my previous game.

JakeQZ commented 1 year ago

Pretty sure today I had Lichess in the foreground

Yep. Can confirm that in the current version of Firefox, even if the tourney tab is (or a single lichess tab for an individial game) is in the foreground and the only lichess tab open, the game start sound doesn't play until you make your first move (even if you are black).

So it's no longer a game start notification sound. It's now a 'you've made your first move' sound effect.

benediktwerner commented 1 year ago

See the link in the first comment posted by TBest. This is caused by Firefox blocking the sound until the first user interaction. As far as I'm aware, there's nothing Lichess can do against this. You need to add an exception for Lichess in the Firefox settings or I guess use another browser or convince Mozilla to change this behavior.

JakeQZ commented 1 year ago

This is caused by Firefox blocking the sound until the first user interaction.

That doesn't make sense, in multifarious ways. The lichess tab was active and I had interacted in the previous game. I hadn't switched away.

You need to add an exception for Lichess in the Firefox settings

I have tried that several times. It keeps getting reset back to the default.

image

IIRC it's the 'Autoplay' setting that needs changing.

However, I think there is a technical design flaw with the way lichess uses audio. Board Game Arena does not have this problem: the game sounds play even if you are on another tab. Are you trying to stream audio when you should be using individual sound 'effects'? Maybe try to figure out what BGA do (perhaps ask them if you have a contact there), and do that.

benediktwerner commented 1 year ago

That doesn't make sense, in multifarious ways. The lichess tab was active and I had interacted in the previous game. I hadn't switched away.

Whether the tab is active is completely irrelevant. Firefox does this to combat auto-play of ad videos and the likes so what matters is whether you interacted with the page. And the previous game is a different page.

This has nothing to do with incorrectly playing the audio as plainly evident by the fact that adjusting the Firefox setting fixes the problem.

BGA seems to be a single-page application which never actually loads a new page and just changes the displayed content. This is not how Lichess works.

And the setting resetting sounds like a Firefox bug. You can report Firefox bugs here: https://bugzilla.mozilla.org

schlawg commented 1 year ago

@JakeQZ, did the recent change to beep at pairing rather than game start address this issue for you? I'd like to close it if possible.

JakeQZ commented 1 year ago

@JakeQZ, did the recent change to beep at pairing rather than game start address this issue for you? I'd like to close it if possible.

Sorry, that won't help. This issue is when you have multiple lichess tabs open while waiting to be paired, and are viewing one other than the tournament lobby. The scenario arises when you get bored of waiting to be paired, and look at a previous game in a new browser tab. When you are finally paired, the game starts in the browser tab opened on the tourney lobby, rather than the one currently viewed.

I think this needs a redesign, and thus should not be closed.

Sites like Spotify seem to manage inter-tab communication, though I don't kniw how. Lichess must, at a minimum, start the new game in the currently active lichess tab, whatever that is.

PS. We also need a setting, for private tournaments, to increase the game-start timout to several minutes.

schlawg commented 1 year ago

We fixed the issue you described. Feel free to reopen a related one with additional information if you have a more specific failure on the current production build.

[edit] Also, we would never open a new game in an unrelated tab just because it's active.

JakeQZ commented 1 year ago

[edit] Also, we would never open a new game in an unrelated tab just because it's active.

So there needs to be a way of a notification in the active tab to indicate a game has started. And without using in-built browser notifications, which no-one ever trusts and everyone has disabled (so they are useless).

Music streaming sites seem to mange what other tabs are doing quite well.

Before a tournament has started, there is a message saying "You will be notified when the tournament starts, so feel free to play a game in another tab." Is that advice good? Does it actually work in that case?

JakeQZ commented 1 year ago

We fixed the issue you described. Feel free to reopen a related one with additional information if you have a more specific failure on the current production build.

What is the point of opening a new issue? The issue here has not been resolved. Should I just copy and paste all the comments into a new issue? I don't have time. Goodbye.

schlawg commented 1 year ago

Go up and actually read the first few comments on this issue. The state of things has morphed quite a bit since then. We now have audio on pairing, which seems to be exactly what you wanted as it avoids the autoplay on fresh page load conundrum failing to notifier players with sounds.

Now you're asking, and apologies if I'm misinterpreting, but it seems you now desire to be notified without using notifications or sounds? That has nothing to do with "Game start notification sound plays too late" which is the title of this issue. So the point of creating a new issue is to consolidate what you're asking for / currently experiencing in as short and digestible format as possible to maximize the chance someone will actually pay attention to you.

JakeQZ commented 1 year ago

There always was audio on pairing. But you had to be on the the tournament tab to get it. That tab was replaced with the new game. If you were on a different tab, and also had the tournament tab open, the game would start in the tournament tab, and you would not know.

That hasn't changed AFAIAA.

schlawg commented 1 year ago

Yes, I believe it has changed. If it's not working for you, it's a bug.

schlawg commented 1 year ago

I replaced the sound library we were using with new code just to support this new behavior, FYI.

JakeQZ commented 1 year ago

you now desire to be notified without using notifications or sounds?

I don't want 'notifications' because I don't want them when I'm doing other things. I may not fully undersand how they work, but 'subscribe to notifications' seems like something I don't want.

I do want sounds, but they don't seem to work properly. That is the issue here..

If I switch to the tourney lobby during a game, I get a big blue alert saying "Your are playing a game". Surely it's possible to similarly provide such an alert if you are analyzing a game when your next game starts?

JakeQZ commented 1 year ago

Surely it's possible to similarly provide such an alert if you are analyzing a game when your next game starts?

Without allowing native browser notifications (which we do not trust).

schlawg commented 1 year ago

I do want sounds, but they don't seem to work properly. That is the issue here..

I am telling you that they should work now. Have you tried it?

JakeQZ commented 1 year ago

I am telling you that they should work now. Have you tried it?

Played this evening, and didn't have any timed-out games. So it's looking good so far. :)