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

Project feature warning system #31171

Merged
merged 1 commit into from
Nov 24, 2021

Conversation

aaronfranke
Copy link
Member

@aaronfranke aaronfranke commented Aug 7, 2019

(Note: This PR also increments the config version by necessity)

A mostly complete implementation of a feature warning system, implements and closes godotengine/godot-proposals#427, implements and closes godotengine/godot-proposals#237

EDIT: The screenshot is a bit outdated, since now there are more specific error messages available.

f

What works: Reading project features from project.godot, displaying unsupported features, warning when trying to open a project with unsupported features, changing the features to comply with currently supported and required features, and saving project features to project.godot.

This PR uses the new feature system for the following:

  • Saves the Godot version. This is in parallel to config_version, so as an example if 4.0 and 4.1 use the same config version then this system will show a warning when opening 4.0 projects in 4.1 and 4.1 projects in 4.0, but if 4.2 uses a higher config version then upgrading to 4.2 would be one-way.
    • Users can also pin a project to a minor version or engine build if they wish, so 4.0.1 as an example.
  • Allows different builds of Godot to save feature tags to warn about the different features. In this PR it saves information about:
    • Whether a project is using single-precision or doubles.
    • Which renderer the project is using (Vulkan/GLES/etc).
    • Whether a project is using C#.
    • More can be added later if there's a need for any other feature tags.
  • Allows people to make custom builds of Godot and include a feature tag for it. Since this system just saves strings, even official builds of Godot can warn that they are missing features found in custom Godot forks.

@akien-mga akien-mga added this to the 3.2 milestone Aug 8, 2019
@aaronfranke aaronfranke force-pushed the feature-system branch 2 times, most recently from 3e7f755 to 2c16d18 Compare August 23, 2019 22:03
@akien-mga akien-mga modified the milestones: 3.2, 4.0 Oct 8, 2019
@aaronfranke aaronfranke force-pushed the feature-system branch 2 times, most recently from 2610c82 to 683493f Compare March 23, 2020 07:20
@aaronfranke aaronfranke force-pushed the feature-system branch 2 times, most recently from 76c42a0 to ce26ba2 Compare April 4, 2020 08:45
@aaronfranke aaronfranke force-pushed the feature-system branch 2 times, most recently from 151b1e7 to b2805b7 Compare July 7, 2020 18:56
@aaronfranke aaronfranke changed the title [WIP] Feature warning system Feature warning system Jul 7, 2020
@aaronfranke aaronfranke force-pushed the feature-system branch 2 times, most recently from 656a851 to 59414b5 Compare July 24, 2020 20:48
@aaronfranke aaronfranke changed the title Feature warning system Project feature warning system Jul 24, 2020
@reduz
Copy link
Member

reduz commented Aug 31, 2021

@reduz Is that guaranteed to happen for 4.0?

Yes that is the idea, otherwise it would be a major compatibility breakage between 4.0 and 4.1.

Saves the Godot version. This is in parallel to config_version, so as an example if 4.0 and 4.1 use the same config version then this system will show a warning when opening 4.0 projects in 4.1 and 4.1 projects in 4.0, but if 4.2 uses a higher config version then upgrading to 4.2 would be one-way.

Not against a version check, this part may go through, but needs to be consulted with other contributors.

For the rest, I think using feature tags for this is not a good idea, because most of them are either irrelevant or platform dependent. IMO something more specialized is required for this situation. I think this needs to be something else more related to compilation flags (engine version, whether it uses doubles, etc) and not feature tags.

I suggest going back to the drawing board with this and create a new proposal.

@Calinou
Copy link
Member

Calinou commented Aug 31, 2021

I think this needs to be something else more related to compilation flags (engine version, whether it uses doubles, etc) and not feature tags.

All the current feature tags are determined at compile-time, so double precision support could be a feature tag.

Comment on lines 481 to 491
if (renderer_type == 0) {
project_features.push_back("Vulkan 1 Clustered");
} else if (renderer_type == 1) {
project_features.push_back("Vulkan 1 Mobile");
} else {
WARN_PRINT("Unknown renderer type. Please report this as a bug on GitHub.");
Copy link
Member

@akien-mga akien-mga Nov 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be hardcoded (it's no longer accurate either). I mean the numbers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you happen to know where the enum is?

Copy link
Member Author

@aaronfranke aaronfranke Nov 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's hard-coded here too (servers/rendering_server.cpp:2827):

GLOBAL_DEF_RST_BASIC("rendering/vulkan/rendering/back_end", 0);
GLOBAL_DEF_RST_BASIC("rendering/vulkan/rendering/back_end.mobile", 1);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/vulkan/rendering/back_end",
		PropertyInfo(Variant::INT,
				"rendering/vulkan/rendering/back_end",
				PROPERTY_HINT_ENUM, "Forward Clustered (Supports Desktop Only),Forward Mobile (Supports Desktop and Mobile)"));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm right, I guess it's fine for now. We can rethink this once the OpenGL backend is ready and needs to be handled too.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved in PR meeting.

We might want to iterate on the actual implementation to see what makes the most sense, but this is a good start to build upon.

Comment on lines 2225 to 2246
String warning_message = "";
for (int i = 0; i < unsupported_features.size(); i++) {
String feature = unsupported_features[i];
if (feature == "Double Precision") {
warning_message += TTR("Warning: This project uses double precision floats, but this version of\nGodot uses single precision floats. Opening this project may cause data loss.\n\n");
unsupported_features.remove(i);
i--;
} else if (feature == "C#") {
warning_message += TTR("Warning: This project uses C#, but this build of Godot does not have\nthe Mono module. If you proceed you will not be able to use any C# scripts.\n\n");
unsupported_features.remove(i);
i--;
} else if (feature.substr(0, 3).is_numeric()) {
warning_message += vformat(TTR("Warning: This project was built in Godot %s.\nOpening will upgrade or downgrade the project to Godot %s.\n\n"), Variant(feature), Variant(VERSION_BRANCH));
unsupported_features.remove(i);
i--;
}
}
if (!unsupported_features.is_empty()) {
String unsupported_features_str = Variant(unsupported_features).operator String().trim_prefix("[").trim_suffix("]");
warning_message += vformat(TTR("Warning: This project uses the following features not supported by this build of Godot:\n\n%s\n\n"), unsupported_features_str);
}
warning_message += TTR("Open anyway? Project will be modified.");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code has been updated to have more specific error messages, but still have a fallback for anything not covered by those messages.

core/config/project_settings.cpp Outdated Show resolved Hide resolved
@aaronfranke aaronfranke force-pushed the feature-system branch 2 times, most recently from 130fbbd to f986caf Compare November 24, 2021 16:19
@akien-mga
Copy link
Member

You can remove me as co-author, it's not deserved for a style nitpick ;)

@akien-mga akien-mga merged commit e49b127 into godotengine:master Nov 24, 2021
@akien-mga
Copy link
Member

Thanks!

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