TetrisTrainer
TetrisTrainer copied to clipboard
60Hz Das on Firefox
Recently, the Tetris pieces have been moving significantly faster than normal. After a bit of testing, it seems that the pieces are moving at roughly 60Hz, or twice the maximum possible rolling speed. While fun, that's not exactly a realistic setting.
I don't recall exactly when I noticed this, but it was no more than a few days ago. This suggests the bug was either caused by your latest batch of commits, or by upgrading Firefox to version 122.0.
I play on Firefox. When I tried it on Chrome, the pieces moved at normal speed. I suppose it's possible that one of my browser settings is relevant, but I don't know how to test that.
Steps to reproduce:
- Open the Tetris trainer in Firefox 122.0
- Set piece sequence to "IIIIIIIIIIIIIIIIIIII"
- Choose level 29
- Hold left
- The I pieces will stack up to the 16th or 17th row before they stop reaching the edge of the screen.
As a side note, I notice that the piece movement is slightly inconsistent. In the testing strategy above, sometimes the seventeenth I reaches the left, and sometimes it doesn't. I suspect this inconsistency is also a bug, but I don't know if it's part of the same bug, or an unrelated bug that I only noticed because I was testing this one.
Inconsistent behavior may make this issue hard to test, and also hard to track down. If you have any other browsers installed, does it do the same thing on those ones?
Inconsistent behavior may make this issue hard to test, and also hard to track down.
The inconsistency here is whether 16 or 17 long bars make it to the left, and in the precise locations where the others land. But if there were no bug, only five or six would make it to the left. So I don't think the inconsistency I mentioned should cause problems tracking down this bug.
If you have any other browsers installed, does it do the same thing on those ones?
Sorry, I only have Firefox and Chrome. As I said, I observe the buggy 60Hz DAS on Firefox, but the regular 10Hz DAS on Chrome.
After a bit more experimenting, I've noticed that adding a right tap into the experimental procedure above, just before the first bar falls, can cause it to revert to 10Hz DAS. I'm not sure why this is, but it might be a clue.
I think I've tracked down the issue. On my Firefox installation, KeyboardEvent.repeat
always returns false, even when it should return true. As a result, the function handleTappedDirection
in input_manager.js
is being called far more often than it should.
To fix this, it might make sense to replace or augment the !repeat
test with a check that the key is not already being held. This is, after all, closer to what the original game does.