-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "BeatGrid: Remove fuzzy behavior from findNthBeat" #4334
Conversation
This reverts commit 95f7d36.
There must be way to fix this without doing the opposite of what the method name and documentation says (it should never be possible that This rounding issue should be handled in the calling code, e. g. by calling |
Please add a test for the actual issue where the beatloop size is wrong. |
I struggled with the Fuzzy behaviour, while reimplementing the beat_active CO. It took me some debugging to find out, why my algorithm sometimes failed. The reason was that I got the wrong beat positions, due to this Epsilon in find prev/next beat. This was really unexpected behaviour. |
I tested and confirm this fixes https://bugs.launchpad.net/mixxx/+bug/1942657 |
double nextBeat = ceil(beatFraction); | ||
|
||
// If the position is within 1/100th of the next or previous beat, treat it | ||
// as if it is that beat. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please elaborate in the comment explaining this is required due to the imprecision of floating points.
Please amend the commit message to link https://bugs.launchpad.net/mixxx/+bug/1945238 and https://bugs.launchpad.net/mixxx/+bug/1942657 |
Would this also work, if epsilon is smaller than the duration of one frame? |
The fuzzyness should not be a feature of the beatgrid, it should be handled in the calling code where it's actually needed. Otherwise it's extremely confusing (see #3418) and we'd have to rename |
If it is required everywhere I think it should be handled in the called function, not the callers. |
I doubt that it's needed everywhere. |
It's definitely not required everywhere: For findPrevNextBeats, there are two callers, which would fail with the Fuzzy behaviour enabled. Therefore this function has the additonal argumnent to enable/disable this "snap tolerance". |
|
||
// If the position is within 1/100th of the next or previous beat, treat it | ||
// as if it is that beat. | ||
const double kEpsilon = .01; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be passed as a parameter instead if hardcoding it, e.g. beatPositionTolerance
. A value of 0.0 should disable the fuzzy behavior. The caller knows best about the precision of the position
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A 1/100th of a frame?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Holzhaus Other ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be a use case for setting a different value for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Counter question: What is the rationale for the hard-coded constant 0.01
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I presume it was determined experimentally in the old code this is reverting to.
This is not a new PR with new code, it is just reverting back to the old code (with a tiny fix to the test so that it compiles). |
Except that it doesn't restore "correct behavior" because the old code blatantly violated the spec and method documentation and sometimes did the opposite of what is expected. In that sense, this PR swaps out a bug with another (the latter is admittedly less severe because it's not user facing). IIUC you were able to reproduce the issue with wrongly sized beatloops/beat jumps locally. This is why I asked if you could add a test for that instead of adding back a test that ensures the wrong method behavior. Then we can later revert this revert and implement another way to satisfy that test instead. |
ok I think I can construct such a test -- it might be tricky because it relies on very small floating point errors, which may not be consistent between platforms. But if I can get it to fail on one, that's a start. |
test added |
Looking at the using code, I think the issue happens in most cases where we have found a beat in first step and we just need a corresponding other beat. This is translated to a position just to fulfill the interface of the findNthBeat() function. |
so can we at least merge the fix for the buggy behavior first? |
Still waiting for a response to my review comments. That's what reviews are for. |
why is it my job to fix these things? @Holzhaus wrote bad code which broke mixxx, and I identified the problem and a simple remedy to get back to a working state. I'm sorry I don't have time to improve on the state of the code as it used to be. Since Jan wanted to change this code, I feel like he should be responsible for fixing his own bug. I'm really sorry I don't have more time or energy to do this but I'm not working on this any more. |
It is very hard to be in the position of being one of the only developers that seemingly uses mixxx on a regular basis. I find so many regressions and it's very hard to be asked by 5 different people to fix all of their bugs for them. |
So you suggest us to stop working on Mixxx and leave it as is? |
No, I'm asking us to follow basic software engineering process when fixing a bug: if a bad commit is found, revert the bad commit cleanly. then, after, consider the code and how it can be improved. Combining code improvements into a commit-revert is bad practice (fixing forward) |
I do a lot of work on Mixxx, I have many PRs open on which I have addressed comments. But I am out of patience for review-creep on every review. |
https://cloud.google.com/blog/products/gcp/reliable-releases-and-rollbacks-cre-life-lessons " When an error is found or reasonably suspected in a new release, the releasing team rolls back first and investigates the problem second. A request for a rollback is not interpreted as an attack on the releasing team, or even the person who wrote the code containing the bug; rather, it is understood as The Right Thing To Do to make the system as reliable as possible for the user. No-one will ask “why did you roll back this change?” as long as the rollback changelist describes the problem that was seen." They are talking about releases specifically, but the same thing applies to individual code commits. You start be resolving the problem. Then you take a look at improving the situation. This PR was supposed to be a rubber-stamp first step toward that goal. I do not have the time to improve every part of mixxx I find a problem with. Would you prefer I have not investigated this problem and found the bug at all? I have done my part, I would like to hand this issue off to someone else. |
These are perfectly good observations and notes for whomever wants to take another stab at fixing this code. A revert is not the right place to ask for those changes. I wish y'all could see my PRs for my job, they are short and sweet and we do what we can to get code in and make things better. I'm not asking for anything that isn't industry standard. |
I have made a good progress to fix the root cause. I think I can publish a PR today. |
Here it is: #4366 |
This reverts commit 95f7d36.
Due to floating point inaccuracy, it's not a good idea to blindly round beat positions without some amount of fuzz. The reverted change caused https://bugs.launchpad.net/mixxx/+bug/1945238