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

Remove from disk: add to deck track menu, fix undeleted message #4560

Merged
merged 6 commits into from
Feb 21, 2022

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Dec 8, 2021

I was missing Remove From Disk in the deck menu when I was too lazy to look for the track in the library.
Here it is.

@github-actions github-actions bot added the ui label Dec 8, 2021
@ronso0 ronso0 marked this pull request as draft December 8, 2021 21:53
@ronso0 ronso0 force-pushed the remove-from-disk-fix-undeleted branch from d78d78f to 143c408 Compare December 8, 2021 22:00
@ronso0 ronso0 added this to the 2.4.0 milestone Dec 8, 2021
src/widget/wtrackmenu.cpp Outdated Show resolved Hide resolved
Comment on lines 1807 to 1810
// Eject track from deck
ControlProxy* ejectTrackProxy = new ControlProxy(
m_deckGroup, "eject", this);
ejectTrackProxy->set(1.0);
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure this is the best way to do it, but the first and simplest that came to mind.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we need to check if it's the deleted track that's loaded?
The progress dialog is modal so manual unloading is not possible in he GUI, but with keyboards and controllers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Deleting an MP3 file while the audio stream is decoded might crash Mixxx: https://bugs.launchpad.net/mixxx/+bug/1452005

This happens because libmad/SoundSourceMP3 uses memory mapped files. You are not able to detect how many decoders are active. Checking if a track is loaded on a deck is not sufficient.

Better drop libmad/SoundSourceMP3 and use something more robust.

Copy link
Member Author

Choose a reason for hiding this comment

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

This might also happen with the existing delete & purge action, right? Like when the Analysis feature is busy.

How do you propose to proceed?

@ronso0 ronso0 force-pushed the remove-from-disk-fix-undeleted branch from 143c408 to 6d65df6 Compare December 8, 2021 22:05
@ronso0 ronso0 marked this pull request as ready for review December 8, 2021 22:05
src/widget/wtrackmenu.cpp Outdated Show resolved Hide resolved
src/widget/wtrackmenu.cpp Show resolved Hide resolved
src/widget/wtrackmenu.cpp Outdated Show resolved Hide resolved
@ronso0
Copy link
Member Author

ronso0 commented Dec 9, 2021

I added another check and removed the redundant feature test.
I'll squash the fixup as soon as I get thumbs up.

@uklotzde
Copy link
Contributor

uklotzde commented Dec 9, 2021

On second thought we should not enable the option to delete the file of a track that is loaded on a deck. This option should never be enabled if m_pTrack is set.

@ronso0
Copy link
Member Author

ronso0 commented Dec 9, 2021

I won't fight for this option, though I want to understand the reasons.
Because of the libmad bug you linked?
From my understanding any selected track can be analyzed (in the background) while the user deletes the file in Mixxx. So it wouldn't make a difference to unload the track after the user confirmed to delete it, would it?
If that is true we would need to disallow the track file deletion in general, right?

@uklotzde
Copy link
Contributor

uklotzde commented Dec 9, 2021

It is counterintuitive to delete the file of a track while it is still loaded. Even if it doesn't crash Mixxx.

@Swiftb0y
Copy link
Member

Swiftb0y commented Dec 9, 2021

It is counterintuitive to delete the file of a track while it is still loaded. Even if it doesn't crash Mixxx.

I disagree to be honest. Its counterintuitive if I want to delete a track but can't for no apparent reason. Maybe I just listened to the track and decided that it doesn't belong into my library, so I want to delete it but can't because its still loaded in a deck.

@Swiftb0y
Copy link
Member

Swiftb0y commented Dec 9, 2021

If we can't delete a track while its loaded for technical reason, I'd make that transparent so the user is confused (display the option, but grey it out and explain in a tooltip or something).

@ronso0
Copy link
Member Author

ronso0 commented Dec 9, 2021

We can simply unload stop the deck and eject the track after the confirmation and before deleting the file.

Do you confirm to stop the deck and delete the loaded track file from disk?
This can not be undone!

@ronso0 ronso0 marked this pull request as draft December 9, 2021 22:13
@ronso0 ronso0 force-pushed the remove-from-disk-fix-undeleted branch from f86eb0f to 6a9aeda Compare December 9, 2021 22:19
@ronso0
Copy link
Member Author

ronso0 commented Dec 9, 2021

Marked as draft because --in case it's decided to allow the operation for decks-- I'd squash the fixup commits.

This is the updated warning (for decks):
Screenshot_2021-12-09_23-22-09

@@ -1761,6 +1778,17 @@ void WTrackMenu::slotRemoveFromDisk() {
}
}

// If the operation was initiated from a deck's track menu
Copy link
Contributor

Choose a reason for hiding this comment

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

This code drags dependencies into WTrackMenu that don't belong here. Another example of the spaghetti control flow in Mixxx, unmaintainable.

Is this side-effect even synchronous? Can we guarantee that the track is ejected immediately? Probably not, because decoding is done concurrently in a separate thread -> CachingReaderWorker.

I suppose this doesn't work as intended.

Copy link
Member Author

@ronso0 ronso0 Dec 10, 2021

Choose a reason for hiding this comment

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

This is only supposed to have a clean UX: it would be confusing if the deleted track was still loaded and could still be played.

Please clarify your technical concerns (for example the libmad issue) and give an estimation if this can be solved at all (by me, with guidance, of course). Because, if there are issues to be expected they apply to the delete and purge action in general, not just to the deck option, since we're not checking if a track queued for deletion is analyzed or loaded anywhere. If there are serious concerns it'd be sad they pop up just now because we'd then have wasted quite some time implementing the feature in the first place :\ (what I've learned along the way would be persist, but still..)

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't imagine an easy fix considering the current state of the code base. Merging the code for deleting files directly from within Mixxx without any chance to detect if those files are still accessed by Mixxx probably was a mistake. We didn't consider all the consequences.

I don't veto against merging this PR, but on the other hand I won't merge it myself. Someone else may decide.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, that's unfortunate.
I'm puzzled why you approve the changes even though you have serious technical objections.

I still don't overlook the potential consequences:
The worst case would be Mixxx crashing when deleting mp3 files due to the libmad / SoundSourceMP3 / mmap issue, right? In that case I wouldn't mind removing the entire feature.
Besides that, what could happen that harms the database or puts Mixxx into an inconsistent state?

Copy link
Contributor

Choose a reason for hiding this comment

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

I could only delete the entire review or keep the rejection. Both are not an option for me. "Disagree and merge" or "Disagree and let others merge" (for a second opinion).

I don't really care enough and I also don't have a better proposal. The code is just ugly with the entanglement of the control proxies for triggering a side-effect in another component directly. It works somehow, but probably not always.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, then thanks for your review!
I'll leave to others to judge the remove feature.

@ronso0 ronso0 force-pushed the remove-from-disk-fix-undeleted branch from 6a9aeda to 0bf2ce3 Compare December 10, 2021 23:57
@ronso0
Copy link
Member Author

ronso0 commented Dec 10, 2021

(I squashed the small fixup commits)

@ronso0
Copy link
Member Author

ronso0 commented Feb 3, 2022

Rebased after #4639 has been merged.

@ronso0 ronso0 force-pushed the remove-from-disk-fix-undeleted branch from 0bf2ce3 to b9d5a4c Compare February 3, 2022 16:52
@ronso0 ronso0 marked this pull request as ready for review February 3, 2022 16:52
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.

Thank you. I have some final comment:

src/widget/wtrackmenu.cpp Show resolved Hide resolved
src/widget/wtrackmenu.cpp Outdated Show resolved Hide resolved
src/widget/wtrackmenu.cpp Outdated Show resolved Hide resolved
QString("<br><br><b>") +
tr("This can not be undone!") + QString("</b>");
} else {
delWarningText =
Copy link
Member

Choose a reason for hiding this comment

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

On Linux you can delete the file while playing.
It is actually removed after the last reference to the file has been closed.
On Windows the file is locked until all file handles are closed.
I am not sure how it relates to caching. The file is kept in cache after rejecting.
We need to check if the lock is released than.

src/widget/wtrackmenu.cpp Outdated Show resolved Hide resolved
src/widget/wtrackmenu.cpp Outdated Show resolved Hide resolved
@daschuer
Copy link
Member

LGTM, Thank you.

Sorry for the delay, this one has slipped through.

@daschuer daschuer merged commit 1b688f2 into mixxxdj:main Feb 21, 2022
@ronso0 ronso0 deleted the remove-from-disk-fix-undeleted branch February 22, 2022 09:10
@ronso0
Copy link
Member Author

ronso0 commented Feb 22, 2022

Never mind, this one wasn't urgent.
Did you have chance to test it on windows?

@daschuer
Copy link
Member

Yes, at least on my Win 10 Virtual Machine it works without any issues.

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

Successfully merging this pull request may close these issues.

4 participants