Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@ But the other way around, running a Qt canvas in e.g. the trio loop, works fine:


There are known issue with Qt widgets that render directly to screen (i.e. widgets that obtain ``widget.winId()``),
related to how they interact with other widgets and in docks.
If you encounter such issues, consider using the bitmap present-method. That way, the rendering happens
off-screen, and is than provided to Qt as an image. This is a safer approach, albeit lowers the performance (FPS)
somewhat when the render area is large.
related to how they interact with other widgets and in docks. Therefore, the Qt backend defaults to the 'bitmap' present method.
If high FPS is a big deal, you can easily set the present method to 'screen'. If you do this, be aware of possible problems,
especially in some Linux environment and when the widget is in a QDockWidget.

.. code-block:: py

widget = QRenderWidget(present_method="bitmap")
widget = QRenderWidget(present_method="bitmap") # safe (default)
widget = QRenderWidget(present_method="screen") # probably higher fps, but can cause problems


Support for wx
Expand Down
14 changes: 7 additions & 7 deletions rendercanvas/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from .base import WrapperRenderCanvas, BaseCanvasGroup, BaseRenderCanvas, BaseLoop
from ._coreutils import (
logger,
SYSTEM_IS_WAYLAND,
get_alt_x11_display,
get_alt_wayland_display,
select_qt_lib,
Expand Down Expand Up @@ -372,12 +371,13 @@ def _rc_gui_poll(self):
def _rc_get_present_info(self, present_methods):
# Select the method
the_method = present_methods[0]
if SYSTEM_IS_WAYLAND and "bitmap" in present_methods:
# Trying to render to screen on Wayland segfaults. This might be because
# the "display" is not the real display id. We can tell Qt to use
# XWayland, so we can use the X11 path. This worked at some point,
# but later this resulted in a Rust panic. So, until this is sorted
# out, we fall back to rendering via an image.
if "bitmap" in present_methods:
# There are various known problems with rendering to screen on Qt.
# Some relate to getting a wgpu surface, and Qt not able to provide a display-id on Linux.
# Some relate to Qt simply not liking it when an application bypasses Qt's compositing.
# For an overview see: https://github.com/pygfx/wgpu-py/issues/688
# To avoid problems, and be consistent, Qt defaults to 'bitmap' present.
# In cases where the extra performance of 'screen' present mode matters, ppl can easily override it.
the_method = "bitmap"

# Apply
Expand Down
6 changes: 3 additions & 3 deletions rendercanvas/wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from ._coreutils import (
logger,
SYSTEM_IS_WAYLAND,
get_alt_x11_display,
get_alt_wayland_display,
)
Expand Down Expand Up @@ -287,8 +286,9 @@ def _rc_gui_poll(self):
def _rc_get_present_info(self, present_methods):
# Select method
the_method = present_methods[0]
if SYSTEM_IS_WAYLAND and "bitmap" in present_methods:
the_method = "bitmap" # also see qt.py
if "bitmap" in present_methods:
# Default to 'bitmap', also see note in qt.py
the_method = "bitmap"

# Apply
if the_method == "screen":
Expand Down