### Godot version

v4.0 rc6

### System information

Windows 10

### Issue description

When using a ViewportTexture from a SubViewport on a TextureRect, it throws errors after running the scene once and then switching scenes in the editor.
![Pasted image 20230227212626](https://user-images.githubusercontent.com/44676282/221680047-984fa03e-33d1-4856-9a7f-1700b28423cf.png)


### Steps to reproduce

Run the canvas-scene once.
Switch to another scene in the editor.
Switch back to the canvas-scene

### Minimal reproduction project

[ViewportTextureError.zip](https://github.com/godotengine/godot/files/10844099/ViewportTextureError.zip)

ERR_READ_THREAD_GUARD_V(false);
	return physics_object_picking;
}
void Viewport::set_physics_object_picking_sort(bool p_enable) {
	ERR_MAIN_THREAD_GUARD;
	physics_object_picking_sort = p_enable;
}
bool Viewport::get_physics_object_picking_sort() {
	ERR_READ_THREAD_GUARD_V(false);
	return physics_object_picking_sort;
}
Vector2 Viewport::get_camera_coords(const Vector2 &p_viewport_coords) const {
	ERR_READ_THREAD_GUARD_V(Vector2());
	Transform2D xf = stretch_transform * global_canvas_transform;
	return xf.xform(p_viewport_coords);
}
Vector2 Viewport::get_camera_rect_size() const {
	ERR_READ_THREAD_GUARD_V(Vector2());
	return size;
}
void Viewport::set_disable_input(bool p_disable) {