### Godot version

4.0.3-stable

### System information

Windows 10

### Issue description

In some projects ViewportTexture remains pink and doesn't render viewport content after upgrading from 4.0.2-stable to 4.0.3-stable. If a pair of files viewport.h/viewport.cpp are downgraded back to what they were in 4.0.2-stable, problem goes away.

This is how it looks in 4.0.3-stable:
![4 0 3_stable_viewport_4 0 3](https://github.com/godotengine/godot/assets/1449921/44c191a9-4b67-4b02-90b6-4ab615f62a73)

And this is how it looks if viewport.h/viewport.cpp are downgraded back to what they were in 4.0.2-stable.
![4 0 3_stable_viewport_4 0 2](https://github.com/godotengine/godot/assets/1449921/f5abc605-f129-4222-9c0e-e9a07621dd9d)



### Steps to reproduce

Unfortunately, I cannot come up wit a simple demo project reproducing the problem. It exists in some projects and doesn't exist in others.


### Minimal reproduction project

Cannot produce a simple project reproducing the problem. In simple projects it works fine.
ERR_MAIN_THREAD_GUARD;
	
	vrs_mode = p_vrs_mode;
	switch (p_vrs_mode) {
		case VRS_TEXTURE: {
			RS::get_singleton()->viewport_set_vrs_mode(viewport, RS::VIEWPORT_VRS_TEXTURE);
		} break;
		case VRS_XR: {
			RS::get_singleton()->viewport_set_vrs_mode(viewport, RS::VIEWPORT_VRS_XR);
		} break;
		default: {
			RS::get_singleton()->viewport_set_vrs_mode(viewport, RS::VIEWPORT_VRS_DISABLED);
		} break;
	}
	notify_property_list_changed();
}
Viewport::VRSMode Viewport::get_vrs_mode() const {
	ERR_READ_THREAD_GUARD_V(VRS_DISABLED);
	return vrs_mode;
}
void Viewport::set_vrs_texture(Ref<Texture2D> p_texture) {
	ERR_MAIN_THREAD_GUARD;
	vrs_texture = p_texture;
	
	RID tex = p_texture.is_valid() ? p_texture->get_rid() : RID();
	RS::get_singleton()->viewport_set_vrs_texture(viewport, tex);
}
Ref<Texture2D> Viewport::get_vrs_texture() const {