### Godot version

4.1 beta 3

The same project works fine on 4.1 **beta 1 and beta 2.**

### System information

Tested on MacOS, Fedora and HTML5

### Issue description

I have a problem in version 4.1 beta 3 with a popup (popup panel). The first time it always displays correctly. Every subsequent time, I only see a black spot. 

[Nagranie ekranu z 2023-06-23 11-35-28.webm](https://github.com/godotengine/godot/assets/5132385/f7a7ad08-754c-4b4b-b594-b6880eff5f3d)

*The same if I show popup by methods like popup_centered.


### Steps to reproduce

I'm trying to reproduce it with a clean and minimal example, but unfortunately, without success. Maybe someone else has this issue or knows a way to reproduce it?

### Minimal reproduction project

I'm trying to create it.
ERR_FAIL_COND(p_layers.is_empty());
	ERR_FAIL_COND(p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP && p_layers.size() != 6);
	ERR_FAIL_COND_MSG(p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP_ARRAY, "Cubemap Arrays are not supported in the GL Compatibility backend.");
	Ref<Image> image = p_layers[0];
	{
		int valid_width = 0;
		int valid_height = 0;
		bool valid_mipmaps = false;
		Image::Format valid_format = Image::FORMAT_MAX;
		for (int i = 0; i < p_layers.size(); i++) {
			ERR_FAIL_COND(p_layers[i]->is_empty());
			if (i == 0) {
				valid_width = p_layers[i]->get_width();
				valid_height = p_layers[i]->get_height();
				valid_format = p_layers[i]->get_format();
				valid_mipmaps = p_layers[i]->has_mipmaps();