godotengine / godotengine/godot-docs

Multiple threads tutorial should use Image.load() as a useful example

Open
#4,389 0 comments 2 reactions 0 assignees View on GitHub
area:manual enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version:**
3.2.3.stable

**Issue description:**
I had an issue with the when a 7Mb jpg file of a satellite image took 450ms in [load_jpg_from_buffer()](https://docs.godotengine.org/en/stable/classes/class_image.html?highlight=load_jpg_from_buffer#class-image-method-load-jpg-from-buffer) for godot to uncompress/decode. This froze everything up and caused network polling problems.
See https://github.com/godotengine/godot/issues/20056#issuecomment-729879361

I think I fixed it by putting my Image loader into a thread.

At the moment the multiple threads tutorial page (link below) uses a completely contrived example of incrementing a counter.

It would be more useful if the example instead applied to decoding a big binary object (like a jpg) as this is likely to be the first application a programmer is going to be forced to use threads in godot for. My implementation is [here](https://github.com/goatchurchprime/tunnelvr/blob/master/ImageSystem.gd#L34).

Then you can have a hint on the `Image.load()` documentation that this can hang the system if it's a big file, but there is a solution. I do not think that `ResourceInteractiveLoader` helps here because (a) it doesn't apply to downloaded files in the `user://` directory, and (b) that interactive loader will still call the image loading function as a single frame-hanging blob.

**URL to the documentation page (if already existing):**
https://docs.godotengine.org/en/stable/tutorials/threads/using_multiple_threads.html

See also https://github.com/godotengine/godot-docs/issues/2148

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.