Open Gyrth opened 2 years ago
I think this is actually a side-effect of remote inspector, I have seen this in the past. It is trying to access image
but for some reason I think it re-creates the object client-side just to provide it, but in reality it is not cached.
Similarly if you try to access image
in script it might also create a new image each time because it does not actually store such object. Only the data inside is stored. In fact image
is not even a documented property, I think it only exists because of serialization purposes.
You can also see some of that in master
, the data is cached as a Ref<Image>
only in some conditions in editor:
https://github.com/godotengine/godot/blob/ed395c6b99915809347a87b0d65220c256d6ec3f/servers/rendering/renderer_rd/renderer_storage_rd.cpp#L1032-L1040
Then in all the other cases, it gets the data probably from the graphics card or whatever cache if any, but because it gets it as raw bytes, it has to wrap it inside an Image
object:
https://github.com/godotengine/godot/blob/ed395c6b99915809347a87b0d65220c256d6ec3f/servers/rendering/renderer_rd/renderer_storage_rd.cpp#L1041-L1044
Which explains why you may get a different instance of an Image
object each time.
Thank you for checking it out. So is this considered a bug worth fixing?
I'm not sure it is even a bug, it looks like it works as intended, as confusing as it looks. I wonder why it shows there in the first place. Also I have a vague memory that this was raised before, but I can't find the issue if any.
Some other slightly related stuff from the past: https://github.com/godotengine/godot/issues/18801#issuecomment-388607918
Godot version
v3.4-stable
System information
Manjaro Linux, GLES3, NVIDIA Geforce GTX 1060 495.44
Issue description
In my script I create a detail texture in the
_ready
function for bullet holes. It works flawlessly but I noticed the object id of the image object increase steadily. So this might be a memory leak, or needless swapping of textures in the engine.Steps to reproduce
Detail Albedo
.Image
increase.Minimal reproduction project
BugReport.zip