Opened 5 years ago
Closed 5 years ago
#3417 closed defect (fixed)
labels don't work in headless mode
Reported by: | Greg Couch | Owned by: | Tom Goddard |
---|---|---|---|
Priority: | moderate | Milestone: | |
Component: | Graphics | Version: | 1.0 |
Keywords: | Cc: | pett | |
Blocked By: | Blocking: | ||
Notify when closed: | Platform: | all | |
Project: | ChimeraX |
Description
labels don't work because they're are using the GUI to get the font information.
Attachments (1)
Change History (6)
comment:2 by , 5 years ago
Used switch.cxc from the G-Protein Switch Regions example on the image gallery, http://www.rbvi.ucsf.edu/chimerax/gallery.html and added another line at the end to save an image. Generated the backtrace with:
$ gdb chimerax-daily (gdb) run --offscreen --exit switch.cxc
Which results in:
Program received signal SIGSEGV, Segmentation fault. 0x00007fffd4ee7353 in QGuiApplication::font() () from /home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5
And the C++ backtrace starts with:
#0 0x00007fffd4ee7353 in QGuiApplication::font() () from /home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #1 0x00007fffd4fc48dd in QFontDatabase::load(QFontPrivate const*, int) () from /home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #2 0x00007fffd4f9b71a in QFontPrivate::engineForScript(int) const () from /home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #3 0x00007fffd4fcc0f3 in QTextEngine::fontEngine(QScriptItem const&, QFixed*, QFixed*, QFixed*) const () from /home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #4 0x00007fffd4fcdb8e in QTextEngine::shapeText(int) const () from /home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #5 0x00007fffd4fcea6c in QTextEngine::shape(int) const () from /home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #6 0x00007fffd4fd51e8 in QTextEngine::boundingBox(int, int) const () from /home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #7 0x00007fffd4fb99f9 in QFontMetrics::boundingRect(QString const&) const () from /home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #8 0x00007fffd02ec232 in meth_QFontMetrics_boundingRect () from /home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/PyQt5/QtGui.so #9 0x00007ffff7905263 in _PyMethodDef_RawFastCallKeywords (method=0x7fffd0613d60 <methods_QFontMetrics+64>, self=<optimized out>, args=0x2da83c0, nargs=1, kwnames=<optimized out>) at Objects/call.c:694
And running "chimerax-daily --offscreen --exit switch.cxc" directly gives:
Fatal Python error: Segmentation fault Thread 0x00007fc953404700 (most recent call first): File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/threading.py", line 300 in wait File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/threading.py", line 552 in wait File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/threading.py", line 1175 in run File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/threading.py", line 926 in _bootstrap_inner File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/threading.py", line 890 in _bootstrap Current thread 0x00007fc97d311740 (most recent call first): File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/graphics/drawing.py", line 2088 in text_image_rgba File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/label/label2d.py", line 605 in _update_label_image File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/label/label2d.py", line 591 in _update_graphics File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/label/label2d.py", line 555 in draw File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/graphics/drawing.py", line 1440 in _draw_multiple File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/graphics/drawing.py", line 1478 in draw_overlays File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/graphics/view.py", line 173 in draw File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/graphics/view.py", line 457 in image File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/image_formats/save.py", line 113 in save_image File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/image_formats/__init__.py", line 24 in save File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/save_command/cmd.py", line 73 in provider_save File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2805 in run File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/save_command/cmd.py", line 60 in cmd_save File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2805 in run File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/core/commands/run.py", line 31 in run File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/core/scripting.py", line 139 in open_command_script File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/core_formats/__init__.py", line 37 in open File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/open_command/cmd.py", line 359 in collated_open File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/open_command/cmd.py", line 146 in provider_open File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2805 in run File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/open_command/cmd.py", line 95 in cmd_open File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2805 in run File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/chimerax/core/commands/run.py", line 31 in run File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/ChimeraX_main.py", line 748 in init File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/site-packages/ChimeraX_main.py", line 897 in <module> File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/runpy.py", line 85 in _run_code File "/home/socr/a/chimera/chimerax_daily/lib/python3.7/runpy.py", line 193 in _run_module_as_main Segmentation fault
by , 5 years ago
Attachment: | switch.cxc added |
---|
G-Protein Switch Regions switch.cxc with "save switch.png" at end
comment:4 by , 5 years ago
So QFontMetrics.boundingRect() crashes if it is not a Qt GUI application. Discussed here
https://stackoverflow.com/questions/31732698/getting-font-metrics-without-gui-console-mode
Not clear there is any solution. Also not clear why Qt needs a GUI to measure font sizes. To make labels ChimeraX of course has to know font sizes.
comment:5 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Greg fixed this using Qt offscreen platform.
Begin forwarded message:
From: Greg Couch
Subject: Re: ChimeraX offscreen rendering
Date: July 9, 2020 at 6:22:59 PM PDT
To: Tom Goddard , Eric Pettersen
Cc: Scooter Morris , Chimera Staff
I had been looking into this and was able to get offscreen rendering of labels to work. It turned out to be fairly trivial. Qt has the concept of platform backends, eg., X11, and there happens to be an offscreen backend. Using the Qt offscreen backend when ChimeraX is in offscreen mode allows the QFont code to work. I've attached an offscreen rendering of Elaine's G-Protein Switch Regions image that was rendered completely offscreen on plato.
-- Greg