### 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.
if (viewport_under) {
				if (viewport_under != this) {
					Transform2D ai = viewport_under->get_final_transform().affine_inverse();
					viewport_pos = ai.xform(viewport_pos);
				}
				
				gui.drag_mouse_over = viewport_under->gui_find_control(viewport_pos);
				if (gui.drag_mouse_over) {
					Transform2D localizer = gui.drag_mouse_over->get_global_transform_with_canvas().affine_inverse();
					gui.drag_mouse_over_pos = localizer.xform(viewport_pos);
					bool can_drop = _gui_drop(gui.drag_mouse_over, gui.drag_mouse_over_pos, true);
					if (!can_drop) {
						ds_cursor_shape = DisplayServer::CURSOR_FORBIDDEN;
					} else {
						ds_cursor_shape = DisplayServer::CURSOR_CAN_DROP;
					}
				}
			} else {
				gui.drag_mouse_over = nullptr;
			}
		}
		if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CURSOR_SHAPE)) {
			DisplayServer::get_singleton()->cursor_set_shape(ds_cursor_shape);
		}
	}
	Ref<InputEventScreenTouch> touch_event = p_event;
	if (touch_event.is_valid()) {
		Size2 pos = touch_event->get_position();
		const int touch_index = touch_event->get_index();
		if (touch_event->is_pressed()) {