FS#77807 - [calibre] 6.14 ebook-viewer crashes on launch

Attached to Project: Community Packages
Opened by Tedd (tedd) - Friday, 10 March 2023, 11:35 GMT
Last edited by Caleb Maclennan (alerque) - Tuesday, 14 March 2023, 18:33 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Caleb Maclennan (alerque)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 11
Private No

Details

Description:
Trying to read an ebook with the included ebook-viewer results in the following error message and fails to load any file.
Downgrading to calibre 6.11.0-1 fixes the problem.

$ ebook-viewer
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
Traceback (most recent call last):
File "/usr/bin/ebook-viewer", line 21, in <module>
sys.exit(ebook_viewer())
File "/usr/lib/calibre/calibre/gui_launch.py", line 102, in wrapper
return func(*a, **kw)
File "/usr/lib/calibre/calibre/gui_launch.py", line 118, in ebook_viewer
main(args)
File "/usr/lib/calibre/calibre/gui2/viewer/main.py", line 225, in main
run_gui(app, opts, args, internal_book_data)
File "/usr/lib/calibre/calibre/gui2/viewer/main.py", line 151, in run_gui
main = EbookViewer(
File "/usr/lib/calibre/calibre/gui2/viewer/ui.py", line 151, in __init__
self.lookup_widget = w = Lookup(self)
File "/usr/lib/calibre/calibre/gui2/viewer/lookup.py", line 307, in __init__
self._page = Page(create_profile(), self.view)
File "/usr/lib/calibre/calibre/gui2/viewer/lookup.py", line 223, in create_profile
ans.setHttpUserAgent(random_user_agent(allow_ie=False))
File "/usr/lib/calibre/calibre/__init__.py", line 297, in random_user_agent
ua_list = common_user_agents()
File "/usr/lib/calibre/calibre/utils/random_ua.py", line 26, in common_user_agents
return user_agent_data()['common_user_agents']
File "/usr/lib/calibre/calibre/utils/random_ua.py", line 14, in user_agent_data
P('user-agent-data.json', data=True, allow_user_override=False))
File "/usr/lib/calibre/calibre/utils/resources.py", line 89, in get_path
with open(fpath, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/calibre/user-agent-data.json'



Additional info:
* package version(s)
Calibre 6.14.0-1


Steps to reproduce:
run ebook-viewer
This task depends upon

Closed by  Caleb Maclennan (alerque)
Tuesday, 14 March 2023, 18:33 GMT
Reason for closing:  Fixed
Additional comments about closing:  calibre-6.14.0-2
Comment by Elizabeth Fia (fia) - Friday, 10 March 2023, 18:15 GMT
I can confirm this bug. What an ebook reader program -- not even Calibre itself, which would make sense for plugins like FanFicFare -- needs to load a user agent like a web browser for, I have no idea.

It appears to be simply a missing file in the package, user-agent-data.json. I replaced it with https://github.com/eli-schwartz/pkgbuilds/blob/master/calibre-git/user-agent-data.json, and this error disappeared.

Now I simply have a "Segmentation fault" problem, which I have with Calibre itself and is likely an unrelated problem from using the ALHP x86_64-v3 repos, since it happens with the AUR calibre-git also.
Comment by yuanwu (rrenn) - Saturday, 11 March 2023, 04:04 GMT
$ diff calibre_6.11.0-1.txt calibre_6.14.0-1.txt
3421a3422,3425
> calibre /usr/lib/calibre/calibre/gui2/tts/__pycache__/windows_sapi.cpython-310.opt-1.pyc
> calibre /usr/lib/calibre/calibre/gui2/tts/__pycache__/windows_sapi.cpython-310.pyc
> calibre /usr/lib/calibre/calibre/gui2/tts/__pycache__/windows_sapi_config.cpython-310.opt-1.pyc
> calibre /usr/lib/calibre/calibre/gui2/tts/__pycache__/windows_sapi_config.cpython-310.pyc
3431a3436,3437
> calibre /usr/lib/calibre/calibre/gui2/tts/windows_sapi.py
> calibre /usr/lib/calibre/calibre/gui2/tts/windows_sapi_config.py
4379a4386,4387
> calibre /usr/lib/calibre/calibre/utils/windows/__pycache__/winspeech.cpython-310.opt-1.pyc
> calibre /usr/lib/calibre/calibre/utils/windows/__pycache__/winspeech.cpython-310.pyc
4382a4391
> calibre /usr/lib/calibre/calibre/utils/windows/winspeech.py
5152d5160
< calibre /usr/share/calibre/user-agent-data.json
Comment by Caleb Maclennan (alerque) - Saturday, 11 March 2023, 18:47 GMT
I'd be happy to fix this, but it isn't immediately apparent what is going on. It works fine for me, but I'm also not on Wayland I'm on X11 and that seems relevant to the above error. Recent upstream changes in Calibre necessitated several build changes including manually invoking several routines to add resources that should have been bundled as part of the main build commands but were not.

If anybody can figure out how to fix this I'm quite open to patches.
Comment by Caleb Maclennan (alerque) - Saturday, 11 March 2023, 18:55 GMT
Also if somebody that's actually seeing this problem could report a bug upstream to https://bugs.launchpad.net/calibre that would be helpful. I'll follow along but I'm not able to reproduce it yet so I'm probably not the best one to report...
Comment by loqs (loqs) - Saturday, 11 March 2023, 20:37 GMT
Could one of those affected try rebuilding calibre with the attached diff applied?
It uses user-agent-data.json from upstream's official build. An alternative would be to use
python setup.py recent_uas
Though that would involve pulling unversioned files from upstream at build time.

The diff also uses a specific commit for the hyphenation dictionaries to avoid master being used.
Comment by Tedd (tedd) - Sunday, 12 March 2023, 01:03 GMT
@alerque
To be clear, the error 'qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""' also occurs in Calibre 6.11.0-1, and is not related to this issue. Not sure if it is a symptom of something else or just a warning.
Comment by Urnoev (Urnoev) - Sunday, 12 March 2023, 07:50 GMT
I can confirm this is not a Wayland-specific issue, since I am experiencing the same problem with X11.

@loqs
I have built the package with your patch and it seems to have resolved the issue.
Comment by leazar (leazar) - Sunday, 12 March 2023, 16:02 GMT
Same issue here, loqs' patch works for me
Comment by Daniel Kessler (dkess) - Sunday, 12 March 2023, 22:59 GMT
That patch fixes ebook-viewer for me, but it removes all the calibre-related files from from /usr/share/applications.
Comment by Elizabeth Fia (fia) - Monday, 13 March 2023, 03:30 GMT
The patched PKGBUILD appears to work correctly. Thanks for the effort!

I can confirm the issues also happened on both X11 and Wayland on my end.

I still had segmentation faults upon starting either Calibre or the ebook viewer, so I tried running the tests via "calibre-debug --run-tests all". They all ran correctly or were skipped due to being Windows-specific, until it reached test_qt.

"test_qt (calibre.test_build.BuildTest) ... Segmentation fault (core dumped)"

I followed up on my feeling re the unofficial repo being at fault, then, and replaced the extra-x86-64-v3/qt6-base package with the one from extra. This proved to be the solution to *that* problem, so we can rule it out being related here. I have neither the time nor the knowledge to poke about the qt6 codebase and figure out what's mangled there, sorry, so I'm not really sure I should file the bug when I can't follow up on it? Just wanted to clear up that my other issue isn't the same issue after all.
Comment by Celio Grand (c31io) - Monday, 13 March 2023, 10:31 GMT
I fixed it by placing this file back under /usr/share/calibre/
I found the file in btrfs snapshots.
Comment by Jeremy Whiting (jpwhiting) - Monday, 13 March 2023, 22:40 GMT
That user-agent-data.json fixed it here also. Thanks.
Comment by Caleb Maclennan (alerque) - Tuesday, 14 March 2023, 18:33 GMT
Thanks @loqs. Your patch helped, as did the -git package. I took a little different approached and generated the file, then cached it in the build sources and inject it before building, but at least it gets installed now.

Loading...