01-23-2024, 12:41 AM | #16 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Also when it hangs what does task manager say?
Also can you run it as calibre-debug -g and reproduce and post whatever is output in the command prompt |
01-23-2024, 12:55 AM | #17 |
null operator (he/him)
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Yes, all my libraries have a VM View applied.
The problem reproduces in Safe mode. Some books in the two libraries that exhibit the problem have data folders, whereas none of the books in the libraries that don't have the problems have data folders. But it seems unlikely that data folders would be a problem in the cover grid view and not in the list view… where they have an icon. I wonder if the OPs problem library has data folders? Hmmm - if I delete %appdata%\calibre\Cache\gui-thumbnail-cache before starting calibre the problem does not manifest at startup, but it comes back again on a library switch - by which time the gui-thumbnail-cache has been created and had a some data added. I've attached screen shots of my L&F-Cover grid settings, the Emblems tab is empty. BR |
Advert | |
|
01-23-2024, 01:02 AM | #18 |
null operator (he/him)
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
01-23-2024, 01:05 AM | #19 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
@kovid: although I can't reproduce it, given what BR says I suspect it is related to setting the current index to row zero in init.finalize_layout(). It does it by setting a oneshot timer(0). This introduces a possible timing issue with ui.post_initialize_actions(). Which of the two goes first, and is the answer deterministic? You can see when the timers fire by when the selected book jumps, changing the book in book details. In BR's case the book jumps but book details isn't changed. The jump is caused by the timer. The selection for book details is inline, not in the timer method.
I tried moving the code to set the current row to zero from finalize_layout() to post_initialize_actions(). Nothing broke. Of course, nothing was fixed either. Also, the view manager will "do its thing" at .initialization_complete(). which happens before the oneshots are processed. I don't know if that could confuse things, in particular the choosing of the currently selected row and the signals related to book details. |
01-23-2024, 01:08 AM | #20 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Hmmmm ... If it happens with switch library then the argument I made above is likely bogus. That code isn't run by switch_libary.
|
Advert | |
|
01-23-2024, 01:14 AM | #21 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
01-23-2024, 01:31 AM | #22 | |
null operator (he/him)
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
"calibre.exe is not responding"
Quote:
Code:
calibre 7.4 embedded-python: True Windows-10-10.0.19045-SP0 Windows ('64bit', 'WindowsPE') ('Windows', '10', '10.0.19045') Python 3.11.5 Windows: ('10', '10.0.19045', 'SP0', 'Multiprocessor Free') Interface language: None Successfully initialized third party plugins: BRMenu Menu (1, 2, 0) && Count Pages (1, 13, 4) && Drop Search Results (1, 0, 14) && Favourites Menu (1, 3, 0) && Job Spy (1, 0, 239) && Modify ePub (1, 8, 2) && Scroll Book Details (1, 0, 2) && View Manager (1, 10, 2) QPA platform: windows devicePixelRatio: 1.5 logicalDpi: 96.0 x 96.0 physicalDpi: 104.87741935483871 x 104.50285714285712 ApplicationPaletteChange event ignored Using calibre Qt style: True [0.00] Starting up... [0.00] Initializing db... [0.05] db initialized [0.05] Constructing main UI... qt.gui.imageio: libpng warning: iCCP: known incorrect sRGB profile qt.gui.imageio: libpng warning: iCCP: cHRM chunk does not match sRGB [0.98] GUI main window shown Job Spy has begun initialization... orig_option = prefs.get[option_key]: True Tweak Library Name: Models 'read_file_metadata' global.py file prefs.set FROM: True TO: True 'read_file_metadata' global prefs[option_key] value changed FROM: True TO: True author_sort_copy_method >>> default tweaks.py method is: invert author_sort_copy_method changed FROM: invert TO: copy current tweaks['title_series_sorting']: library_order --->>>apply_title_series_sorting_by_library: libname is NOT tweaked; default value used for: Models is: library_order title_series_sorting changed FROM: library_order TO: library_order Calibre, and hence Job Spy, was gracefully shut down last time? False Last time daemon started: never Last time daemon failed: never Total daemon starts inception_to_date: 0 Total daemon failures inception-to-date: 0 qt.gui.imageio: libpng warning: iCCP: known incorrect sRGB profile JS: ===>>> change_gui_alternating_row_colors() Job Spy has finished initialization... [1.48] main UI initialized... [1.48] Started up in 1.48 seconds with 171 books Here's another one with a library switch to my Creators library Code:
calibre 7.4 embedded-python: True Windows-10-10.0.19045-SP0 Windows ('64bit', 'WindowsPE') ('Windows', '10', '10.0.19045') Python 3.11.5 Windows: ('10', '10.0.19045', 'SP0', 'Multiprocessor Free') Interface language: None Successfully initialized third party plugins: BRMenu Menu (1, 2, 0) && Count Pages (1, 13, 4) && Drop Search Results (1, 0, 14) && Favourites Menu (1, 3, 0) && Job Spy (1, 0, 239) && Modify ePub (1, 8, 2) && Scroll Book Details (1, 0, 2) && View Manager (1, 10, 2) QPA platform: windows devicePixelRatio: 1.5 logicalDpi: 96.0 x 96.0 physicalDpi: 104.87741935483871 x 104.50285714285712 ApplicationPaletteChange event ignored Using calibre Qt style: True [0.00] Starting up... [0.02] Initializing db... [0.19] db initialized [0.19] Constructing main UI... qt.gui.imageio: libpng warning: iCCP: known incorrect sRGB profile qt.gui.imageio: libpng warning: iCCP: cHRM chunk does not match sRGB [1.30] GUI main window shown Job Spy has begun initialization... orig_option = prefs.get[option_key]: True Tweak Library Name: Books 'read_file_metadata' global.py file prefs.set FROM: True TO: True 'read_file_metadata' global prefs[option_key] value changed FROM: True TO: True author_sort_copy_method >>> default tweaks.py method is: invert current tweaks['title_series_sorting']: library_order --->>>apply_title_series_sorting_by_library: libname IS tweaked; new value for: Books is: library_order title_series_sorting changed FROM: library_order TO: library_order Calibre, and hence Job Spy, was gracefully shut down last time? True Last time daemon started: never Last time daemon failed: never Total daemon starts inception_to_date: 0 Total daemon failures inception-to-date: 0 qt.gui.imageio: libpng warning: iCCP: known incorrect sRGB profile JS: ===>>> change_gui_alternating_row_colors() Job Spy has finished initialization... [1.69] main UI initialized... [1.69] Started up in 1.69 seconds with 5 books author_sort_copy_method >>> default tweaks.py method is: invert apply_author_sort_method_by_library: libname is NOT tweaked; nothing changed: Creators orig_option = prefs.get[option_key]: True Tweak Library Name: Creators 'read_file_metadata' global.py file prefs.set FROM: True TO: True 'read_file_metadata' global prefs[option_key] value changed FROM: True TO: True executing: self.maingui._spare_pool.shutdown(wait_time=60.0) Successful; forced the upcoming new pool to reload global preference 'read_file_metadata' just tweaked here per-Library... current tweaks['title_series_sorting']: library_order --->>>apply_title_series_sorting_by_library: libname is NOT tweaked; default value used for: Creators is: library_order title_series_sorting changed FROM: library_order TO: library_order BR |
|
01-23-2024, 01:35 AM | #23 |
null operator (he/him)
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
I'm going to do a backup, in case I break something, shouldn't take long - it's and incremental backup
BR |
01-23-2024, 02:16 AM | #24 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
@BR: I meant is the CPU usage high? That is, is calibre.exe in some kind of loop or just stuck.
|
01-23-2024, 02:36 AM | #25 |
null operator (he/him)
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
It's stuck, wedged in my vernacular
|
01-23-2024, 09:09 AM | #26 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
@kovid: it failed for me a few times. It is extremely timing dependent. Putting in print statements seems to often avoid the failures.
I was able to trace it to some sort of hang in the cover cache. The view was fully initialized after the library change and render_covers() was called. At that point things froze, by the looks of things deadlocked (no processor time). When it failed it seems not to render any covers. Putting prints into the render thread "fixed" it. I never got a failure despite 30-40 attempts. BTW: what is self.pixmap_staging[] used for in CoverCache. As far as I can tell covers are added to a list then never used. Is this some way to avoid garbage collecting covers? |
01-23-2024, 09:32 AM | #27 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Yeah, it prevents the QPixmap objects from being garbage collected in case they are removed from a non GUI thread. It might causes crashes if their destructors run on a non-GUI thread. Do you suspect the deadlock being there? Its a pretty simple class but you can try changing the Lock to an RLock.
|
01-23-2024, 01:30 PM | #28 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
The method alternate_view.render_cover is called in the render thread, not the GUI thread. With this code (the print statements), when it fails I see only the first message. I have never seen a failure if the second message appears. Code:
... print(f'render_cover has_cover: {has_cover}') if has_cover: p = QImage() p.loadFromData(cdata, CACHE_FORMAT if cdata is tcdata else 'JPEG') print(f'render_cover p.isNull: {p.isNull()}, cdata is tcdata:{cdata is tcdata}') p.setDevicePixelRatio(dpr) I see three possible fixes:
A patch file is attached. I can do it as a PR if you would rather. |
|
01-23-2024, 09:25 PM | #29 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Qt in general is not thread safe, but QImage is supposed to be, see https://doc.qt.io/qt-6/threads-modules.html
That is in fact the reason the code uses QImage rather than QPixmap even though QPixmap is faster to render. That said, there could well be a regression in newer Qt that breaks the supposed thread safety of QImage. See for example: https://bugreports.qt.io/browse/QTBUG-90629 There are two QImage operations performed in the render thread, loading from data and resizing to create the thumbnail. If we don't trust QImage to be thread safe, probably best to move both into the GUI thread and just load the JPEG data into memory in the render thread. Or maybe have the render thread do resizing using PIL instead of Qt, that should cause the least loss of performance. PIL could output the thumbnail data in 32bpp format and it can be loaded into the QImage without copying using the QImage(uchar...) constructor. Or ditch QImage and use QPixmap (since we are now on the GUI thread) having PIL output in XPM or uncompressed PNG. Needs some thought/experimentation. Coming to your patch, its hard to know if it actually fixes the issue or just changes timing. If we have identified QImage not being thread safe as the culprit, then I would rather remove QImage completely from the render thread if that can be done performantly. I will look at it when I have some time, feel free to experiment further yourself if you want to, I will post here when I start working on it. |
01-23-2024, 09:42 PM | #30 |
Resident Curmudgeon
Posts: 74,015
Karma: 129333114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
What changed between calibre 7.2.0 and the later versions that 7.2.0 doesn't hang while the newer versions do?
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre hangs | taurins | Calibre | 13 | 11-30-2021 01:12 PM |
PRS-T1 Hangs when starting- please help | fruit12 | Sony Reader | 14 | 03-11-2020 01:27 AM |
Calibre just hangs | mentz | Calibre | 9 | 10-07-2010 11:26 PM |
Calibre hangs and can't do anything | vincentnoiseux | Calibre | 17 | 04-30-2010 09:13 AM |
Calibre hangs now | coase | Calibre | 5 | 07-14-2009 07:12 PM |