kivy-garden / garden.matplotlib

Matplotlib backends using kivy
MIT License
104 stars 50 forks source link

Rendering is slow on Raspberry Pi #60

Closed mcu101 closed 6 years ago

mcu101 commented 6 years ago

Hi everybody and thanks again for developing your matplotlib integration with Kivy.

In case you were wondering, the examples run on a Raspberry Pi Model 3 B+ with the default Raspbian OS as of Sep 28th 2018. Unfortunately, the GUI response is very slow. However, this seems to be an issue with the graphics handling within the Kivy backend rather than with the Pi's processing power. Here's my evidence:

I'm currently and simultaneously interacting with my Pi in two different ways:

1) Computer monitor through the HDMI port, keyboard, and mouse. 2) VNC Viewer connection from a laptop runing Windows 10.

Note that VNC Viewer cannot display Kivy GUIs because it lacks support for Open GL rendering for the Pi. So, when I run the examples, or any other Kivy app, I can see the Kivy GUI through the HDMI monitor but not through my VNC Viewer connection. Using this setup, I noticed that the garden.matplotlib examples present a very annoying mouse cursor lag through the actual HDMI monitor. But, on the VNC Viewer connection, and while keeping the Kivy GUI runing, I'm still able to run Chromium and surf the web without any graphics lag. So that's how I know that the problem cannot be attributed to the Pi being too slow to handle this use case.

I'd be great if we could figure out a way to speed up the graphics rendering for Raspberry Pi. I wouldn't mind contributing some development if I could get some suggestions from some of the more experienced contributors.

Thanks again for your great work.

matham commented 6 years ago

This is unfortunately due to matplotlib being pretty slow. There isn't much we can do about this - short of rewriting the library, which wouldn't help that much anyway, given that mpl is inherently somewhat slow.

May I suggest you use kivy.garden.graph instead if that has sufficient options for you?

mcu101 commented 6 years ago

@matham Thanks for your reply. I did try kivy.garden.graph but its real-time graphics rendering looked too "laggy" and "choppy" on the Pi for me to present it as a professional solution at work, and that was just for plotting from a simple random number generator.

For the moment, I've switched back to using a spare Win 10 laptop to monitor the sensors I'm working with and using Kivy and matplotlib on separate windows. I have matplotlib running on the main thread and the Kivy GUI on a separate thread. Otherwise, matplotlib blocks the GUI for the user.