Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 01-24-2024, 05:46 AM   #31
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kovidgoyal View Post
Qt in general is not thread safe, but QImage is supposed to be, see https://doc.qt.io/qt-6/threads-modules.html
I read that as guaranteeing they are reentrant, not threadsafe. Also, loadFromData() seems to be the supposed problem, which might be different from "painting" into threads.
Quote:
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.
I agree that it could merely be hiding the problem. But if so, it is doing a good job at it.

I suspect the safest solution is the one you referred to, using the thread to fetch the data from the disk cache but do no Qt ops on it. The cached data would be passed back to re_render() in the GUI via the update_item signal already there. Re_render() would convert & size the image, store it in the CoverCache, then trigger the item repaint(). This should take approximately the same number of CPU cycles as doing it in the render thread, and the queue system already there would prevent the UI from being blocked for noticable periods. As a side benefit, I think CoverCache would no longer need locking because it would run only on the GUI thread. I will look at this approach if/when I get the energy.
chaley is offline   Reply With Quote
Old 01-24-2024, 10:12 AM   #32
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
@kovid: I made progress today. I should have a trial implementation tomorrow.
chaley is offline   Reply With Quote
Old 01-24-2024, 10:35 AM   #33
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by chaley View Post
@kovid: I made progress today. I should have a trial implementation tomorrow.
Glad to hear it.
kovidgoyal is offline   Reply With Quote
Old 01-25-2024, 09:01 AM   #34
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kovidgoyal View Post
Glad to hear it.
I did a PR for the proposed fix. I say "proposed" because it is possible (probable?) that I missed a case or did something in a way you won't want to maintain. I commented the code where I made assumptions about its behavior or to justify implementation choices.

I tested it with a 24,000 book library with covers. This library would hang 2 out of 3 times with the old code. No hangs with the new code. Of course this isn't proof, but that, code path analysis, and lock chain analysis combine well enough for be to say "fixed".
chaley is offline   Reply With Quote
Old 01-25-2024, 03:27 PM   #35
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
The fix is now in calibre source.
chaley is offline   Reply With Quote
Old 01-25-2024, 10:32 PM   #36
MCBastos
Enthusiast
MCBastos began at the beginning.
 
Posts: 37
Karma: 10
Join Date: Jan 2012
Location: Brazil
Device: Galaxy A71
I have done some more testing. Things that *did not* solve the problem:
- Uninstalling the antivirus
- Disabling just about every third-party program from startup
- Updating the video driver (coincidentally, AMD has just offered a new version)
- Starting Calibre with the --ignore-plugins (well, it worked *once*, and then never again)

However, I noticed one peculiar thing that might give a hint to someone with a better understanding of the program innards: although Calibre itself becomes non-responsive when the issue hits, the window can still be moved or minimized... and when I do that, I find that the Calibre splash (the one that says "Starting up, please wait... Initializing user interface...") is still showing up, only moved to the background.

I also found that running
calibre --start-in-tray
works fine, no matter what layout has been used.

As I mentioned, I have no idea of how the innards of Calibre work... but it seems to me that the UI code hangs trying to draw the cover grid *if a specific part of the rest of the program has not yet been loaded.* Maybe it relies on a service that it's not yet available, or maybe it causes a racing condition, I don't know, I'm not much of a programmer.

Why does it work in Windows safe mode, then? Beats me. Maybe it just loads fast enough when there's less stuff using machine resources.

This is by no means a competent technical analysis; this is what in Portuguese is called a "palpite", which could be roughly translated to English as "uninformed guess."
MCBastos is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 01:13 PM.


MobileRead.com is a privately owned, operated and funded community.