Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPL animation fails due to absence of FigureCanvasKivy.restore_region() #39

Open
janssen opened this issue Apr 13, 2016 · 3 comments
Open

Comments

@janssen
Copy link
Contributor

janssen commented Apr 13, 2016

See https://gist.github.com/janssen/98598d5859e44687f12cf96ef29570e8.

$ python strip_chart_demo.py 
[INFO              ] [Logger      ] Record log in /home/wjanssen/.kivy/logs/kivy_16-04-12_53.txt
[INFO              ] [Factory     ] 179 symbols loaded
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO              ] [Text        ] Provider: sdl2
[INFO              ] [Kivy        ] v1.9.1
[INFO              ] [Python      ] v2.7.11 |Continuum Analytics, Inc.| (default, Dec  6 2015, 18:08:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
[INFO              ] [OSC         ] using <multiprocessing> for socket
[INFO              ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO              ] [GL          ] OpenGL version <3.0 Mesa 11.0.2>
[INFO              ] [GL          ] OpenGL vendor <Intel Open Source Technology Center>
[INFO              ] [GL          ] OpenGL renderer <Mesa DRI Intel(R) HD Graphics 5500 (Broadwell GT2) >
[INFO              ] [GL          ] OpenGL parsed version: 3, 0
[INFO              ] [GL          ] Shading version <1.30>
[INFO              ] [GL          ] Texture max size <8192>
[INFO              ] [GL          ] Texture max units <32>
[INFO              ] [Window      ] auto add sdl2 input provider
[INFO              ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO              ] [GL          ] NPOT texture support is available
[INFO              ] [Base        ] Start application main loop
[INFO              ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "strip_chart_demo.py", line 76, in <module>
     app.run()
   File "/opt/CBMX/lib/python2.7/site-packages/kivy/app.py", line 828, in run
     runTouchApp()
   File "/opt/CBMX/lib/python2.7/site-packages/kivy/base.py", line 487, in runTouchApp
     EventLoop.window.mainloop()
   File "/opt/CBMX/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 619, in mainloop
     self._mainloop()
   File "/opt/CBMX/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 362, in _mainloop
     EventLoop.idle()
   File "/opt/CBMX/lib/python2.7/site-packages/kivy/base.py", line 327, in idle
     Clock.tick()
   File "/opt/CBMX/lib/python2.7/site-packages/kivy/clock.py", line 515, in tick
     self._process_events()
   File "/opt/CBMX/lib/python2.7/site-packages/kivy/clock.py", line 647, in _process_events
     event.tick(self._last_tick, remove)
   File "/opt/CBMX/lib/python2.7/site-packages/kivy/clock.py", line 406, in tick
     ret = callback(self._dt)
   File "/home/wjanssen/.kivy/garden/garden.matplotlib/backend_kivy.py", line 1029, in _on_timer
     super(TimerKivy, self)._on_timer()
   File "/opt/CBMX/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 1305, in _on_timer
     ret = func(*args, **kwargs)
   File "/opt/CBMX/lib/python2.7/site-packages/matplotlib/animation.py", line 1021, in _step
     still_going = Animation._step(self, *args)
   File "/opt/CBMX/lib/python2.7/site-packages/matplotlib/animation.py", line 827, in _step
     self._draw_next_frame(framedata, self._blit)
   File "/opt/CBMX/lib/python2.7/site-packages/matplotlib/animation.py", line 845, in _draw_next_frame
     self._pre_draw(framedata, blit)
   File "/opt/CBMX/lib/python2.7/site-packages/matplotlib/animation.py", line 858, in _pre_draw
     self._blit_clear(self._drawn_artists, self._blit_cache)
   File "/opt/CBMX/lib/python2.7/site-packages/matplotlib/animation.py", line 898, in _blit_clear
     a.figure.canvas.restore_region(bg_cache[a])
 AttributeError: 'FigureCanvasKivy' object has no attribute 'restore_region'
@janssen
Copy link
Contributor Author

janssen commented Apr 17, 2016

Note this from matplotlib/matplotlib#6295:

Animations can work without restore_region, but the backend needs to have "support_blit" attribute set to False.

It defaults to True.

@lkjell
Copy link

lkjell commented Oct 8, 2017

restore_region() is in class FigureCanvasAgg

    def restore_region(self, region, bbox=None, xy=None):
        renderer = self.get_renderer()
        return renderer.restore_region(region, bbox,xy)

Not sure if one should use FigureCanvasKivy or FigureCanvasKivyAgg. Though I found out that blitting does not work as it should with Agg

@lkjell
Copy link

lkjell commented Oct 8, 2017

I got a working animation with FigureCanvasKivyAgg and blitting. However, there is a memory leak and the animation slows down. Anyone knows how one can reuse texture since I only get seg fault when trying to use the same texture instance? Or a way to destroy the texture instance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants