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

Example project missing sprites and runtime errors #79

Open
pabaucom opened this issue Jul 28, 2023 · 4 comments
Open

Example project missing sprites and runtime errors #79

pabaucom opened this issue Jul 28, 2023 · 4 comments

Comments

@pabaucom
Copy link
Contributor

The example project has missing sprites and runtime errors when viewing the vertical list or horizontal list options:

ERROR:DLIB: Failed to load image: 'Image not of any known type, or corrupt'
WARNING:SCRIPT: failed to load image (-2)
DEBUG:SCRIPT: Unable to load image
ERROR:SCRIPT: gooey/image_cache.lua:60: failed to delete texture 'https://dummyimage.com/40x40/f70/f70.png' (result = -5)

That external url is referenced in:

  • dynamiclist.gui_script
  • horizontallist.gui_script

Should these colored square images be included in the example.atlas instead of pulled from external source?

@britzl
Copy link
Owner

britzl commented Jul 29, 2023

Hmm, the idea was to show async loading of images from an external source, but it seems like something with the dummyimage.com service has changed.

@pabaucom
Copy link
Contributor Author

I see. That's a very useful thing to have now that I think about it. I've been digging into this since the magenta and pink shaded images (salmon, pink, and coral) do work consistently while the others consistently do not work. The urls work fine when opened in a browser, even clicking them directly from the debugger watch.

I see that it is trying to read and write to a file it is opening in appdata on Windows that is not a valid path:

"C:\Users\Paul\AppData\Roaming\Gooey\https://dummyimage.com/40x40/f00/f00.png"

This may have something to do with it or nothing to do with it. I will see if I can get this working as expected since it is very useful and the examples are useful to new devs for baseline best practices.

@pabaucom
Copy link
Contributor Author

pabaucom commented Jul 29, 2023

tl;dr: dummyimage.com is serving webp files for some images and png for others, and Defold can't open the webp files.

I have fixed the issue with the local image cache on Windows, and it now writes the files to disk as expected. I have not tested on linux or mac, but it should work on those too given the nature of how the filename is transformed now.

I can put in a PR for this simple change. The current image_cache.lua module will never be able to write/read these files to disk on Windows. The fix would be relevant if someone tried to used the library as-is with valid external image sources. Let me know if you want to review a PR on it since you may want to go a different direction on the example code given the following:

After getting it to read/write the files to disk as expected, it still considered some images invalid. After doing some digging into the Defold source, it appears that the stb_image library that is used for loading images can't load the webp files.

It wasn't obvious they were webp files until I saved them directly from the browser. They also cannot be imported into the Defold editor when downloaded (giving the same error of unknown format).

The dummyimage.com site is serving compatible pngs for some images.

Not valid, chrome saves this as a webp file: https://dummyimage.com/40x40/ff0/ff0.png
Valid, chrome saves as regular png: https://dummyimage.com/40x40/f0f/f0f.png

I don't know if Defold should support webp files or if stb will ever support it (this may answer both questions).

This issue should probably be closed since it is just an example that is not working. Someone that really needs this to work should hopefully find this issue and proceed with using working external image sources in their project. Let me know if you want a PR on the Windows file path fix in image_cache.lua.

@britzl
Copy link
Owner

britzl commented Jul 30, 2023

I can put in a PR for this simple change

Please do!

dummyimage.com is serving webp files for some images and png for others

That is annoying...

I don't know if Defold should support webp files

Not at runtime using image.load(). But loading WebP images using an extension is ofc possible.

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