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

Unexpected behaviour of set_process(false) #94710

Open
Svarshick opened this issue Jul 24, 2024 · 5 comments
Open

Unexpected behaviour of set_process(false) #94710

Svarshick opened this issue Jul 24, 2024 · 5 comments

Comments

@Svarshick
Copy link

Svarshick commented Jul 24, 2024

Tested versions

4.2.stable

System information

Godot v4.2.2.stable.mono - Ubuntu Core 22 - Wayland - Vulkan (Forward+) - integrated Intel(R) Graphics (ADL GT2) - 12th Gen Intel(R) Core(TM) i5-12500H (16 Threads)

Issue description

I found out post about the same problem: #7894
As I understood the answer from reduz

We could add an extra check i guess

It was considered as bug. Let me know if not, please.
Issue was closed as completed.

Steps to reproduce

I created 2D Scene (Main) and added main.gd:

extends Node2D

var _active = false

func _process(delta):
	print("_process here!")

func _enter_tree():
	set_process(_active)
	print("Parent entered!")

Output:
image

Minimal reproduction project (MRP)

bug.zip

@huwpascoe
Copy link
Contributor

_active should be false for the process to be disabled?

@Svarshick
Copy link
Author

_active should be false for the process to be disabled?
Oh, I am sorry. Yes, it should be false. I may checked if it works with another parameters and forgot to change it

@huwpascoe
Copy link
Contributor

Concluded testing, it only works with _ready.

func _init():
	set_process(false) # FAIL

func _enter_tree():
	set_process(false) # FAIL

func _ready():
	set_process(false) # OK

Don't know if this intended behavior or not.

@kleonc
Copy link
Member

kleonc commented Jul 25, 2024

I found out post about the same problem: #7894 As I understood the answer from reduz

We could add an extra check i guess

It was considered as bug. Let me know if not, please. Issue was closed as completed.

#7894 describes a different problem than what is reported in here, and #7894 seems to be already solved/fixed indeed.

This issue is rather a duplicate of #31946. Basically if _process etc. is present/overridden within the script, then the relevant processing is enabled internally on NOTIFICATION_READY, which results in overwriting any previously set value (e.g. by set_process(_active) within _enter_tree like in the MRP):

godot/scene/main/node.cpp

Lines 193 to 215 in e343dbb

case NOTIFICATION_READY: {
if (GDVIRTUAL_IS_OVERRIDDEN(_input)) {
set_process_input(true);
}
if (GDVIRTUAL_IS_OVERRIDDEN(_shortcut_input)) {
set_process_shortcut_input(true);
}
if (GDVIRTUAL_IS_OVERRIDDEN(_unhandled_input)) {
set_process_unhandled_input(true);
}
if (GDVIRTUAL_IS_OVERRIDDEN(_unhandled_key_input)) {
set_process_unhandled_key_input(true);
}
if (GDVIRTUAL_IS_OVERRIDDEN(_process)) {
set_process(true);
}
if (GDVIRTUAL_IS_OVERRIDDEN(_physics_process)) {
set_physics_process(true);
}

See also godotengine/godot-proposals#1008.


Tested versions

4.2.stable

System information

Godot v4.2.2.stable.mono - Ubuntu Core 22 - Wayland - Vulkan (Forward+) - integrated Intel(R) Graphics (ADL GT2) - 12th Gen Intel(R) Core(TM) i5-12500H (16 Threads)

Note that in the 4.2.2 docs (thus in the current online stable docs as well) of Node.set_process etc. the potential overwrite on NOTIFICATION_READY is not mentioned anyhow, as:

cc @Mickeon

@Mickeon
Copy link
Contributor

Mickeon commented Jul 25, 2024

Yeah, there's no reason not to cherrypick the next PR, if not because other minor PRs may have made it a bit annoying to.

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

No branches or pull requests

4 participants