Skip to content
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

Force findNthBeat to return mutliples of beatlength and adapt tests #2196

Merged
merged 2 commits into from
Oct 23, 2019

Conversation

sharst
Copy link
Contributor

@sharst sharst commented Jun 28, 2019

This is a spinoff of #2186 .
When using the findNextBeat-function (and associated functions), I noticed that the returned sample is not always a multitude of the beat length in samples, which is what I'd have expected and what the respective tests also seem to assume. This is particularly true for beatgrids with non-integer bpm.
I adapted the function to respect this again and adapted the test to be checking for an uneven bpm. This could break some other functions though, which is why I opened it in its own PR

@daschuer
Copy link
Member

daschuer commented Jun 29, 2019

Unfortunately now three tests are failing on AppVeyor:

[  FAILED  ] EngineSyncTest.QuantizeImpliesSyncPhase
[  FAILED  ] EngineSyncTest.SeekStayInPhase
[  FAILED  ] EngineSyncTest.QuantizeHotCueActivate
 3 FAILED TESTS

@daschuer
Copy link
Member

daschuer commented Jun 29, 2019

The rest looks good. Now we need some manual tests.

@sharst
Copy link
Contributor Author

sharst commented Jul 24, 2019

Yes, you are right, and as far as I can tell the failing tests rely on values that were determined experimentally before, so it's only natural that they fail.
To quote from enginesynctest.cpp:

1583 // the value was determined experimentally
1584 ASSERT_DOUBLE_EQ(0.019349962207105064, ControlObject::get(ConfigKey(m_sGroup2, "beat_distance")));
The beat_distance calculation relies on the methods to find closest beats.

Let's test this in a few sets and afterwards if you let me know how to generate the experimental values, I'll enter new ones.

@daschuer
Copy link
Member

If you are sure the unit test should succeeded, you can download the long https://ci.appveyor.com/api/buildjobs/ssrti50d67xljp2m/log
If you search for the name of the failing tests, you will find the expected values.

@sharst
Copy link
Contributor Author

sharst commented Aug 8, 2019

I finally got around to play a few sets with this commit. I couldn't notice any difference, but being a beginner DJ I surely haven't covered all. Transport controls, looping, beatgrid setting all seem to work fine.
Therefore I adapted the tests to the new experimental values.

@uklotzde
Copy link
Contributor

uklotzde commented Aug 9, 2019

The rounding of play positions to integer sample or frame boundaries is found at many places in the engine code and needs to be removed carefully. This PR seems to be a step in the in the right direction and we should consider including it in 2.3.0.

LGTM. @daschuer Merge?

@uklotzde uklotzde added this to the 2.3.0 milestone Aug 9, 2019
@uklotzde
Copy link
Contributor

uklotzde commented Aug 9, 2019

Consistently using frame instead of sample positions inside the engine code would help to write more robust code. But this migration will be large and difficult task...

@Holzhaus
Copy link
Member

The CI issues are unrelated. Merge?

@daschuer
Copy link
Member

Oh sorry for the delay. This slipped through.
LGTM.

@daschuer daschuer merged commit 3c1bdfa into mixxxdj:master Oct 23, 2019
@uklotzde
Copy link
Contributor

The changes in beatgrid.cpp cause many failed debug assertions in quantizecontrol.cpp:

Critical [CachingReaderWorker 2]: DEBUG ASSERT: "even(static_cast<int>(currentClosestBeat))" in function void QuantizeControl::updateClosestBeat(double) at /tmp/mixxx/src/engine/controls/quantizecontrol.cpp:122
Critical [Engine]: DEBUG ASSERT: "m_trackSampleRateOld && m_tempo_ratio_old" in function void EngineBuffer::updateIndicators(double, int) at /tmp/mixxx/src/engine/enginebuffer.cpp:1205

#0  0x00007ffff63e8af5 in raise () at /lib64/libpthread.so.0
#1  0x000000000065a519 in mixxx::(anonymous namespace)::MessageHandler(QtMsgType, QMessageLogContext const&, QString const&) (type=<optimized out>, input=...)
    at /tmp/mixxx/src/util/logging.cpp:133
#2  0x00007ffff41e6321 in qt_message_print(QtMsgType, QMessageLogContext const&, QString const&) () at /lib64/libQt5Core.so.5
#3  0x00007ffff41e6439 in qt_message(QtMsgType, QMessageLogContext const&, char const*, __va_list_tag*) () at /lib64/libQt5Core.so.5
#4  0x00007ffff41b8712 in QMessageLogger::critical(char const*, ...) const () at /lib64/libQt5Core.so.5
#5  0x00000000004e59da in mixxx_debug_assert(char const*, char const*, int, char const*)
    (function=0x109d348 "void QuantizeControl::updateClosestBeat(double)", line=122, file=0x109d310 "/tmp/mixxx/src/engine/controls/quantizecontrol.cpp", assertion=0x109d378 "even(static_cast<int>(currentClosestBeat))") at /usr/include/qt5/QtCore/qlogging.h:91
#6  0x00000000004e59da in mixxx_maybe_debug_assert_return_true(char const*, char const*, int, char const*)
    (function=0x109d348 "void QuantizeControl::updateClosestBeat(double)", line=122, file=0x109d310 "/tmp/mixxx/src/engine/controls/quantizecontrol.cpp", assertion=0x109d378 "even(static_cast<int>(currentClosestBeat))") at /tmp/mixxx/src/util/assert.h:16
#7  0x00000000004e59da in QuantizeControl::updateClosestBeat(double) (this=0x2b424e0, dCurrentSample=<optimized out>) at /tmp/mixxx/src/engine/controls/quantizecontrol.cpp:122
#8  0x00000000010b72d2 in  ()
#9  0x00007fff31bcc0f0 in  ()
#10 0x000000000096aeef in QuantizeControl::trackLoaded(std::shared_ptr<Track>) (this=0x2b424e0, pNewTrack=...) at /tmp/mixxx/src/engine/controls/quantizecontrol.cpp:49
#11 0x000000000097ec3b in EngineBuffer::notifyTrackLoaded(std::shared_ptr<Track>, std::shared_ptr<Track>) (this=0x21b2320, pNewTrack=
    std::shared_ptr<Track> (use count 29, weak count 1) = {...}, pOldTrack=std::shared_ptr<Track> (empty) = {...}) at /usr/include/c++/9/ext/atomicity.h:96
#12 0x000000000097f181 in EngineBuffer::slotTrackLoaded(std::shared_ptr<Track>, int, int) (this=0x21b2320, pTrack=..., iTrackSampleRate=44100, iTrackNumSamples=15213218)

@uklotzde
Copy link
Contributor

Please compile and test with debug assertions enabled and debug_assertions_fatal=1.

@uklotzde
Copy link
Contributor

If it takes time to sort this out I recommend to revert the changes until all issues have been resolved.

@Be-ing
Copy link
Contributor

Be-ing commented Oct 27, 2019

This broke master builds:

[  FAILED  ] BeatGridTest.TestNthBeatWhenOnBeat
[  FAILED  ] BeatGridTest.TestNthBeatWhenOnBeat_BeforeEpsilon
[  FAILED  ] BeatGridTest.TestNthBeatWhenOnBeat_AfterEpsilon
[  FAILED  ] BeatGridTest.TestNthBeatWhenNotOnBeat

@esbrandt
Copy link
Contributor

Related?
Getting audible crackles in short intervals, log spews

...
Critical [Engine]: DEBUG ASSERT: "even(static_cast<int>(currentClosestBeat))" in function void QuantizeControl::updateClosestBeat(double) at src/engine/controls/quantizecontrol.cpp:122
Warning [Engine]: underflowHappened code: 24
Warning [Engine]: underflowHappened code: 6
Critical [Engine]: DEBUG ASSERT: "even(static_cast<int>(currentClosestBeat))" in function void QuantizeControl::updateClosestBeat(double) at src/engine/controls/quantizecontrol.cpp:122
Critical [Engine]: DEBUG ASSERT: "even(static_cast<int>(currentClosestBeat))" in function void QuantizeControl::updateClosestBeat(double) at src/engine/controls/quantizecontrol.cpp:122
Critical [Engine]: DEBUG ASSERT: "even(static_cast<int>(currentClosestBeat))" in function void QuantizeControl::updateClosestBeat(double) at src/engine/controls/quantizecontrol.cpp:122
Critical [Engine]: DEBUG ASSERT: "even(static_cast<int>(currentClosestBeat))" in function void QuantizeControl::updateClosestBeat(double) at src/engine/controls/quantizecontrol.cpp:122
Critical [Engine]: DEBUG ASSERT: "even(static_cast<int>(currentClosestBeat))" in function void QuantizeControl::updateClosestBeat(double) at src/engine/controls/quantizecontrol.cpp:122
...
```

@uklotzde
Copy link
Contributor

Removing the debug assertion doesn't seem to cause any further issues. It might have become obsolete, see #2334.

I don't see any test failure on master, BeatGridTest passes.

@uklotzde
Copy link
Contributor

I also added a note to the Wiki for future builds: https://www.mixxx.org/wiki/doku.php/compiling_on_linux#developer_build_options

Developers are strongly advised to use these options for testing their builds. Otherwise violated debug assertions may not be noticed during testing as we have seen. Unfortunately --debugAssertBreak doesn't seem to work when running the tests.

@Be-ing
Copy link
Contributor

Be-ing commented Oct 27, 2019

Instead of suggesting developers use an optional flag, how about we turn it on by default and only disable it on the build servers?

@uklotzde
Copy link
Contributor

After switching to CMake I forgot to add those additional flags to my build scripts. I agree, the debug build options should better be opt-out instead of opt-in!

@uklotzde
Copy link
Contributor

uklotzde commented Oct 27, 2019

The macOS tests are failing because of rounding errors. This is independent of the debug assertion.
Only the tests on the build server fail, while the Travis CI tests finish successfully.

@uklotzde
Copy link
Contributor

I've added some test fixes to #2334. The kMaxBeatError constant needs to be tuned depending on the test results on the build server.

@daschuer
Copy link
Member

I agree, the debug build options should better be opt-out instead of opt-in!

I guess we have many users compiling Mixxx for live usage and only some developers. So I think the default build should be a live usable version. How about add a script that generates an optimized Version for developing?

I am just afraid that we will get complains about crashes due to assertions.

@uklotzde
Copy link
Contributor

Scripts are non-portable and all other build options need to be customized. In this case documentation is the only option.

daschuer added a commit that referenced this pull request Oct 28, 2019
Follow-up #2196: Remove obsolete debug assertion
@uklotzde
Copy link
Contributor

Master builds are passing on all platforms after #2334 has been merged: https://builds.renegadetech.mixxx.org/job/master-release/882/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants