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

Avoid redundant messages for failed track load #10889

Merged
merged 2 commits into from
Sep 21, 2022

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Sep 12, 2022

Stumbled over this a few times after LoadSelectedTrack was triggered multiple times. Having multiple identical popups stacked was confusing, and is also pointless.

This ensures there is only one QMessageBox for the same track.

if (pTrack && m_pPrevFailedTrack == pTrack) {
return;
} else if (pTrack) {
m_pPrevFailedTrack = pTrack;
Copy link
Contributor

@uklotzde uklotzde Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping TrackPtr cached for an unforeseeable time is not a good idea. Use the id or location.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks.
Should I initialise (in the constructor) with m_pPrevFailedTrack() or m_pPrevFailedTrack(TrackId)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, @ronso0, I am no longer available for reviews. This was just a hint to prevent a regression.

@ronso0 ronso0 force-pushed the failed-track-load-message branch from 4eb384a to 8db1e40 Compare September 13, 2022 12:08
// Alert user.
// Show only one message for this track at a time
TrackId currTrackId = pTrack->getId();
if (pTrack && m_pPrevFailedTrackId == currTrackId) {
Copy link
Member

@daschuer daschuer Sep 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if pTrack is null, it has already crashed above. How about moving the if (pTrack) { to the beginning?
Can this ever be null, if not we can VERIFY_OR_DEBUG_ASSERT that.
Another idea would be to introduce a TrackPointerNotNull but that would be a bigger refactoring.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if pTrack is null, it has already crashed above.

I don't understand where it would have "crashed above"?
IMO that is irrelevant here because the existing code expects having to deal with this and would do m_pChannelToCloneFrom = nullptr;, and I have no intention to change that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line:
TrackId currTrackId = pTrack->getId();
will segfault if pTrack is null
so you will never reach the line below
if (pTrack &&

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my inline comments

@ronso0 ronso0 force-pushed the failed-track-load-message branch from 8db1e40 to 540c386 Compare September 18, 2022 21:51
@ronso0
Copy link
Member Author

ronso0 commented Sep 18, 2022

I must admit to not have tested the code

After noticing the issue with my controller, at home I used a simple MIDI-Through script to trigger multiple track load actions:
https://gist.github.com/ronso0/567f6e92c04ef16989a95cac841bd680

@daschuer
Copy link
Member

Thank you for the script. With it, I was able to reproduce the issue and confirm that it is fixed.

I think the main issue is the at the modal message box disables the control via the main thread, but not via the controller thread so that you can continue control even if the message box is shown. This way one should be able to trick that workaround, by loading another not existing track and than the first. This way we can still stack up message boxes.

The same happens if we load the same track into two or more decks. The later can even happen with the GUI, since track loading happens asynchronous.

I am not against the proposed solution since it is a low impact salition for a real problem while my considerations are only an edge case. But at least we should add a comment about it.

What do you think?

@daschuer
Copy link
Member

How about returning early in BaseTrackPlayerImpl::slotLoadTrack() while the message box is shown?

@ronso0
Copy link
Member Author

ronso0 commented Sep 19, 2022

How about returning early in BaseTrackPlayerImpl::slotLoadTrack() while the message box is shown?

Yes, that makes sense.
Even though I double-checked the signal flow I don't feel comfortable with it for some reason.
Please check this commit.

@ronso0
Copy link
Member Author

ronso0 commented Sep 19, 2022

I don't feel comfortable with it for some reason.

with this LoadTrack tests fail (didn't look into it), so I'll revert e56a6dd
Let's just avoid the redundant popup, that's a good enough, compact UX improvement for a special case IMO.

@ronso0 ronso0 force-pushed the failed-track-load-message branch from e56a6dd to 540c386 Compare September 19, 2022 20:15
Comment on lines 421 to 422
// Show only one message for this track at a time in case this slot is called
// repeatedly for the same track while any prior message is still shown.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Show only one message for this track at a time in case this slot is called
// repeatedly for the same track while any prior message is still shown.
// Due to the event loop inside QMessageBox, slotLoadFailed() can be called recursively
// via repeated loads attempts from a controller. A prior message is still shown in this case.
// In this case we don't show a second message box for the same track.

An alternative suggestion for the comment, with a bit more details. An you take it or integrate it in your comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I extended the comment.
will squash if you think it's okay.

@daschuer
Copy link
Member

Let's just avoid the redundant popup, that's a good enough ..

OK

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you.

@daschuer daschuer added this to the 2.3.4 milestone Sep 21, 2022
@daschuer daschuer added the changelog This PR should be included in the changelog label Sep 21, 2022
@daschuer daschuer merged commit fc176e4 into mixxxdj:2.3 Sep 21, 2022
@ronso0 ronso0 deleted the failed-track-load-message branch September 21, 2022 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog This PR should be included in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants