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

Fix reading the Spinny cover on Windows #12103

Merged
merged 2 commits into from Nov 23, 2023
Merged

Conversation

daschuer
Copy link
Member

This finally fixes #11131

This patch awoid to access the same file simultaneously form two threads.
Instead it used the same thread to redponds to both requests.

@JoergAtGithub Please confirm if this fixes your issue.

This PR is on top of #12087 which is on top of #12009

@m0dB
Copy link
Contributor

m0dB commented Oct 14, 2023

Great work, @daschuer !

This patch avoids to access the same file simultaneously from two threads.

Isn't that something that could have been solved with a simple mutex? Not saying that that would have been a better solution (I am all for reducing needless threading complexity), just trying to understand the changes so I can do the review.

Instead it used the same thread to respond to both requests.

Can you point out the where in the code this change is implemented?

@daschuer
Copy link
Member Author

Isn't that something that could have been solved with a simple mutex?

Yes, a quick hack solution with a mutex would have been possible. The downside would be that only one thread would be have file excess and that multiple access of the same file would have been chained.

Now we still use a new concurrent thread for every new file. Simultaneous accesses to the same file, that happens when loadingva track, are performed by a single thread.

// to avoid loading the same picture again while we are loading it
QPair<const QObject*, mixxx::cache_key_t> requestId = qMakePair(pRequester, requestedCacheKey);
if (m_runningRequests.contains(requestId)) {
bool requestPending = m_runningRequests.contains(cacheKey);
Copy link
Member Author

Choose a reason for hiding this comment

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

Here we collect requests to a same file.
Whe the first look up is done m_runningRequests is used to signall all requesters.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it! Thanks, this helps!

this,
coverInfo,
absoluteHeightOfCoverartToolTip);
return tr("Fetching image ...");
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the string used for? Can you add a 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.

This text is shown as tooltip for the spit of a second before the actual cover is shown. I will add a 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.

Done

Copy link
Member

Choose a reason for hiding this comment

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

This text is shown as tooltip for the spit of a second before the actual cover is shown.

Than it doesn't work, I see the text, but it's no replaced by the cover art. If I don't move the mouse, it remains there for some seconds, and than the tooltip disappears.

getTrackLocation(m_toolTipIndex) != coverInfo.trackLocation) {
return;
}
emit dataChanged(m_toolTipIndex, m_toolTipIndex, {Qt::ToolTipRole});
Copy link
Contributor

Choose a reason for hiding this comment

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

What has the tooltip to do with the cover?

Copy link
Member

Choose a reason for hiding this comment

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

If library tooltips are enabled and you move the mouse over a library cover, than the tooltip shows a bigger picture of this cover (mouse pointer is not captured by screenshot-tool):
grafik

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it!t Thanks! Still discovering mixxx features I never use :-)

bool hasImage() const {
return cacheKey() != CoverImageUtils::defaultCacheKey();
return type != NONE;
Copy link
Contributor

Choose a reason for hiding this comment

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

might be a good moment to prefix this m_type?

@JoergAtGithub
Copy link
Member

The deck spinnies are now loaded, but there is a new issue:

If I start with initial library table column size everything works:
grafik
But if I change the column width of the library, the loading of coverart stops(in the screenshot you see how it looks after column width change an loading the same track into deck1):
grafik

@daschuer
Copy link
Member Author

Can you allso have a look to that mature #12009
This needs to be merged first and would make the review here more easy.

@daschuer daschuer force-pushed the gh11131 branch 3 times, most recently from 519ab18 to 5724857 Compare October 15, 2023 21:53
@daschuer
Copy link
Member Author

I was able to reproduce the column size issue. I have amended the last commit with a fix.

@JoergAtGithub
Copy link
Member

This doesn't compile:

  [222/686] Building CXX object CMakeFiles\mixxx-lib.dir\src\library\coverartcache.cpp.obj
  FAILED: CMakeFiles/mixxx-lib.dir/src/library/coverartcache.cpp.obj 
  C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1437~1.328\bin\Hostx64\x64\cl.exe  /nologo /TP -DAMD64 -DDJINTEROP_SOURCE -DHAVE_WINSOCK2_H -DMIXXX_BUILD_RELEASE -DMIXXX_DEBUG_ASSERTIONS_ENABLED -DMIXXX_DEBUG_ASSERTIONS_FATAL -DMIXXX_USE_QOPENGL -DNOMINMAX -DPROTOBUF_USE_DLLS -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_PRINTSUPPORT_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_QUICKWIDGETS_LIB -DQT_QUICK_LIB -DQT_SQL_LIB -DQT_SVG_LIB -DQT_TABLET_SUPPORT -DQT_TESTCASE_BUILDDIR=\"C:/Users/Joerg.WORLDWARTWEB/source/repos/JoergAtGithub/mixxx/build/x64__legacy\" -DQT_TESTLIB_LIB -DQT_USE_QSTRINGBUILDER -DQT_WIDGETS_LIB -DQT_XML_LIB -DSFC_SUPPORTS_SET_COMPRESSION_LEVEL -DUNICODE -DWIN32 -DWINVER=0x0601 -D_ATL_MIN_CRT -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING -D_USE_MATH_DEFINES -D_WIN32_WINNT=0x0601 -D_WINSOCK_DEPRECATED_NO_WARNINGS -D__BATTERY__ -D__BROADCAST__ -D__ENGINEPRIME__ -D__HID__ -D__HSS1394__ -D__LILV__ -D__MAD__ -D__MEDIAFOUNDATION__ -D__MODPLUG__ -D__OPUS__ -D__QTKEYCHAIN__ -D__SNDFILE__ -D__SQLITE3__ -D__SSE2__ -D__SSE__ -D__VINYLCONTROL__ -D__WINDOWS__ -D__WV__ -IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\build\x64__legacy\mixxx-lib_autogen\include -IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\src -IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\build\x64__legacy\src -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\lib\fidlib -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\lib\portaudio -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\lib\rigtorp\SPSCQueue\include -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\lib\replaygain -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\lib\reverb -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\lib\libshout-idjc\include -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\djinterop -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\lib\kaitai -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\lib\mp3guessenc-0.27.4 -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5 -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtConcurrent -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtCore -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\tools\qt5\mkspecs\win32-msvc -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtGui -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtNetwork -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtOpenGL -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtWidgets -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtPrintSupport -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtQml -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtQuickWidgets -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtQuick -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtQmlModels -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtSql -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtSvg -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtTest -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\qt5\QtXml -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\lib\qm-dsp -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\lib\qm-dsp\include -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\taglib -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\opus -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\hidapi -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\lib\xwax -external:IC:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\buildenv\mixxx-deps-2.4-x64-windows-0309294\installed\x64-windows\include\wavpack -external:W0 /DWIN32 /D_WINDOWS /GR /EHsc /Zc:__cplusplus /Zc:inline /Z7 /O2  /DNDEBUG -std:c++20 -MD /UTF8 /fp:fast /Gy /W3 -DPA_USE_JACK=1 -DPA_USE_ASIO=1 -DPA_USE_DS=1 -DPA_USE_WMME=1 -DPA_USE_WASAPI=1 -DPA_USE_WDMKS=1 /showIncludes /FoCMakeFiles\mixxx-lib.dir\src\library\coverartcache.cpp.obj /FdCMakeFiles\mixxx-lib.dir\mixxx-lib.pdb /FS -c C:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\src\library\coverartcache.cpp
C:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\src\library\coverartcache.cpp(301): error C2653: 'm_runningRequests': is not a class or namespace name
C:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\src\library\coverartcache.cpp(301): error C2664: 'int remove(const char *)': cannot convert argument 1 from 'mixxx::cache_key_t' to 'const char *'
  C:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\src\library\coverartcache.cpp(301): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or parenthesized function-style cast
  C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\stdio.h(369): note: see declaration of 'remove'
  C:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\src\library\coverartcache.cpp(301): note: while trying to match the argument list '(mixxx::cache_key_t)'
C:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\src\library\coverartcache.cpp(303): error C2144: syntax error: 'auto' should be preceded by ';'

@daschuer
Copy link
Member Author

Now it builds again.

@JoergAtGithub
Copy link
Member

I could build it now, and it fixes the issue with the missing cover art in the decks. But the cover art tooltips in the library only work, if the cover art is already cached.

@daschuer
Copy link
Member Author

Strange, I am not able to confirm it natively on Ubuntu, but on my windows 10 virtual machine.

@daschuer
Copy link
Member Author

Fixed here by rebasing on #12087

Copy link
Member

@JoergAtGithub JoergAtGithub left a comment

Choose a reason for hiding this comment

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

Now the CoverArt tooltip always appears, but I couldn't see the string "Fetching image ..." anymore. Not sure, if it does not appear, or the loading is too fast. Anyway, it is what the user expect. Great work! Thank you!

@daschuer
Copy link
Member Author

Rebased on top of the branches this one is based on.

@daschuer daschuer force-pushed the gh11131 branch 2 times, most recently from 9be98cd to 4db2609 Compare November 16, 2023 07:18
@JoergAtGithub
Copy link
Member

I think this needs to be rebased to latest 2.4, before we can be merge this - or can Git handle this merge without rebase?

@daschuer
Copy link
Member Author

Rebased.

@JoergAtGithub
Copy link
Member

Thank you! Still LGTM!

@JoergAtGithub JoergAtGithub merged commit 6e9ea54 into mixxxdj:2.4 Nov 23, 2023
12 checks passed
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.

Deck/Spinny Coverart is randomly not read
3 participants