Crash on builds TextCore::TryAddGlyphToTextureSingleThread

Hi, I recenty updated to TMP 2.1.4 and we are using Unity 2019.4.14f1

After the update everything worked fine, and then some time after I regenerated the tmp fonts, in editor everything seems fine, but on device when we tried to open a screen that shows several of those fonts at the same time (its a language select screen, for now uses all fonts, will see about improving that) it crashes with a bad access on devices, and gets stuck on mac.

I checked the crash on ios and the bad access was on

stacktrace

0   UnityFramework                    0x00000001028c8544 TextCore::TryAddGlyphToTextureSingleThread(unsigned int, int, TextCore::GlyphPackingMode, dynamic_array<TextCore::GlyphRect, 0ul>&, int&, dynamic_array<TextCore::GlyphRect, 0ul>&, int&, TextCore::R... + 696
1   UnityFramework                    0x00000001028c8384 TextCore::TryAddGlyphToTextureSingleThread(unsigned int, int, TextCore::GlyphPackingMode, dynamic_array<TextCore::GlyphRect, 0ul>&, int&, dynamic_array<TextCore::GlyphRect, 0ul>&, int&, TextCore::R... + 248
2   UnityFramework                    0x00000001028c8c78 TextCore::FontEngine::TryAddGlyphToTexture(unsigned int, int, TextCore::GlyphPackingMode, dynamic_array<TextCore::GlyphRect, 0ul>&, int&, dynamic_array<TextCore::GlyphRect, 0ul>&, int&, TextCore::R... + 320
3   UnityFramework                    0x00000001028cc3e4 FontEngine_CUSTOM_TryAddGlyphToTexture_Internal(unsigned int, int, TextCore::GlyphPackingMode, ScriptingBackendNativeArrayPtrOpaque*, int*, ScriptingBackendNativeArrayPtrOpaque*, int*, TextCore::Re... + 276 (TextCoreBindings.gen.cpp:584)
4   UnityFramework                    0x0000000103d30c78 FontEngine_TryAddGlyphToTexture_Internal_mAD9085B9AF5B6BEBAB100A0F0DD3114CF23B7E82 + 72 (UnityEngine.TextCoreModule.cpp:4383)
5   UnityFramework                    0x0000000103d30c78 FontEngine_TryAddGlyphToTexture_mD70AEC0FDCEE818B4366C78FF662464F13112172 + 812 (UnityEngine.TextCoreModule.cpp:4263)
6   UnityFramework                    0x0000000103c5cddc TMP_FontAsset_TryAddCharacterInternal_mEA410CC2F803499842A2D223B48B46506CEA0E6E + 960 (Unity.TextMeshPro.cpp:40933)
7   UnityFramework                    0x0000000103c6159c TMP_FontAssetUtilities_GetCharacterFromFontAsset_Internal_mB55898D627A3FBB7C29C08FA60F2B3C9301C5B39 + 540 (Unity.TextMeshPro1.cpp:23044)
8   UnityFramework                    0x0000000103c92994 TMP_Text_GetTextElement_m35E1CC227F517766F74BB989A35588FF5F7C52FC + 152 (Unity.TextMeshPro2.cpp:49267)
9   UnityFramework                    0x0000000103cb025c TextMeshProUGUI_SetArraySizes_m876EAE8394515E722551C88F77D2CD650E5BB3A2 + 2208 (Unity.TextMeshPro4.cpp:17857)
10  UnityFramework                    0x0000000103cb25dc TextMeshProUGUI_OnPreRenderCanvas_mA1BB76D11387DF804E68A7C05BA58651ADAC825E + 472 (Unity.TextMeshPro4.cpp:19688)
11  UnityFramework                    0x0000000103cbbbec TextMeshProUGUI_Rebuild_m7BA4E1445DB42FD1EC2DB0A92324458BD178F610 + 196 (Unity.TextMeshPro4.cpp:34165)
12  UnityFramework                    0x0000000103d42ac4 Invoke + 88 (UnityEngine.UI.cpp:94)
13  UnityFramework                    0x0000000103d42ac4 CanvasUpdateRegistry_PerformUpdate_m6C0C51EBC871BFD67FEE7403B0A4D8FC99AAE93E + 1132 (UnityEngine.UI.cpp:28253)
14  UnityFramework                    0x0000000103d95bb4 WillRenderCanvases_Invoke_m115F44E08A802F1800D79D3B92EE1A575AD08834 + 276
15  UnityFramework                    0x00000001020cbc24 RuntimeInvoker_FalseVoid_t22962CB4C05B1D89B55A6E1139F0E87A90987017(void (*)(), MethodInfo const*, void*, void**) + 20 (Il2CppInvokerTable.cpp:42648)
16  UnityFramework                    0x0000000102f18bc4 0x102000000 + 15829956
17  UnityFramework                    0x0000000102717e4c scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) + 112
18  UnityFramework                    0x0000000102722be0 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) + 116
19  UnityFramework                    0x00000001022fdd20 UI::CanvasManager::WillRenderCanvases() + 60
20  UnityFramework                    0x0000000102631e44 0x102000000 + 6495812
21  UnityFramework                    0x0000000102631e78 0x102000000 + 6495864
22  UnityFramework                    0x00000001026320dc 0x102000000 + 6496476
23  UnityFramework                    0x0000000102a332a0 UnityPlayerLoopImpl(bool) + 224
24  UnityFramework                    0x0000000102019cb8 UnityRepaint + 140 (UnityAppController+Rendering.mm:282)
25  UnityFramework                    0x0000000102019b94 -[UnityAppController(Rendering) repaintDisplayLink] + 88 (UnityAppController+Rendering.mm:71)
26  QuartzCore                        0x00000001b7260418 CA::smile:isplay::smile:isplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 516 (CADisplay.mm:2528)
27  IOKit                             0x00000001b17f66d0 IODispatchCalloutFromCFMessage + 480 (IOKitLib.c:1239)
28  CoreFoundation                    0x00000001b0807c74 __CFMachPortPerform + 172 (CFMachPort.c:533)
29  CoreFoundation                    0x00000001b08312b4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56 (CFRunLoop.c:1937)
30  CoreFoundation                    0x00000001b08309c0 __CFRunLoopDoSource1 + 444 (CFRunLoop.c:2075)
31  CoreFoundation                    0x00000001b082b774 __CFRunLoopRun + 1888 (CFRunLoop.c:3098)
32  CoreFoundation                    0x00000001b082ace8 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3192)
33  GraphicsServices                  0x00000001ba97538c GSEventRunModal + 160 (GSEvent.c:2246)
34  UIKitCore                         0x00000001b4959444 UIApplicationMain + 1932 (UIApplication.m:4823)
35  UnityFramework                    0x0000000102018654 -[UnityFramework runUIApplicationMainWithArgc:argv:] + 108 (main.mm:96)
36  testing                           0x0000000100b0be1c main + 68 (main.mm:26)
37  libdyld.dylib                     0x00000001b06b28f0 start + 4

We are. not using dynamic tmp fonts so I don’t see why it would try to add a missing glyph (in other places showing text with missing glyphs seems to work fine without crashing)

I tried to revert the commit with the font regeneration and it works after reverting that. Those are the only chances reverted so I am sure the problem is related to those fonts.

I created a bug report, but have been unable to create a repro case
case: 1319567

Thanks for any information.

Rubén

1 Like

The issue still happens with TMP 3.0.4 and Unity 2020.3.4f1 - it seems it has been fixed in TMP 3.0.5 though.

Hi I am really sorry I completely forgot about this thread since it saw no movement since I posted it.

I was contacted by unity to try to solve this issue and what I was able to find was this


I think I found the problem, before regenerating the font textures, one of them “NotoSansCJKzhhant-Bold SDF.asset” was setup as dynamic by mistake, after regenerating with the new version of Text Mesh Pro this didn’t change but what changed is that all fonts (including the dynamic one) changed its config to not be readable.

This is in the changelogs and I assume is the root of the issue

  • Fixed Font Asset Creator incorrectly leaving the Readable state of font asset atlas textures to readable where it should be set to non readable for static font assets. Case #1305520

In this case, for this particular font that was dynamic it should not have changed it to not readable.

In the end for us the fix was setting that font that was dynamic by mistake as static (we didn’t want it as dynamic) and regenerating.

Hope this helps

Rubén

1 Like

That appears to be the same issue. Let me know if this resurfaces at any point.

1 Like

@Stephan_B In Unity 2022.1.9 with TMP 3.0.6, “Is Readable” is always set to false on the Atlas Texture after saving from the Font Asset Creator, regardless of whether it’s set to dynamic or static.

Then, when it’s dynamic, you’ll get errors about TMP being unable to add missing glyphs to the atlas.

Should I make a repro project?