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

SpatialEditor tries to modify null RID when creating a new scene #44712

Closed
Zylann opened this issue Dec 26, 2020 · 1 comment
Closed

SpatialEditor tries to modify null RID when creating a new scene #44712

Zylann opened this issue Dec 26, 2020 · 1 comment
Milestone

Comments

@Zylann
Copy link
Contributor

Zylann commented Dec 26, 2020

Godot version:
Godot 3.2.4 dev 279f4fb
Might happen too in Godot 4.0

OS/device including version:
Windows 10 64 bits

Issue description:
SpatialEditor tries to modify grid instances that were not created. This is a problem occurring around the same area as #44642
Seems like it need a review.

It prints this in the console:

ERROR: RID_Owner<struct VisualServerScene::Instance>::get: Condition "!p_rid.is_valid()" is true. Returned: 0
   At: C:\Projects\Godot\Engine\godot_fork\core/rid.h:149
ERROR: VisualServerScene::instance_set_visible: Condition "!instance" is true.
   At: servers\visual\visual_server_scene.cpp:662

Steps to reproduce:
I opened a project, which opened its main scene. I created a new scene and the error showed up.
I don't have more precise steps, however I found this because I had a C++ debugger attached, and I told it to break each time an error got logged, initially to debug my own things.

So here is the crime scene:
image

The problem is straightforward to see: SpatialEditor::clear() is called, in which it tries to set every grid as visible, if it is enabled.
It should not get fixed by simply checking if it's null though, because something already went wrong before: grid_enable is true only for index 2 (the XZ grid), but only the RID at index 1 is assigned, the others are null. So here it tries to set visibility of a null RID, causing the error.

  1. Having a null RID in a slot where grid_enable is true is an odd situation. EIther it's expected somehow, or was badly initialized.
  2. There is a supposedly dangling RID in a slot where grid_enable is false. It should never have been assigned since grid XY is not enabled.

Note 1:
My build of Godot has this change inside:

@@ -5719,10 +5719,12 @@ void SpatialEditor::_finish_indicators() {
 
 void SpatialEditor::_finish_grid() {
 	for (int i = 0; i < 3; i++) {
 		VisualServer::get_singleton()->free(grid_instance[i]);
 		VisualServer::get_singleton()->free(grid[i]);
+		grid_instance[i] = RID();
+		grid[i] = RID();
 	}
 }

However as you can see, this can't be the origin of the problem. In worst case, you might just see a different error for the same reasons.

Note 2: in #44642 that was also the case: only the RID at index 1 was set.

Minimal reproduction project:
None, sorry.

@Zylann Zylann changed the title SpatialEditor tries to modify null RID when creating a new scene while the grid and axes are turned off SpatialEditor tries to modify null RID when creating a new scene Dec 26, 2020
@akien-mga akien-mga added this to the 3.5 milestone Dec 9, 2021
@akien-mga
Copy link
Member

Fixed by #54650.

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

3 participants