### 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 (over) {
			bool stopped = false;
			if (over->can_process()) {
				Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse();
				Size2 pos = localizer.xform(drag_event->get_position());
				Vector2 velocity = localizer.basis_xform(drag_event->get_velocity());
				Vector2 rel = localizer.basis_xform(drag_event->get_relative());
				drag_event = drag_event->xformed_by(Transform2D()); 
				drag_event->set_velocity(velocity);
				drag_event->set_relative(rel);
				drag_event->set_position(pos);
				stopped = _gui_call_input(over, drag_event);
			}
			if (stopped) {
				set_input_as_handled();
			}
			return;
		}
	}
	if (mm.is_null() && mb.is_null() && p_event->is_action_type()) {
		if (gui.dragging && p_event->is_action_pressed("ui_cancel") && Input::get_singleton()->is_action_just_pressed("ui_cancel")) {
			_perform_drop();
			set_input_as_handled();
			return;
		}
		if (gui.key_focus && !gui.key_focus->is_visible_in_tree()) {
			gui.key_focus->release_focus();
		}
		if (gui.key_focus) {
			gui.key_event_accepted = false;