godot icon indicating copy to clipboard operation
godot copied to clipboard

Crash on macOS when importing textures with specific settings

Open vnen opened this issue 1 year ago • 8 comments

Tested versions

4.3-rc1 (also happens in 4.3-beta3)

System information

macOS Sonoma (14.5) with Intel CPU - GPU: Radeon Pro Vega 20

Issue description

When opening the editor to import textures, the editor crashes with a segfault. I'm using the Compatibility renderer.

Stack trace
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007ff810a4b14a libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x0000000107c57555 libsystem_pthread.dylib`pthread_kill + 262
    frame #2: 0x00007ff8109a9b19 libsystem_c.dylib`__abort + 145
    frame #3: 0x00007ff810997ab8 libsystem_c.dylib`__stack_chk_fail + 102
    frame #4: 0x00000001009d60d8 Godot`_compress_astc(Image*, Image::ASTCFormat) + 2168
    frame #5: 0x00000001046031c8 Godot`Image::compress_from_channels(Image::CompressMode, Image::UsedChannels, Image::ASTCFormat) + 200
    frame #6: 0x0000000102093ca5 Godot`ResourceImporterTexture::save_to_ctex_format(Ref<FileAccess>, Ref<Image> const&, ResourceImporterTexture::CompressMode, Image::UsedChannels, Image::CompressMode, float) + 837
    frame #7: 0x00000001020944b1 Godot`ResourceImporterTexture::_save_ctex(Ref<Image> const&, String const&, ResourceImporterTexture::CompressMode, float, Image::CompressMode, bool, bool, bool, bool, bool, bool, bool, bool, unsigned int, Ref<Image> const&, Image::RoughnessChannel) + 721
    frame #8: 0x00000001020960e1 Godot`ResourceImporterTexture::import(String const&, String const&, HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, DefaultTypedAllocator<HashMapElement<StringName, Variant>>> const&, List<String, DefaultAllocator>*, List<String, DefaultAllocator>*, Variant*) + 6257
    frame #9: 0x0000000101b78722 Godot`EditorFileSystem::_reimport_file(String const&, HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, DefaultTypedAllocator<HashMapElement<StringName, Variant>>> const&, String const&, Variant*) + 6178
    frame #10: 0x0000000101b6afe3 Godot`EditorFileSystem::reimport_files(Vector<String> const&) + 3091
    frame #11: 0x0000000101b68b8e Godot`EditorFileSystem::_update_scan_actions() + 5854
    frame #12: 0x0000000101b6f13d Godot`EditorFileSystem::_notification(int) + 621
    frame #13: 0x0000000104a469de Godot`Object::notification(int, bool) + 62
    frame #14: 0x0000000102898bb5 Godot`SceneTree::_process_group(SceneTree::ProcessGroup*, bool) + 405
    frame #15: 0x0000000102896ddf Godot`SceneTree::_process(bool) + 879
    frame #16: 0x000000010289748f Godot`SceneTree::process(double) + 223
    frame #17: 0x0000000100971f71 Godot`Main::iteration() + 1089
    frame #18: 0x000000010090314a Godot`OS_MacOS::run() + 154
    frame #19: 0x00000001009321f3 Godot`main + 387
    frame #20: 0x00007ff8106f8366 dyld`start + 1942

Only happens on macOS. On Linux and Windows it imports the texture just fine.

Disabling ETC2 ASTC makes it not crash but it does not import the texture correctly.

Steps to reproduce

  • Create a project.godot with these settings:
[importer_defaults]

texture={
"compress/channel_pack": 0,
"compress/hdr_compression": 1,
"compress/high_quality": true,
"compress/lossy_quality": 0.7,
"compress/mode": 2,
"compress/normal_map": 0,
"detect_3d/compress_to": 1,
"editor/convert_colors_with_editor_theme": false,
"editor/scale_with_editor_scale": false,
"mipmaps/generate": false,
"mipmaps/limit": -1,
"process/fix_alpha_border": true,
"process/hdr_as_srgb": false,
"process/hdr_clamp_exposure": false,
"process/normal_map_invert_y": false,
"process/premult_alpha": false,
"process/size_limit": 0,
"roughness/mode": 0,
"roughness/src_normal": "",
"svg/scale": 1.0
}

[rendering]

renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"
textures/vram_compression/import_etc2_astc=true
  • Include any texture in the project (can be the default icon.svg).
  • Open the editor to import the files.

Minimal reproduction project (MRP)

import-crash-macos.zip

vnen avatar Jul 26 '24 18:07 vnen

Note: None of my custom builds cause the crash so I couldn't debug it properly. Even with ASAN enabled. Though none import the texture correctly.

Also, it gets to the message astcenc: Encoding took 558 ms. that happens at the end of the _compress_astc() function so the issue might be in some destructor.

vnen avatar Jul 26 '24 18:07 vnen

Do you reproduce the issue with 4.2.2 or earlier dev snapshots?

Note: None of my custom builds cause the crash so I couldn't debug it properly.

Can you reproduce the issue if you build with production=yes like official builds?

akien-mga avatar Jul 27 '24 20:07 akien-mga

Even with ASAN enabled.

I can reproduce it with custom build without ASAN, but can't reproduce with ASAN (maybe since ASAN build increase stack size from 8 MB to 30, and trace indicate stack related issue).

bruvzg avatar Jul 27 '24 21:07 bruvzg

Do you reproduce the issue with 4.2.2 or earlier dev snapshots?

I will try earlier snapshots. With 4.2.2 it does not crash, but it does not import the texture correctly, and it tries to reimport every time the window is focused (which takes a while in the actual project).

vnen avatar Jul 27 '24 23:07 vnen

Checked the snapshots and 4.3-dev4 is the first that crashes. Still couldn't reproduce with my own builds even with production=yes.

vnen avatar Jul 28 '24 01:07 vnen

It might some sort of conflict with ANGLE, which also include own copy of ASTC encoder (none of the symbols should be public), it's not crashing without ANGLE, ~but import is not working.~ Edit: import is working, but MRP is set compatibility renderer, and ASTC is not supported by OpenGL on macOS.

bruvzg avatar Jul 28 '24 10:07 bruvzg

Edit: import is working, but MRP is set compatibility renderer, and ASTC is not supported by OpenGL on macOS.

Okay, this seems to be a different problem. When I disable "High Quality" in the import settings, it actually loads everything just fine, even if the ETC2 ASTC option is on.

Summary:

  • If "High Quality" import setting is OFF, everything works.
  • If "High Quality" import setting is ON, textures do not load, but it does not crash.
  • If "High Quality" import setting is ON and the ETC2 ASTC option is ON, the editor crashes.

Edit: With "High Quality" ON, it imports as BPTC instead of S3TC.

vnen avatar Jul 28 '24 15:07 vnen

It might some sort of conflict with ANGLE, which also include own copy of ASTC encoder (none of the symbols should be public), it's not crashing without ANGLE.

I got it working with enabled ANGLE (by keeping only Godot copy of ASTC encoder), will check if it's working on Windows (might need linking order adjusted for GCC builds), and open PR tomorrow.

bruvzg avatar Jul 28 '24 16:07 bruvzg