Skip to content

Crashes under Wayland, because some parts are assuming X #266

@chris-morgan

Description

@chris-morgan

I’m filing this here because I’m not certain where it should go and CQ-editor is where I observe it, but it could belong on OCP or OpenCascade or something.

Environment: Arch Linux, Sway window manager, and OCP, CadQuery and CQ-editor master, via these AUR packages:

  • python-ocp-git 7.5.RC1.r13.ge1df346-1 (corresponding to CadQuery/OCP@e1df346), also observed with python-ocp 7.5.RC1-2;
  • python-cadquery-git 2.1.r138.g2b7f39b-1 (corresponding to CadQuery/cadquery@2b7f39b);
  • python-cq-editor-git 0.2.r22.gfbf8c8c-1 (corresponding to fbf8c8c).

Result of running CQ-editor:

With XWayland enabled, the CQ-editor window opens very briefly in a regular Wayland window, and then the process dies:

$ cq-editor
Namespace(filename=None)
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  3 (X_GetWindowAttributes)
  Resource id in failed request:  0x3
  Serial number of failed request:  10
  Current serial number in output stream:  11
$ [exit code 1]

Looks like something is calling an X function with a Wayland id.

With XWayland pseudo-disabled (it’s still running, but I unset DISPLAY), it doesn’t start:

$ DISPLAY= cq-editor
Traceback (most recent call last):
  File "/usr/bin/cq-editor", line 33, in <module>
    sys.exit(load_entry_point('CQ-editor==0.3.0.dev0', 'gui_scripts', 'cq-editor')())
  File "/usr/lib/python3.9/site-packages/cq_editor/__main__.py", line 16, in main
    win = MainWindow()
  File "/usr/lib/python3.9/site-packages/cq_editor/main_window.py", line 35, in __init__
    self.viewer = OCCViewer(self)
  File "/usr/lib/python3.9/site-packages/cq_editor/widgets/viewer.py", line 54, in __init__
    self.canvas = OCCTWidget()
  File "/usr/lib/python3.9/site-packages/cq_editor/widgets/occt_widget.py", line 35, in __init__
    self.display_connection = Aspect_DisplayConnection()
OCP.Aspect.Aspect_DisplayConnectionDefinitionError: Can not connect to the server ""
$ [exit code 1]

Diagnosis: Qt supports Wayland, and so CQ-editor defaults to rendering to Wayland, but it looks like OCP or something like it is using X APIs where it should be using Qt APIs which abstract over the platform.

Workaround: force CQ-editor to use X instead of Wayland by setting the environment variable QT_QPA_PLATFORM=xcb, or by passing the command line arguments --platform xcb.

Other remarks: I strongly desire proper Wayland support, because I’m using fractional scaling (1.5×), which Sway handles fine, but XWayland renders at 2× and scales down, which mangles it terribly.

I’m not sure where the error message comes from; I haven’t delved in a debugger to find out (because I’m not sure quite how to).

If this is out of CadQuery’s control for whatever reason, then until it can be fixed, CQ-editor should be adjusted to default to xcb instead of wayland. No idea how you do that, but Krita does it (because it’s mostly broken under Wayland).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions