-
Notifications
You must be signed in to change notification settings - Fork 320
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
arcade.SpriteList "atlas" property sometimes does not exist #1882
Comments
I can replicate this. Thank you for writing the example. To my understanding, automatic initialization would undermine the intent of Having the
I strongly agree the behavior should be explained better, including linking the relevant programming guide section from the At the moment, I think the best approach is ensuring arcade/arcade/sprite_list/sprite_list.py Lines 108 to 109 in 1e60dff
This has two benefits over the
The unresolved question is how |
Is Instead of returning None (I see you had to add type: ignore comments in a lot of places - I expect I would have to do the same, or add if-checks, which I am not looking forward to), I was thinking of just raising a better error than AttributeError, like SpriteListNotInitializedError or something like that. But you say that adding logic to the atlas getter might have a performance cost, so I will trust you on that. (To me, that seemed insignificant, but you probably know better.) |
tl;dr:
I'm not sure. Although atlases currently initialize GPU resources, they could be given deferred initialization support. That idea may have come up before in the context of atlas pre-packing tools. Regardless, this is a separate issue and best discussed with @einarf since he has the most thorough understanding of the subject.
It was the most explicit option, although I agree it is very ugly.
After discussing it with einarf on Discord, I agree with the exception approach. The Is there pre-existing exception type the new exception type could inherit from?
We need to translate the benchmarking examples cspotcode has posted into documentation.
I don't. That's why I tagged you on the PR to review it: I wanted you and einarf to tell me how / why it's wrong or risky. |
Only if I add type: ignore checks like in the PR.
I looked in the Actually, if you look at the
I don't know about "wrong", I was only commenting on your claim that there would be a performance hit to adding an if-check in the |
Fix already merged |
Bug Report
System Info
Run this and paste the output here: python -m arcade
Arcade 3.0.0.dev24
vendor: Intel
renderer: Intel(R) UHD Graphics
version: (3, 3)
python: 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
platform: win32
pyglet version: 2.0.8
PIL version: 9.4.0
Actual behavior:
The "atlas" property of SpriteList crashes with an AttributeError if there is no window or if the SpriteList is lazy and has not been fully initialized (init_deferred) yet. The reason is that "self._atlas" is not set at all in these cases.
The error is very deceptive:
AttributeError: 'SpriteList' object has no attribute '_atlas'. Did you mean: 'atlas'?
Expected behavior:
I would expect calling the "atlas" property to, e.g., do one of
Steps to reproduce/example code:
The text was updated successfully, but these errors were encountered: