kivy / kivy

Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS
https://kivy.org
MIT License
17.79k stars 3.07k forks source link

Texture loading from file crashes kivy without exeption -- (when loading atlas) #8786

Open bela127 opened 4 months ago

bela127 commented 4 months ago

Software Versions

Describe the bug Kivy crashs (without showing any error) when loading a "kivy.atlas.Atlas". (The Bug is probably not Atlas related but a general bug with Image loading)

I tracked down the source of the Bug quite far, it originates in the Texture loading process when "Texture.create_from_data" is called in "ImageLoaderBase.populate()" .

[Texture == kivy.graphics.texture.Texture] Sadly i could not debug Texture because it is cython code, so you have to find the bug in there ;)

Expected behavior No crash.

To Reproduce

import kivy
kivy.require('2.3.0')
from pathlib import Path

from kivy.logger import Logger, LOG_LEVELS
Logger.setLevel(LOG_LEVELS["debug"])

from kivy.atlas import Atlas

from kivy.app import App
from kivy.uix.button import Button

class MyApp(App):

    def build(self):
        Logger.warning(kivy.__version__)
        kivy_data_path = Path(kivy.kivy_data_dir)
        Logger.warning(kivy_data_path)
        atlas_path = kivy_data_path / "./images/defaulttheme.atlas"
        Logger.warning(atlas_path)
        atlas = Atlas(str(atlas_path.as_posix()))
        #Logger.warning(atlas.original_textures)
        return Button()

if __name__ == '__main__':
    MyApp().run()

Logs

start:
[INFO   ] [Logger      ] Record log in C:\Users\chris\.kivy\logs\kivy_24-07-21_83.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.4.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.3.1
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.7.0
[INFO   ] [Kivy        ] v2.3.0
[INFO   ] [Kivy        ] Installed at "C:\Users\chris\Code\kivy_training\.venv\Lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.12.4 (tags/v3.12.4:8e8a4ba, Jun  6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\chris\Code\kivy_training\.venv\Scripts\python.exe"
[INFO   ] [Logger      ] Purge log fired. Processing...
[INFO   ] [Logger      ] Purge finished!
[INFO   ] [Factory     ] 195 symbols loaded
[DEBUG  ] [Cache       ] register <kv.resourcefind> with limit=None, timeout=60
[DEBUG  ] [Cache       ] register <kv.lang> with limit=None, timeout=None
[DEBUG  ] [Cache       ] register <kv.image> with limit=None, timeout=60
[DEBUG  ] [Cache       ] register <kv.atlas> with limit=None, timeout=None
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[DEBUG  ] [Cache       ] register <kv.texture> with limit=1000, timeout=60
[DEBUG  ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600       
[DEBUG  ] [Cache       ] register <kv.graphics.texture> with limit=None, timeout=None
[INFO   ] [Text        ] Provider: sdl2
[DEBUG  ] [App         ] Loading kv <c:\Users\chris\Code\kivy_training\kivy_training\my.kv>
[DEBUG  ] [App         ] kv <c:\Users\chris\Code\kivy_training\kivy_training\my.kv> not found
[WARNING] 2.3.0
[WARNING] C:\Users\chris\Code\kivy_training\.venv\Lib\site-packages\kivy\data     
[WARNING] C:\Users\chris\Code\kivy_training\.venv\Lib\site-packages\kivy\data\images\defaulttheme.atlas
[DEBUG  ] [Atlas       ] Load <C:\Users\chris\Code\kivy_training\.venv\Lib\site-packages\kivy\data\images\defaulttheme.atlas>
[DEBUG  ] [Atlas       ] Need to load 1 images
[DEBUG  ] [Atlas       ] Load <C:\Users\chris\Code\kivy_training\.venv\Lib\site-packages\kivy\data\images\defaulttheme-0.png>
[DEBUG  ] [ImageSDL2   ] Load <C:\Users\chris\Code\kivy_training\.venv\Lib\site-packages\kivy\data\images\defaulttheme-0.png>
terminated: exit code 1
BPConsSA commented 4 days ago

I am getting the same issue Used the same logger enabled script that bela127 created. Final commands

    atlas = Atlas(atlas_path)
    Logger.warning("Atlas loaded")
    Logger.warning(atlas.textures.keys())

On loading the first atlas png file [DEBUG ] [Atlas ] Load [DEBUG ] [Atlas ] Need to load 2 images [DEBUG ] [Atlas ] Load [DEBUG ] [ImageSDL2 ] Load <C:\Data\PyProjects\BPCTst\icons-0.png>

The kernel died, restarting...