### 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.
itemsv.resize(texture_atlas.textures.size());
		int base_size = 8;
		int idx = 0;
		for (const KeyValue<RID, TextureAtlas::Texture> &E : texture_atlas.textures) {
			TextureAtlas::SortItem &si = itemsv.write[idx];
			Texture *src_tex = get_texture(E.key);
			si.size.width = (src_tex->width / border) + 1;
			si.size.height = (src_tex->height / border) + 1;
			si.pixel_size = Size2i(src_tex->width, src_tex->height);
			if (base_size < si.size.width) {
				base_size = nearest_power_of_2_templated(si.size.width);
			}
			si.texture = E.key;
			idx++;
		}
		
		itemsv.sort();
		
		int item_count = itemsv.size();
		TextureAtlas::SortItem *items = itemsv.ptrw();
		int atlas_height = 0;
		while (true) {
			Vector<int> v_offsetsv;
			v_offsetsv.resize(base_size);
			int *v_offsets = v_offsetsv.ptrw();
			memset(v_offsets, 0, sizeof(int) * base_size);
			int max_height = 0;
			for (int i = 0; i < item_count; i++) {
				
				TextureAtlas::SortItem &si = items[i];