### 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.
Control *over = nullptr;
		if (gui.mouse_in_viewport) {
			over = gui_find_control(mpos);
		}
		if (over != gui.mouse_over) {
			_drop_mouse_over();
			_gui_cancel_tooltip();
			if (over) {
				if (!gui.mouse_over) {
					_drop_physics_mouseover();
				}
				_gui_call_notification(over, Control::NOTIFICATION_MOUSE_ENTER);
				gui.mouse_over = over;
			}
		}
		if (gui.mouse_focus) {
			over = gui.mouse_focus;
		}
		DisplayServer::CursorShape ds_cursor_shape = (DisplayServer::CursorShape)Input::get_singleton()->get_default_cursor_shape();
		if (over) {
			Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse();
			Size2 pos = localizer.xform(mpos);
			Vector2 velocity = localizer.basis_xform(mm->get_velocity());
			Vector2 rel = localizer.basis_xform(mm->get_relative());
			mm = mm->xformed_by(Transform2D()); 
			mm->set_global_position(mpos);
			mm->set_velocity(velocity);
			mm->set_relative(rel);
			if (mm->get_button_mask().is_empty()) {