godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.51k stars 21.26k forks source link

Warning about server features on every startup #99850

Open clayjohn opened 2 days ago

clayjohn commented 2 days ago

Tested versions

Current master 56a7dba10beacec50176723a5fae76d1614e75c1

System information

Godot v4.4.dev (5ea9e8b26) - Pop!_OS 22.04 LTS on X11 - X11 display driver, Multi-window, 1 monitor - OpenGL 3 (Compatibility) - Mesa Intel(R) Xe Graphics (TGL GT2) - 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 threads)

Issue description

The following warning is printed whenever you run Godot in a debug build with --verbose:

WARNING: Server features cannot be checked before RenderingServer has been created. If you are checking a server feature, consider moving your OS::has_feature call after INITIALIZATION_LEVEL_SERVERS.
     at: has_feature (core/os/os.cpp:544)

Introduced by https://github.com/godotengine/godot/pull/98862

Here is the relevant code:

before

if (has_server_feature_callback && has_server_feature_callback(p_feature)) {
    return true;
}

after

if (has_server_feature_callback) {
    return has_server_feature_callback(p_feature);
}
#ifdef DEBUG_ENABLED
else if (is_stdout_verbose()) {
    WARN_PRINT_ONCE("Server features cannot be checked before RenderingServer has been created. If you are checking a server feature, consider moving your OS::has_feature call after INITIALIZATION_LEVEL_SERVERS.");
}
#endif

Before if either has_server_feature_callback or has_server_feature_callback(p_feature) was false, the function would continue and check if (ProjectSettings::get_singleton()->has_custom_feature(p_feature)). With the new logic the warning is printed any time that has_server_feature_callback is false and the code returns early whenever has_server_feature_callback is true. I suspect that neither of those things are intended

CC @HuntJSparra

Steps to reproduce

Run Godot from the command line with --verbose and observe

Minimal reproduction project (MRP)

N/A

clayjohn commented 2 days ago

Also CCing @RandomShaper as he made the suggestion that led to this code https://github.com/godotengine/godot/pull/98862#issuecomment-2488994511

HuntJSparra commented 1 day ago

Sorry for the issue. I’ll write up a PR later today that fixes the early return and moves the warning until after all other checks.

If the check still fails to find the feature, it’ll print the warning, regardless of if the call was originally intended to check a server feature or not. That could be annoy for people who really want 0 warnings in their console. So, another “fix” for this issue could be to remove the warning entirely. I don’t have a preference either way.