Repository: kivy/kivy

Issue:
SDL2 - crash on loading asyncimage loading gif?
relevant log:

Traceback (most recent call last):
  File "/home/chozabu/git/KivEntEd/main.py", line 1289, in <module>
    KivEntEd().run()
  File "/usr/local/lib/python2.7/dist-packages/kivy/app.py", line 825, in run
    runTouchApp()
  File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 484, in runTouchApp
    EventLoop.window.mainloop()
  File "/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py", line 364, in mainloop
    self._mainloop()
  File "/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py", line 268, in _mainloop
    EventLoop.idle()
  File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 324, in idle
    Clock.tick()
  File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 482, in tick
    self._process_events()
  File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 614, in _process_events
    event.tick(self._last_tick, remove)
  File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 373, in tick
    ret = callback(self._dt)
  File "/home/chozabu/git/KivEntEd/ui_elements.py", line 121, in initUI
    self.screenShot.source = serverURL+"/downloadSS?fullname="+self.info['filename']+".png"
  File "kivy/properties.pyx", line 377, in kivy.properties.Property.__set__ (kivy/properties.c:4346)
  File "kivy/properties.pyx", line 409, in kivy.properties.Property.set (kivy/properties.c:4861)
  File "kivy/properties.pyx", line 460, in kivy.properties.Property.dispatch (kivy/properties.c:5437)
  File "kivy/_event.pyx", line 1046, in kivy._event.EventObservers.dispatch (kivy/_event.c:10980)
  File "/usr/local/lib/python2.7/dist-packages/kivy/uix/image.py", line 327, in _load_source
    anim_delay=self.anim_delay)
  File "/usr/local/lib/python2.7/dist-packages/kivy/loader.py", line 432, in image
    client = ProxyImage(self.loading_image,
  File "/usr/local/lib/python2.7/dist-packages/kivy/loader.py", line 163, in _get_loading_image
    self._loading_image = ImageLoader.load(filename=loading_png_fn)
  File "/usr/local/lib/python2.7/dist-packages/kivy/core/image/__init__.py", line 385, in load
    im = loader(filename, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/kivy/core/image/**init**.py", line 164, in **init**
    self._data = self.load(filename)
  File "/usr/local/lib/python2.7/dist-packages/kivy/core/image/img_sdl2.py", line 34, in load
    raise Exception('SDL2: Unable to load image')
Exception: SDL2: Unable to load image



Discussion:
Loading animated gifs directly with sdl2 looks problematic - so I updated the PIL image provider to work with updated kivy instead: https://github.com/kivy/kivy/pull/2695

I imagine this issue may have been addressed before, if SDL is the default image provider on IOS?

I'm not sure about the ios defaults, but our goal is to use sdl2 providers on all platforms.

Then I suspect it will be necessary to use a different lib for animated gifs inside the sdl2 image provider? That or I am seriously missing something in the sdl2_image docs (and code, and search)


Resolving patch:
diff --git a/kivy/core/image/img_sdl2.py b/kivy/core/image/img_sdl2.py
--- a/kivy/core/image/img_sdl2.py
+++ b/kivy/core/image/img_sdl2.py
@@ -20,7 +20,7 @@ def _ensure_ext(self):
     @staticmethod
     def extensions():
         '''Return accepted extensions for this loader'''
-        return ('bmp', 'gif', 'jpg', 'jpeg', 'lbm', 'pcx', 'png', 'pnm', 'tga', 'tiff',
+        return ('bmp', 'jpg', 'jpeg', 'lbm', 'pcx', 'png', 'pnm', 'tga', 'tiff',
                 'webp', 'xcf', 'xpm', 'xv')
 
     @staticmethod
@@ -43,10 +43,6 @@ def load(self, filename):
 
     @staticmethod
     def save(filename, width, height, fmt, pixels, flipped):
-        # TODO implement the save for sdl2
-        #surface = SDL2.image.fromstring(
-        #        pixels, (width, height), fmt.upper(), False)
-        #SDL2.image.save(surface, filename)
         _img_sdl2.save(filename, width, height, fmt, pixels, flipped)
         return True
 


Test patch: