Tom94 / tev

High dynamic range (HDR) image viewer for graphics people
BSD 3-Clause "New" or "Revised" License
1.11k stars 90 forks source link

[MacbookPro M1] Crash on 16k displacement map #178

Open ommaury opened 2 years ago

ommaury commented 2 years ago

Hi Thomas,

On a 14" Macbook Pro M1, I get a crash viewing a 16k map. You can find a map like this here for example: 00_displacement_micro.exr in the following archive: https://vgl.ict.usc.edu/Data/DigitalEmily2/Data/2.1/Emily_2_1_Textures.zip

The stack trace does highlight a metal texture size limitation (in nanogui):

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

Process:               tev [41027]
Path:                  /Applications/tev.app/Contents/MacOS/tev
Identifier:            org.tom94.tev
Version:               1.23 (64 bit) (1.23 (64 bit))
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2022-03-08 15:54:53.4108 -0800
OS Version:            macOS 12.2.1 (21D62)
Report Version:        12
Anonymous UUID:        2F57BED6-4D6F-C2EE-CD1F-8755CA554A7E

Sleep/Wake UUID:       91726AF8-3044-4C94-9BEA-D8422E76F0F7

Time Awake Since Boot: 38000 seconds
Time Since Wake:       1719 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

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

Application Specific Information:
-[MTLTextureDescriptorInternal validateWithDevice:]:1325: failed assertion `Texture Descriptor Validation
MTLTextureDescriptor has width (16804) greater than the maximum allowed size of 16384.
'

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                 0x1c464d9b8 __pthread_kill + 8
1   libsystem_pthread.dylib                0x1c4680eb0 pthread_kill + 288
2   libsystem_c.dylib                      0x1c45be314 abort + 164
3   libsystem_c.dylib                      0x1c45bd6d4 __assert_rtn + 212
4   Metal                                  0x1ccfd7d50 MTLReportFailure.cold.1 + 56
5   Metal                                  0x1ccfc1d04 MTLReportFailure + 476
6   Metal                                  0x1ccfbaa8c _MTLMessageContextEnd + 1068
7   Metal                                  0x1ccf0b8c0 -[MTLTextureDescriptorInternal validateWithDevice:] + 2572
8   AGXMetalG13X                           0x20a1c2780 0x209cf8000 + 5023616
9   tev                                    0x104355548 nanogui::Texture::resize(nanogui::Array<int, 2ul> const&) + 632
10  tev                                    0x1043657cc nanogui::Screen::resize_callback_event(int, int) + 132
11  tev                                    0x10437bd6c -[GLFWWindowDelegate windowDidResize:] + 236
12  CoreFoundation                         0x1c4741200 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28
13  CoreFoundation                         0x1c47e4b84 ___CFXRegistrationPost_block_invoke + 52
14  CoreFoundation                         0x1c47e4af0 _CFXRegistrationPost + 456
15  CoreFoundation                         0x1c470feb0 _CFXNotificationPost + 720
16  Foundation                             0x1c55c5e3c -[NSNotificationCenter postNotificationName:object:userInfo:] + 96
17  AppKit                                 0x1c72f3f40 -[NSWindow _setFrameCommon:display:fromServer:] + 3264
18  tev                                    0x10437e0e4 _glfwPlatformSetWindowSize + 292
19  tev                                    0x104285c5c tev::ImageViewer::insertImage(std::__1::shared_ptr<tev::Image>, unsigned long, bool) + 1044
20  tev                                    0x104282e60 tev::ImageViewer::draw_contents() + 704
21  tev                                    0x1043644e4 nanogui::Screen::draw_all() + 68
22  tev                                    0x10435d3b8 nanogui::mainloop(float) + 512
23  tev                                    0x1042a39c4 tev::mainFunc(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 11136
24  tev                                    0x1042a83a0 main + 828
25  dyld                                   0x1049190f4 start + 520

Hope this helps, Olivier

Tom94 commented 2 years ago

Hi Olivier, this seems to be a fundamental limitation w.r.t. texture size -- not much to be done by tev / nanogui other than detecting such cases and breaking the rendering down into multiple tiled textures.

This is unlikely to happen soon (if at all), but I'm going to keep the issue open as a "TODO" bullet.

Cheers!

ommaury commented 2 years ago

Thanks Thomas for the quick response, makes sense, that's what the native Preview app does it looks like (break the image into 4 tiles).