Hello unity users.
It’s my first time write to unity forum
I Need HELP!!
here is parts of my project’s crash report…
Thread 0 Crashed:
0 MYPROJECT 0x0000000102eb149c Sprite::GetRenderDataKey() const (in MYPROJECT) + 0
1 MYPROJECT 0x0000000102dfd050 SpriteAtlas::CanBindTo(Sprite const*) const (in MYPROJECT) + 36
2 MYPROJECT 0x000000010306a9d8 SpriteAtlas_CUSTOM_CanBindTo(Il2CppObject*, Il2CppObject*) (in MYPROJECT) + 80
3 MYPROJECT 0x0000000104d2ec14 Image_RebuildImage_mB4AA47E0011889F0491C290A025B1FDC53F53743 (in MYPROJECT) + 280
4 MYPROJECT 0x000000010427ed78 Action_1_Invoke_mB86FC1B303E77C41ED0E94FC3592A9CF8DA571D5_gshared (in MYPROJECT) + 792
5 MYPROJECT 0x00000001029f3f8c RuntimeInvoker_FalseVoid_t22962CB4C05B1D89B55A6E1139F0E87A90987017_RuntimeObject(void ()(), MethodInfo const, void*, void**) (in MYPROJECT) + 20
6 MYPROJECT 0x00000001036cf2b4 il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) (in MYPROJECT) + 108
7 MYPROJECT 0x0000000103019f8c scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) (in MYPROJECT) + 100
8 MYPROJECT 0x00000001030227e4 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) (in MYPROJECT) + 60
9 MYPROJECT 0x0000000102dfda94 SpriteAtlasManager::Register(PPtr) (in MYPROJECT) + 412
10 MYPROJECT 0x000000010415bb54 AssetBundleHelper_OnAtlasRequested_m5DB84044CE68AE1D30678038D377D8512828A4E2 (in MYPROJECT) + 1012
11 MYPROJECT 0x0000000104cc21b4 SpriteAtlasManager_RequestAtlas_m792F61C44C634D9E8F1E15401C8CECB7A12F5DDE (in MYPROJECT) + 304
AssetBundleHelper is my project’s class that handling SpriteAtlas requested.
I Made project use SpriteAtlas using from downloaded assetbundles.
But, on device, Install app and first launch time running normaly. for a while. after move sevaral scenes suddenly occured crash what you look upper crash stacks.
After crash. When I re launch app. It’s OK all the time… that makes me crazy!!!
I can’t found similar case by googling.
Anyone has same experience with my case?.. Somebody help me…
@changdocs @MaydayWorks @leuconoe @joe_nk
Sorry for the delay in response. We are working on a fix for this issue. Will update this thread as soon as we have a fix published. Thanks for posting.
Also not fixed in 2019.4.17f1. We have plans to update to a later version soon. Hopefully it will be fixed there. The stack trace is slightly different:
When a late binding atlas is loaded and TilemapRenderer’s delegates get invoked the game crashes with a null pointer dereference in native code:
Cause: null pointer dereference```
This behaviour appears both in Android build and in the Editor (the editor itself crashes). Naturally, to reproduce it in editor you have to set Sprite Packer Mode to "Always Enabled" in Edit - Project Settings - Editor.
When I create a simple Tilemap from scratch - it doesn't crash the game. However the game *does* crash when our actual assets are loaded. Maybe it has something to do with those assets being created in earlier versions of Unity. I'm still unable to pinpoint a particular cause.
The call stack of the crash is the same in Android build and Mac OS Editor:
```#0 0x00000103252870 in Sprite::GetRenderDataKey() const
#1 0x00000103ddb1f8 in TilemapRenderer::OnSpriteAtlasRegistered(SpriteAtlas*)
#2 0x00000102db01b4 in TilemapRenderer_CUSTOM_OnSpriteAtlasRegistered(ScriptingBackendNativeObjectPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3 0x000006f8533c0c in (wrapper managed-to-native) UnityEngine.Tilemaps.TilemapRenderer:OnSpriteAtlasRegistered (UnityEngine.Tilemaps.TilemapRenderer,UnityEngine.U2D.SpriteAtlas) [{0x3d3e24880} + 0xcc] (0x6f8533b40 0x6f8533ca0) [0x144502a80 - Unity Child Domain]
#4 0x000006f83a0904 in (wrapper delegate-invoke) System.Action`1<T_REF>:invoke_void_T (T_REF) [{0x600001d1ccc0} + 0x224] (0x6f83a06e0 0x6f83a0974) [0x144502a80 - Unity Child Domain]
#5 0x000006f8533b04 in UnityEngine.U2D.SpriteAtlasManager:PostRegisteredAtlas (UnityEngine.U2D.SpriteAtlas) [{0x4308eba48} + 0x9c] [/Users/bokken/buildslave/unity/build/Runtime/2D/SpriteAtlas/ScriptBindings/SpriteAtlas.bindings.cs :: 31u] (0x6f8533a68 0x6f8533b40) [0x144502a80 - Unity Child Domain]
#6 0x000006f5e97930 in (wrapper runtime-invoke) <Module>:runtime_invoke_void_object (object,intptr,intptr,intptr) [{0x430871a10} + 0xc0] (0x6f5e97870 0x6f5e979f8) [0x144502a80 - Unity Child Domain]
#7 0x0000016401190c in mono_jit_runtime_invoke
#8 0x000001641976a8 in do_runtime_invoke
#9 0x000001641975c8 in mono_runtime_invoke
#10 0x000001037a3a48 in scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#11 0x0000010379ebb8 in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#12 0x000001030a72b4 in SpriteAtlasManager::Register(PPtr<SpriteAtlas>)
#13 0x00000102c451a8 in SpriteAtlasManager_CUSTOM_Register(ScriptingBackendNativeObjectPtrOpaque*)
#14 0x000006f8533984 in (wrapper managed-to-native) UnityEngine.U2D.SpriteAtlasManager:Register (UnityEngine.U2D.SpriteAtlas) [{0x2ec0ea318} + 0xa4] (0x6f85338e0 0x6f8533a18) [0x144502a80 - Unity Child Domain]
--- here goes our code providing a loaded atlas to SpriteAtlasManager ---
#15 0x000006f8533728 in game.AssetLoading:CompleteAtlasRequest (string,UnityEngine.U2D.SpriteAtlas,System.Action`1<UnityEngine.U2D.SpriteAtlas>)```
I observe this issue only with TilemapRenderer’s delegates. I’m still unable to pinpoint the issue to make a simple repro project. Seems like it has something to do with our assets made in older Unity versions.
Okay, seems like I’ve found the source of this problem. In my case the crash was caused by Tilemap having Tiles with missing/invalid Sprites. Hard to tell where they came from originally, probably some sprites referenced in Tiles were deleted from the project at some point.
I’ve iterated over all the prefabs in the project and analysed their Tilemaps like this:
static void TilemapForeachTile(UnityEngine.Tilemaps.Tilemap tilemap, TileAction cb = null)
{
var bounds = tilemap.cellBounds;
for(int x = bounds.min.x; x <= bounds.max.x; x++)
{
for(int y = bounds.min.y; y <= bounds.max.y; y++)
{
for(int z = bounds.min.z; z <= bounds.max.z; z++)
{
var coord = new Vector3Int(x, y, z);
var tile = tilemap.GetTile<UnityEngine.Tilemaps.Tile>(coord);
if(tile == null)
continue;
var sprite = tile.sprite;
var sprite_path = AssetDatabase.GetAssetPath(sprite);
var sprite_guid = AssetDatabase.GUIDFromAssetPath(sprite_path);
//Here, if sprite_guid is all zeroes - it means the Tile references a missing/corrupted Sprite
//Such tiles should be removed from the Tilemap
}
}
}
}
The game no longer crashes after I’ve removed all such corrupted Tiles from all the Tilemaps.
Probably there were no crashes in Unity 2018 because TilemapRenderers did not have their own SpriteAtlasManager.atlasRegistered delegates back then. So there was no access to a missing/corrupted Sprite after SpriteAtlas has been loaded.