Open Delsin-Yu opened 3 weeks ago
When the button is pressed, ResourceLoader.load(file_path, "", ResourceLoader.CACHE_MODE_IGNORE)
is called for every file in the project. This results in force reloading of the script of your addon itself. This makes later logic heap-reuse-after-free.
You can use ResourceLoader.get_recognized_extensions_for_type("AtlasTexture")
to get a list of extensions to filter out the correct resource files.
I see. Should precautions be taken to prevent such use cases from crashing the engine?
Made a MRP that crashes the game instead of the editor: test-4.zip
In short:
res://demo.gd
:
extends Control
func _on_button_pressed() -> void:
var res := ResourceLoader.load("res://demo.gd", "", ResourceLoader.CACHE_MODE_IGNORE)
print(self)
print(res)
I stumbled across this problem today and when trying to find a work-around, noticed that this also causes an editor crash:
func hot_reload():
get_script().reload(true)
Could the root cause be the same?
@aekobear I guess so, since conceptually, they are doing the same thing in the end, but we might need someone familiar with the ResourceLoader::load
and GDScript::reload
to confirm.
Tested versions
v4.3.stable.official [77dcf97d8] v4.4.dev.custom_build [8004c7524] (master)
System information
Godot v4.4.dev (8004c7524) - Windows 10.0.17763 - Multi-window, 4 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Ti (NVIDIA; 32.0.15.6109) - AMD Ryzen 9 5900X 12-Core Processor (24 threads)
Issue description
A plugin I'm working on encountered this issue. I tried to repeat the MRP for several times and get a sets of different stack traces as follows:
The code snippets related to this issue:
Headers are the same:
Tempt 1
Tempt 2
Tempt 3
Tempt 4
Steps to reproduce
AtlasTextue Manager
window at the top left dock.icon.svg
image asset in theFileSystem
window.Scan in Project
button in theAtlasTextue Manager
window.https://github.com/user-attachments/assets/ab24c711-5d91-48d2-88bd-8ea74ba2734a
Minimal reproduction project (MRP)
MRP-GDScript-Crash.zip