Repository: godotengine/godot (language: cpp)

Issue:
Godot 4.4 editor crashing on Metal renderer with CompressedCubemap Panorama Skybox: "Texture Descriptor Validation MTLTextureDescriptor width must equal height for cube textures."
### Tested versions

- Reproducable 4.4 Stable
- Not reproducable 4.3

### System information

Godot v4.4.stable - macOS Sequoia (15.3.1) - Multi-window, 1 monitor - Metal (Forward+) - integrated Apple M2 Max (Apple8) - Apple M2 Max (12 threads)

### Issue description

```
-[MTLTextureDescriptorInternal validateWithDevice:]:1405: failed assertion `Texture Descriptor Validation
MTLTextureDescriptor width must equal height for cube textures.
```

Here is the crash:

```
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Godot [65826]
Path:                  /Applications/Godot4.4.app/Contents/MacOS/Godot
Identifier:            org.godotengine.godot
Version:               4.4 (4.4)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2025-03-04 13:43:52.3064 -0900
OS Version:            macOS 15.3.1 (24D70)
Report Version:        12
Anonymous UUID:        E28CF697-58FF-9C33-558D-4A0B8E2BED8C

Sleep/Wake UUID:       2D217976-34E0-4E20-AA14-1CA4B30ADD15

Time Awake Since Boot: 53000 seconds
Time Since Wake:       12813 seconds

System Integrity Protection: enabled

Crashed Thread:        27

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 6 Abort trap: 6
Terminating Process:   Godot [65826]

Thread 0::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x19978a4e8 __semwait_signal + 8
1   libsystem_c.dylib             	       0x1996696f0 nanosleep + 220
2   Godot                         	       0x1028ce270 OS_Unix::delay_usec(unsigned int) const + 64
3   Godot                         	       0x1057b0304 OS::add_frame_delay(bool) + 220
4   Godot                         	       0x10180a00c Main::iteration() + 1972
5   Godot                         	       0x101792484 OS_MacOS::run() + 168
6   Godot                         	       0x1017c3354 main + 388
7   dyld                          	       0x199448274 start + 2840

Thread 1:
0   libsystem_pthread.dylib       	       0x1997c30e8 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib       	       0x1997c30e8 start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib       	       0x1997c30e8 start_wqthread + 0

Thread 4:
0   libsystem_pthread.dylib       	       0x1997c30e8 start_wqthread + 0

Thread 5:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x1058dc828 _IP_ResolverPrivate::_thread_function(void*) + 152
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 6:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 7:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 8:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 9:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 10:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 11:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 12:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 13:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 14:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 15:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 16:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 17:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x105de0dd0 WorkerThreadPool::_thread_function(void*) + 260
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 18:: com.apple.NSEventThread
0   libsystem_kernel.dylib        	       0x199786f54 mach_msg2_trap + 8
1   libsystem_kernel.dylib        	       0x199799604 mach_msg2_internal + 80
2   libsystem_kernel.dylib        	       0x19978faf8 mach_msg_overwrite + 480
3   libsystem_kernel.dylib        	       0x19978729c mach_msg + 24
4   CoreFoundation                	       0x1998b0a4c __CFRunLoopServiceMachPort + 160
5   CoreFoundation                	       0x1998af2ac __CFRunLoopRun + 1212
6   CoreFoundation                	       0x1998ae734 CFRunLoopRunSpecific + 588
7   AppKit                        	       0x19d54b278 _NSEventThread + 148
8   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
9   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 19:: caulk.messenger.shared:17
0   libsystem_kernel.dylib        	       0x199786ed0 semaphore_wait_trap + 8
1   caulk                         	       0x1a48f3ff4 caulk::semaphore::timed_wait(double) + 220
2   caulk                         	       0x1a48f3ea0 caulk::concurrent::details::worker_thread::run() + 36
3   caulk                         	       0x1a48f3b74 void* caulk::thread_proxy<std::__1::tuple<caulk::thread::attributes, void (caulk::concurrent::details::worker_thread::*)(), std::__1::tuple<caulk::concurrent::details::worker_thread*>>>(void*) + 96
4   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
5   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 20:: caulk.messenger.shared:high
0   libsystem_kernel.dylib        	       0x199786ed0 semaphore_wait_trap + 8
1   caulk                         	       0x1a48f3ff4 caulk::semaphore::timed_wait(double) + 220
2   caulk                         	       0x1a48f3ea0 caulk::concurrent::details::worker_thread::run() + 36
3   caulk                         	       0x1a48f3b74 void* caulk::thread_proxy<std::__1::tuple<caulk::thread::attributes, void (caulk::concurrent::details::worker_thread::*)(), std::__1::tuple<caulk::concurrent::details::worker_thread*>>>(void*) + 96
4   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
5   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 21:: caulk::deferred_logger
0   libsystem_kernel.dylib        	       0x199786ed0 semaphore_wait_trap + 8
1   caulk                         	       0x1a48f3ff4 caulk::semaphore::timed_wait(double) + 220
2   caulk                         	       0x1a48f3ea0 caulk::concurrent::details::worker_thread::run() + 36
3   caulk                         	       0x1a48f3b74 void* caulk::thread_proxy<std::__1::tuple<caulk::thread::attributes, void (caulk::concurrent::details::worker_thread::*)(), std::__1::tuple<caulk::concurrent::details::worker_thread*>>>(void*) + 96
4   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
5   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 22:: com.apple.audio.IOThread.client
0   libsystem_kernel.dylib        	       0x199786edc semaphore_wait_signal_trap + 8
1   caulk                         	       0x1a49105c4 caulk::mach::semaphore::wait_signal_or_error(caulk::mach::semaphore&) + 36
2   CoreAudio                     	       0x19c304330 HALC_ProxyIOContext::IOWorkLoop() + 4892
3   CoreAudio                     	       0x19c302898 invocation function for block in HALC_ProxyIOContext::HALC_ProxyIOContext(unsigned int, unsigned int) + 176
4   CoreAudio                     	       0x19c4b3760 HALC_IOThread::Entry(void*) + 88
5   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
6   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 23:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x10277e738 0x100fd0000 + 24831800
4   Godot                         	       0x10277e5e4 0x100fd0000 + 24831460
5   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
6   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 24:
0   libsystem_kernel.dylib        	       0x19978a4e8 __semwait_signal + 8
1   libsystem_c.dylib             	       0x1996696f0 nanosleep + 220
2   Godot                         	       0x1028ce270 OS_Unix::delay_usec(unsigned int) const + 64
3   Godot                         	       0x102bd5fb8 EditorExportPlatformAndroid::_check_for_changes_poll_thread(void*) + 8280
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 25:
0   libsystem_kernel.dylib        	       0x19978a4e8 __semwait_signal + 8
1   libsystem_c.dylib             	       0x1996696f0 nanosleep + 220
2   Godot                         	       0x1028ce270 OS_Unix::delay_usec(unsigned int) const + 64
3   Godot                         	       0x102c40914 EditorExportPlatformIOS::_check_for_changes_poll_thread(void*) + 4464
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 26:
0   libsystem_kernel.dylib        	       0x19978a6ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x1997c8894 _pthread_cond_wait + 1204
2   libc++.1.dylib                	       0x1996fe578 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   Godot                         	       0x103ad7378 TilesEditorUtils::_thread() + 280
4   Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
5   Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
6   libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8

Thread 27 Crashed:
0   libsystem_kernel.dylib        	       0x19978f720 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x1997c7f70 pthread_kill + 288
2   libsystem_c.dylib             	       0x1996d4908 abort + 128
3   libsystem_c.dylib             	       0x1996d3c1c __assert_rtn + 284
4   Metal                         	       0x1a482a4e0 MTLReportFailure.cold.1 + 48
5   Metal                         	       0x1a4805de4 MTLReportFailure + 448
6   Metal                         	       0x1a47fb2bc _MTLMessageContextEnd + 876
7   Metal                         	       0x1a468cf90 -[MTLTextureDescriptorInternal validateWithDevice:] + 2320
8   AGXMetalG14X                  	       0x117f24d90 -[AGXTexture initWithDevice:desc:isSuballocDisabled:] + 56
9   Godot                         	       0x102b946d4 RenderingDeviceDriverMetal::texture_create(RenderingDeviceCommons::TextureFormat const&, RenderingDeviceDriver::TextureView const&) + 1580
10  Godot                         	       0x1051447ec RenderingDevice::texture_create(RenderingDeviceCommons::TextureFormat const&, RenderingDevice::TextureView const&, Vector<Vector<unsigned char>> const&) + 2492
11  Godot                         	       0x10544342c RendererRD::TextureStorage::texture_2d_layered_initialize(RID, Vector<Ref<Image>> const&, RenderingServer::TextureLayeredType) + 1432
12  Godot                         	       0x105229ec0 0x100fd0000 + 69574336
13  Godot                         	       0x10468b678 CompressedTextureLayered::load(String const&) + 92
14  Godot                         	       0x10468c3c8 ResourceFormatLoaderCompressedTextureLayered::load(String const&, String const&, Error*, bool, float*, ResourceFormatLoader::CacheMode) + 684
15  Godot                         	       0x10594c810 ResourceLoader::_load(String const&, String const&, String const&, ResourceFormatLoader::CacheMode, Error*, bool, float*) + 1152
16  Godot                         	       0x10593ad38 ResourceFormatImporter::load_internal(String const&, Error*, bool, float*, ResourceFormatLoader::CacheMode, bool) + 260
17  Godot                         	       0x10594c810 ResourceLoader::_load(String const&, String const&, String const&, ResourceFormatLoader::CacheMode, Error*, bool, float*) + 1152
18  Godot                         	       0x10594dad4 ResourceLoader::_run_load_task(void*) + 336
19  Godot                         	       0x10594ff7c ResourceLoader::_load_start(String const&, String const&, ResourceLoader::LoadThreadMode, ResourceFormatLoader::CacheMode, bool) + 1588
20  Godot                         	       0x1059503b0 ResourceLoader::load(String const&, String const&, ResourceFormatLoader::CacheMode, Error*) + 88
21  Godot                         	       0x103028a28 EditorResourcePreviewGenerator::generate_from_path(String const&, Vector2 const&, Dictionary&) const + 2844
22  Godot                         	       0x10302c7bc EditorResourcePreview::_generate_preview(Ref<ImageTexture>&, Ref<ImageTexture>&, EditorResourcePreview::QueueItem const&, String const&, Dictionary&) + 740
23  Godot                         	       0x10302df80 EditorResourcePreview::_iterate() + 1692
24  Godot                         	       0x10302b9ec EditorResourcePreview::_thread() + 92
25  Godot                         	       0x1057b31ac Thread::callback(unsigned long long, Thread::Settings const&, void (*)(void*), void*) + 148
26  Godot                         	       0x1057b35f8 0x100fd0000 + 75380216
27  libsystem_pthread.dylib       	       0x1997c82e4 _pthread_start + 136
28  libsystem_pthread.dylib       	       0x1997c30fc thread_start + 8


Thread 27 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000073   x5: 0x000000000000002e   x6: 0x0000000000000000   x7: 0x0000000000000000
    x8: 0x7ddb0cf71498ce6e   x9: 0x7ddb0cf48323be6e  x10: 0x000000000000000a  x11: 0x0000000000000000
   x12: 0x0000000000000031  x13: 0x000000013b00a3b0  x14: 0x01000002031505b1  x15: 0x00000002031505b0
   x16: 0x0000000000000148  x17: 0x000000020b77a2c0  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x0000000000021103  x21: 0x0000000397bb70e0  x22: 0x000000012e4fc000  x23: 0xffffffffffffffff
   x24: 0x0000000200ceb000  x25: 0x00000001fd0ec000  x26: 0x00000001a4855ecf  x27: 0x0000000397bb5e80
   x28: 0x00006000019c5560   fp: 0x0000000397bb5b00   lr: 0x00000001997c7f70
    sp: 0x0000000397bb5ae0   pc: 0x000000019978f720 cpsr: 0x40001000
   far: 0x0000000000000000  esr: 0x56000080  Address size fault

Binary Images:
       0x100fd0000 -        0x1085c7fff org.godotengine.godot (4.4) <89494539-1aff-31c9-b57a-5ed1158c0256> /Applications/Godot4.4.app/Contents/MacOS/Godot
       0x109cc8000 -        0x109cd3fff libobjc-trampolines.dylib (*) <3d687e9b-e092-3632-bc1d-74b19d492de0> /usr/lib/libobjc-trampolines.dylib
       0x117854000 -        0x117f7ffff com.apple.AGXMetalG14X (324.6) <da4fd60f-fe41-3f17-9e23-c9718a8013a3> /System/Library/Extensions/AGXMetalG14X.bundle/Contents/MacOS/AGXMetalG14X
       0x117280000 -        0x11736bfff libgodotopenxrvendors.macos (*) <432e5c10-87f1-354b-b801-7da305c29b99> /Users/USER/*/libgodotopenxrvendors.macos.framework/libgodotopenxrvendors.macos
       0x1194fc000 -        0x119a47fff org.godotengine.webrtc-native (1.0.0) <d85a4119-7552-34c5-b4fb-27f0067de0a3> /Users/USER/*/libwebrtc_native.macos.template_debug.universal.framework/libwebrtc_native.macos.template_debug.universal.dylib
       0x11712c000 -        0x117133fff com.apple.GameController.KeyboardAndMouseSupport (*) <c14a3384-2826-343b-b16d-f36e5e285159> /System/Library/Frameworks/GameController.framework/Versions/A/Resources/KeyboardAndMouseSupport.bundle/Contents/MacOS/KeyboardAndMouseSupport
       0x118df0000 -        0x118f2bfff com.apple.audio.units.Components (1.14) <ce006ced-ee1c-3174-bba9-1e326231ab55> /System/Library/Components/CoreAudio.component/Contents/MacOS/CoreAudio
       0x11943c000 -        0x119487fff com.apple.cmio.DAL.VDC-4 (810.0) <a3ef8c90-1511-3a87-b8a8-ce9535cb9511> /System/Library/Frameworks/CoreMediaIO.framework/Versions/A/Resources/VDC.plugin/Contents/MacOS/VDC
       0x199786000 -        0x1997c0ff7 libsystem_kernel.dylib (*) <eee9d0d3-dffc-37cb-9ced-b27cd0286d8c> /usr/lib/system/libsystem_kernel.dylib
       0x19965b000 -        0x1996dcffb libsystem_c.dylib (*) <92699527-645f-3d8d-aed8-1cfb0c034e15> /usr/lib/system/libsystem_c.dylib
       0x199442000 -        0x1994c3f3f dyld (*) <398a133c-9bcb-317f-a064-a40d3cea3c0f> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
       0x1997c1000 -        0x1997cdfff libsystem_pthread.dylib (*) <642faf7a-874e-37e6-8aba-2b0cc09a3025> /usr/lib/system/libsystem_pthread.dylib
       0x1996dd000 -        0x19976affb libc++.1.dylib (*) <bbab286c-2e51-3d64-9ae3-a4102935fe32> /usr/lib/libc++.1.dylib
       0x199833000 -        0x199d27fff com.apple.CoreFoundation (6.9) <190e6a36-fcaa-3ea3-94bb-7009c44653da> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
       0x19d3eb000 -        0x19e827fff com.apple.AppKit (6.9) <b88a44c1-d617-33dc-90ed-b6ab417c428e> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
       0x1a48f2000 -        0x1a4919fff com.apple.audio.caulk (1.0) <a307ba82-97de-37d1-99b7-bf68ac23c35c> /System/Library/PrivateFrameworks/caulk.framework/Versions/A/caulk
       0x19c112000 -        0x19c85dfff com.apple.audio.CoreAudio (5.0) <214b90dc-87e8-30a8-b682-c2c1883f9635> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
       0x1a4678000 -        0x1a48f1fff com.apple.Metal (367.6) <8e4d919e-aa4b-36c5-8621-dbc72ed287cd> /System/Library/Frameworks/Metal.framework/Versions/A/Metal

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 33
    thread_create: 0
    thread_set_state: 4702

VM Region Summary:
ReadOnly portion of Libraries: Total=1.7G resident=0K(0%) swapped_out_or_unallocated=1.7G(100%)
Writable regions: Total=9.2G written=4803K(0%) resident=4803K(0%) swapped_out=0K(0%) unallocated=9.2G(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
CG image                           240K        8 
ColorSync                          560K       27 
CoreAnimation                      736K       45 
CoreGraphics                        32K        2 
CoreUI image data                 1216K        8 
Foundation                          16K        1 
Kernel Alloc Once                   32K        1 
MALLOC                             9.2G      355 
MALLOC guard page                  288K       18 
MALLOC_LARGE (reserved)             16K        1         reserved VM address space (unallocated)
STACK GUARD                        448K       28 
Stack                             22.3M       28 
VM_ALLOCATE                        448K       16 
__AUTH                            5178K      662 
__AUTH_CONST                      69.6M      902 
__CTF                               824        1 
__DATA                            27.4M      891 
__DATA_CONST                      27.7M      917 
__DATA_DIRTY                      2748K      334 
__FONT_DATA                        2352        1 
__INFO_FILTER                         8        1 
__LINKEDIT                       624.8M        9 
__OBJC_RW                         2374K        1 
__TEXT                             1.1G      937 
__TPRO_CONST                       272K        2 
dyld private memory                640K        2 
mapped file                      318.2M       27 
owned unmapped memory              528K        1 
page table in kernel              4803K        1 
shared memory                      992K       16 
===========                     =======  ======= 
TOTAL                             11.4G     5244 
TOTAL, minus reserved VM space    11.4G     5244 
```

gist: https://gist.github.com/Clancey/9edb5e97305df84767d6b07a8f1804ce

### Steps to reproduce

I am not totally sure what is causing the crash. But one of my projects cannot load in Godot 4.4. It has worked in previous betas of 4.4. Working on narrowing down when it worked.

### Minimal reproduction project (MRP)

N/A


Discussion / hints:
I found the issue. If a panoramo skybox has the wrong import type:
```
importer="cubemap_texture"
type="CompressedCubemap"
```


It crashes Godot. This was not an issue in previous versions. Maybe the cubemap importer should validate the dimensions to ensure it's square to prevent the crash. Or the metal renderer can validate rather than crashing.


What are the exact steps to validate this?
This issue doesn't appear to be exclusive to Metal or macOS. On Linux + Vulkan, I can reproduce rendering issues, although it doesn't crash or print an error. It seems the Cubemap importer can't deal with non-square cubemaps correctly, even though the size reported in the inspector for each face is correct:
 
Square cubemap | Non-square cubemap (4:1 aspect ratio)
-|-
![Image](https://github.com/user-attachments/assets/b534f7ab-eb04-4da7-94fa-74ddf4f87ed4) | ![Image](https://github.com/user-attachments/assets/198fccb2-9b74-4938-89db-d1c0d8eafcaa)

I've also tried to create the Cubemap from code to no avail:

![Image](https://github.com/user-attachments/assets/2aecaf7b-d1be-4fe1-ab4c-c43cf3c4425f)

(It renders perfectly when its faces have a 1:1 aspect ratio.)

However, given the Metal limitation of requiring square cubemaps, I suppose we should do two things to ensure consistent behavior across platforms:

- Forbid creating Cubemap/CubemapArray resources from code with non-square images (print an error).
- Make the Cubemap importer resize images to have a square aspect ratio by upscaling their lower-resolution axis, so that they are imported correctly.

**Minimal reproduction project:** [test_cubemap_non_square.zip](https://github.com/user-attachments/files/19302507/test_cubemap_non_square.zip)
The MRP includes a script that creates a Cubemap from code when you run the project.

Fix patch:
diff --git a/drivers/metal/rendering_device_driver_metal.mm b/drivers/metal/rendering_device_driver_metal.mm
index f7ac6121bc8d..8f7e6505875c 100644
--- a/drivers/metal/rendering_device_driver_metal.mm
+++ b/drivers/metal/rendering_device_driver_metal.mm
@@ -405,6 +405,15 @@ _FORCE_INLINE_ MTLSize mipmapLevelSizeFromSize(MTLSize p_size, NSUInteger p_leve
 RDD::TextureID RenderingDeviceDriverMetal::texture_create_shared(TextureID p_original_texture, const TextureView &p_view) {
 	id<MTLTexture> src_texture = rid::get(p_original_texture);
 
+	NSUInteger slices = src_texture.arrayLength;
+	if (src_texture.textureType == MTLTextureTypeCube) {
+		// Metal expects Cube textures to have a slice count of 6.
+		slices = 6;
+	} else if (src_texture.textureType == MTLTextureTypeCubeArray) {
+		// Metal expects Cube Array textures to have 6 slices per layer.
+		slices *= 6;
+	}
+
 #if DEV_ENABLED
 	if (src_texture.sampleCount > 1) {
 		// TODO(sgc): is it ok to create a shared texture from a multi-sample texture?
@@ -434,7 +443,7 @@ _FORCE_INLINE_ MTLSize mipmapLevelSizeFromSize(MTLSize p_size, NSUInteger p_leve
 	id<MTLTexture> obj = [src_texture newTextureViewWithPixelFormat:format
 														textureType:src_texture.textureType
 															 levels:NSMakeRange(0, src_texture.mipmapLevelCount)
-															 slices:NSMakeRange(0, src_texture.arrayLength)
+															 slices:NSMakeRange(0, slices)
 															swizzle:swizzle];
 	ERR_FAIL_NULL_V_MSG(obj, TextureID(), "Unable to create shared texture");
 	return rid::make(obj);
@@ -566,7 +575,14 @@ _FORCE_INLINE_ MTLSize mipmapLevelSizeFromSize(MTLSize p_size, NSUInteger p_leve
 		r_layout->size = get_image_format_required_size(format, sz.width, sz.height, sz.depth, 1, &sbw, &sbh);
 		r_layout->row_pitch = r_layout->size / ((sbh / bh) * sz.depth);
 		r_layout->depth_pitch = r_layout->size / sz.depth;
-		r_layout->layer_pitch = r_layout->size / obj.arrayLength;
+
+		uint32_t array_length = obj.arrayLength;
+		if (obj.textureType == MTLTextureTypeCube) {
+			array_length = 6;
+		} else if (obj.textureType == MTLTextureTypeCubeArray) {
+			array_length *= 6;
+		}
+		r_layout->layer_pitch = r_layout->size / array_length;
 	} else {
 		CRASH_NOW_MSG("need to calculate layout for shared texture");
 	}
diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp
index 62c5135172df..2ae365d167e2 100644
--- a/servers/rendering/rendering_device.cpp
+++ b/servers/rendering/rendering_device.cpp
@@ -912,6 +912,8 @@ RID RenderingDevice::texture_create(const TextureFormat &p_format, const Texture
 				"Number of layers must be equal or greater than 1 for arrays and cubemaps.");
 		ERR_FAIL_COND_V_MSG((format.texture_type == TEXTURE_TYPE_CUBE_ARRAY || format.texture_type == TEXTURE_TYPE_CUBE) && (format.array_layers % 6) != 0, RID(),
 				"Cubemap and cubemap array textures must provide a layer number that is multiple of 6");
+		ERR_FAIL_COND_V_MSG(((format.texture_type == TEXTURE_TYPE_CUBE_ARRAY || format.texture_type == TEXTURE_TYPE_CUBE)) && (format.width != format.height), RID(),
+				"Cubemap and cubemap array textures must have equal width and height.");
 		ERR_FAIL_COND_V_MSG(format.array_layers > driver->limit_get(LIMIT_MAX_TEXTURE_ARRAY_LAYERS), RID(), "Number of layers exceeds device maximum.");
 	} else {
 		format.array_layers = 1;


Test patch: