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

Cannot connect to 'changed': the provided callable is not valid: ShaderMaterial::_shader_changed #90565

Closed
yythlj opened this issue Apr 12, 2024 · 7 comments · Fixed by #91630

Comments

@yythlj
Copy link

yythlj commented Apr 12, 2024

Tested versions

4.3.dev5

System information

windows10 godot4.3.dev5

Issue description

Cannot connect to 'changed': the provided callable is not valid: ShaderMaterial::_shader_changed

this is the full error message, no more info

Steps to reproduce

no

Minimal reproduction project (MRP)

no

@yythlj
Copy link
Author

yythlj commented Apr 12, 2024

and there is no a method or variable call _shader_changed.(has check both addon and project)

@yythlj
Copy link
Author

yythlj commented Apr 12, 2024

image

@Sauermann
Copy link
Contributor

Sauermann commented Apr 15, 2024

Can you please provide more info about how to reproduce this behavior? A minimal reproduction project would help to investigate this issue.
Without these infos, it is nearly impossible to properly investigate this issue.

@Zylann
Copy link
Contributor

Zylann commented Apr 15, 2024

Apparently it happens when my plugin is enabled in Godot 4.3 beta5: Zylann/godot_heightmap_plugin#433, using the Forward+ renderer.
That didn't happen before.
But there is nowhere in my plugin that connects to that signal in that particular way. It's all GDScript and the error mentions a C++ method name (which you'd get with callable_mp).

I ran a quick debugging session and this is the stack trace of the error:

_err_print_error(const char * p_function, const char * p_file, int p_line, const char * p_error, const char * p_message, bool p_editor_notify, ErrorHandlerType p_type) Line 86 (godot4_fork\core\error\error_macros.cpp:86)
_err_print_error(const char * p_function, const char * p_file, int p_line, const char * p_error, const String & p_message, bool p_editor_notify, ErrorHandlerType p_type) Line 110 (godot4_fork\core\error\error_macros.cpp:110)
Object::connect(const StringName & p_signal, const Callable & p_callable, unsigned int p_flags) Line 1380 (godot4_fork\core\object\object.cpp:1380)
Resource::connect_changed(const Callable & p_callable, unsigned int p_flags) Line 178 (godot4_fork\core\io\resource.cpp:178)
call_with_variant_args_helper<Resource,Callable const &,unsigned int,0,1>(Resource * p_instance, void(Resource::*)(const Callable &, unsigned int) p_method, const Variant * * p_args, Callable::CallError & r_error, IndexSequence<0,1> __formal) Line 304 (godot4_fork\core\variant\binder_common.h:304)
call_with_variant_args<Resource,Callable const &,unsigned int>(Resource * p_instance, void(Resource::*)(const Callable &, unsigned int) p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 419 (godot4_fork\core\variant\binder_common.h:419)
CallableCustomMethodPointer<Resource,Callable const &,unsigned int>::call(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 104 (godot4_fork\core\object\callable_method_pointer.h:104)
Callable::callp(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 58 (godot4_fork\core\variant\callable.cpp:58)
CallQueue::_call_function(const Callable & p_callable, const Variant * p_args, int p_argcount, bool p_show_error) Line 222 (godot4_fork\core\object\message_queue.cpp:222)
CallQueue::flush() Line 328 (godot4_fork\core\object\message_queue.cpp:328)
SceneTree::physics_process(double p_time) Line 499 (godot4_fork\scene\main\scene_tree.cpp:499)
Main::iteration() Line 3968 (godot4_fork\main\main.cpp:3968)
OS_Windows::run() Line 1577 (godot4_fork\platform\windows\os_windows.cpp:1577)
widechar_main(int argc, wchar_t * * argv) Line 181 (godot4_fork\platform\windows\godot_windows.cpp:181)
_main() Line 206 (godot4_fork\platform\windows\godot_windows.cpp:206)
main(int argc, char * * argv) Line 220 (godot4_fork\platform\windows\godot_windows.cpp:220)
WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 234 (godot4_fork\platform\windows\godot_windows.cpp:234)
invoke_main() Line 107 (d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:107)

It's still hard to find out what that call is. There is no GDScript involved in here. Also, this is a deferred call, so this doesn't tell what the instigator is.

My only guess is it could come from this:

void Resource::connect_changed(const Callable &p_callable, uint32_t p_flags) {
	if (ResourceLoader::is_within_load() && !Thread::is_main_thread()) {
		// Let the check and connection happen on the main thread, later, since signals are not thread-safe.
		callable_mp(this, &Resource::connect_changed).call_deferred(p_callable, p_flags);
		return;
	}

Which is equally unspecific. My plugin is not using threaded loading either.

@TheRealSlander
Copy link

I can confirm this error in some of my projects (Godot 4.3.dev6)... I worked on it for 4 hours now to understand what happens and I stripped down to a MRP for you guys.

In the video below you can see that adding my component in the tree (instance of it using Ctrl + Shift + A) produces the error when the project is loaded, and removing it from the tree makes the error to disappear.

2024-05-02.21-14-40.mp4

Also, I found out that simply opening the component scene or shader code in the editor (without even instancing the scene in the tree) triggers the error as well. To completely remove the error, I have to close the shader script and close the component scene in the editor as well. Having the associated GDScript code open in the editor does not trigger the error though, only the shader code or the scene.

2024-05-02.21-35-01.mp4

The component I found to work as producing the error is a Control derived node with a MaterialShader in it and a shader code associated and a GDScript to interact with the shader as well. The component is a tool script, but removing the @tool flag does not change anything.

image

I don't know exactly if the problem is the GDScript interaction with the shader, the shader itself or a resource linked to the component... Each time I tried to strip down further the component, the error disappeared...

I hope this will help you to find the source of the error.

Shader Error MRP.zip

By the way, you can see in the videos that the error in the Godot output is sometimes not displayed, I have to toggle a button to make it appear... Probably another bug, if you want me to create an issue for that, just ask, but it only appears with this shader error thing, so maybe it is related (I mean that other errors in other projects are correctly displayed as far as I'm aware of)...

@akien-mga
Copy link
Member

akien-mga commented May 2, 2024

Thanks for the detailed investigation and MRP!

Sorry I missed this report earlier, I might have been able to save you some time by pointing out that it's a recent regression, and could thus be bisected. It was introduced in 4.3-dev5, so the culprit should be a PR from https://godotengine.github.io/godot-interactive-changelog/#4.3-dev5
Edit: I'll bisect it now.

I can reproduce the error in my own recent game jam project: https://github.com/johncoffee/ngj-2024

But the provided MRP will make it much easier to debug and fix the issue, so the effort was well spent.
I can confirm the bug with that MRP too, in 4.3-dev5, 4.3-dev6, and latest b9e0223.

@akien-mga
Copy link
Member

Bisected to #88561, CC @RandomShaper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Bad
Development

Successfully merging a pull request may close this issue.

6 participants