Open Ryan-000 opened 4 weeks ago
ran a profile on the issue :
Seems to be because the window notification mechanism is slow and maybe a lack of "opt-out" mechanism.
Basically, when you get a window event as such, the whole Node hierarchy is notified recursively (Window::_propagate_window_notification
), via a function with a thread guard (good).
As it's all done on a single frame (good), if you have millions of nodes into millions of others, that guarded recursion is bound to be slow.
So if Godot should handle such recursion (a voxel based-game is what comes to mind for such a case), it could be a good thing to neutralize this impact somewhat. A parameter could be introduced on Node to check if it should propagate the notification further down (propagating by default for compatibility).
But again, in this case it might be more interesting to get into specific object management with node alternatives.
Tested versions
4.3, 4.2.2, 4.1.3, 4.0
System information
Godot v4.3.stable.mono (97f0c76f2) - Ubuntu 24.04.1 LTS 24.04 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2080 Ti (nvidia; 560.35.03) - AMD Ryzen 9 3900X 12-Core Processor (24 Threads)
Issue description
When the
NOTIFICATION_APPLICATION_FOCUS_IN
andNOTIFICATION_APPLICATION_FOCUS_OUT
notifications are triggered, the Godot engine freezes or stutters noticeably if there are many nodes in the scene tree. This issue affects the engine's performance, especially in scenes with large hierarchies.Steps to reproduce
Minimal reproduction project (MRP)
MRP.zip