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

Restore invalid cover image hashes #2508

Merged
merged 17 commits into from
Mar 9, 2020
Merged

Restore invalid cover image hashes #2508

merged 17 commits into from
Mar 9, 2020

Conversation

uklotzde
Copy link
Contributor

@uklotzde uklotzde commented Feb 21, 2020

Invalid cover image hashes with the value 0 are not handled correctly and wrong cover images are displayed. Instead those hashes need to be fixed and updated on-the-fly when the images are loaded the next time by CoverArtCache.

The updating is done in CoverArtDelegate that has access to TrackModel. CoverArtCache does not have direct access to Track objects or the library and I don't want to introduce such a dependency. Updating the hashes when tracks are loaded is too late, because first the images are loaded and displayed in the track table view without instantiating any Track objects. Not ideal but a clean solution that fits into our current design.

Follow-up

PR #2524: SHA-256 digest and (background) color

@uklotzde uklotzde added this to the 2.3.0 milestone Feb 21, 2020
@uklotzde uklotzde changed the title Restore invalid cover image hashes [WiP] Restore invalid cover image hashes Feb 22, 2020
@uklotzde
Copy link
Contributor Author

uklotzde commented Feb 22, 2020

Needs to be rebased on master after #2511 has been merged to fix the spurious test errors.

src/library/coverart.cpp Outdated Show resolved Hide resolved
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 for the PR. I have left some comments, the manual test is pending.

<< *this;
// Preserve the track location, i.e. slicing during
// assignment is intended here!
static_cast<CoverInfoRelative&>(*this) = CoverInfoRelative();
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer a separate function to reset the cover info. I can imagine that even with this comment, the code cannot be understand by a less experienced contributor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@uklotzde uklotzde changed the title [WiP] Restore invalid cover image hashes Restore invalid cover image hashes Feb 24, 2020
@uklotzde
Copy link
Contributor Author

Let's see if the tests will succeed after the database issues have been fixed.

@uklotzde uklotzde changed the title Restore invalid cover image hashes [WiP] Restore invalid cover image hashes Feb 25, 2020
@uklotzde
Copy link
Contributor Author

Still segfaults with ctest on Travis

@uklotzde uklotzde changed the title [WiP] Restore invalid cover image hashes Restore invalid cover image hashes Feb 28, 2020
@uklotzde
Copy link
Contributor Author

After a long search for the spurious segfaults during tests I have rebuilt the whole branch and reorganized the commits into small, correlated work packages. Hopefully all tests will pass now.

@uklotzde
Copy link
Contributor Author

The remaining CI failures are now really unrelated.

@uklotzde
Copy link
Contributor Author

@daschuer: Ready, finally.

The concurrent guessing of cover art was poorly documented and designed with lots of implicit assumptions and dependencies. It worked more or less by chance. This investigation and fix has cost me a LOT of time!

#2525 contains a separate fix for the application, independent of any test setup.

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.

The API is still a bit cluttered. It would be nice to clean up.
The manual test was successful. So it is already merge-able.

src/library/coverartutils.cpp Show resolved Hide resolved
src/library/coverart.cpp Outdated Show resolved Hide resolved
CoverArtCache::~CoverArtCache() {
qDebug() << "~CoverArtCache()";
//static
void CoverArtCache::requestCover(
Copy link
Member

Choose a reason for hiding this comment

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

Request cover implies to respond with a cover. Is this always the case here?
What happens if the cover is returned instantly?
I think the called tryLoadCover() name needs to be adjusted as well. ... Or split into two functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just tried to preserve the original naming that used "request" for asynchronous invocations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

request is always called with a pRequestor that expects to receive the result as a signal. What's wrong with this? Returning a QFuture from tryLoad would be nice, but it doesn't allow to return immediate results. Aynway, I'm not planning to rewrite this.

<< requestInfo << pRequestor <<
desiredWidth << onlyCached << signalWhenDone;
//static
void CoverArtCache::requestTrackCover(
Copy link
Member

Choose a reason for hiding this comment

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

This is the request that unlike all direct calls to requestCover also updates the Track.

I think we should get rid of the default null track parameter in requestCover and call pCache->tryLoadCover expicite will pTrack or TrackPointer()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The request functions are static and return nothing. Both (public) variants boil down to a single, special-case invocation of tryLoad. The tryLoad function is non-static and may return something immediately, later, or never.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The use cases are already split. How and why does this need to be split even further?

kLogger.info()
<< "Updating cover info of track"
<< coverInfo.trackLocation;
pTrack->setCoverInfo(coverInfo);
Copy link
Member

Choose a reason for hiding this comment

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

This is redundant if we pass the track into the request.
Can't we do it at one place only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we don't. The CoverArtDelegate accesses query results directly. Track objects are only loaded if the CoverArtCache signals that the cover info has been updated.

@daschuer
Copy link
Member

daschuer commented Mar 2, 2020

Ok, no need to overengineer this. It is already a good step forward.
Unfortunately build fails:

/home/appveyor/projects/mixxx/src/library/coverart.cpp:127:21: error: no match for ‘operator<<’ (operand types are ‘QDebug’ and ‘QFileInfo’)
             kLogger.warning()
             ~~~~~~~~~~~~~~~~~
                     << "loadImage"
                     ~~~~~~~~~~~~~~
                     << type
                     ~~~~~~~
                     << "cover does not exist:"
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~
                     << coverFile;
                     ^~~~~~~~~~~~

@uklotzde
Copy link
Contributor Author

uklotzde commented Mar 2, 2020

Ok, no need to overengineer this. It is already a good step forward.
Unfortunately build fails:

/home/appveyor/projects/mixxx/src/library/coverart.cpp:127:21: error: no match for ‘operator<<’ (operand types are ‘QDebug’ and ‘QFileInfo’)
             kLogger.warning()
             ~~~~~~~~~~~~~~~~~
                     << "loadImage"
                     ~~~~~~~~~~~~~~
                     << type
                     ~~~~~~~
                     << "cover does not exist:"
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~
                     << coverFile;
                     ^~~~~~~~~~~~

Backward compatibility with legacy Qt versions strikes once again.

@uklotzde
Copy link
Contributor Author

uklotzde commented Mar 5, 2020

Anything else to do? CI failures are unrelated.

@uklotzde
Copy link
Contributor Author

uklotzde commented Mar 6, 2020

@daschuer Ping.

I have more changes ready on top of this PR that will allow to share UI code between the internal track collection and external track collections like aoide. Mainly additional base classes and a signal/slot optimization for the CoverArtDelegate. I already experienced inconsistencies due to redundant code that I want to prevent in the future.

@daschuer
Copy link
Member

daschuer commented Mar 9, 2020

No issues found during manual tests. LGTM. Thank you.

@daschuer daschuer merged commit 7a3095d into mixxxdj:master Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants