Sprite Atlas white sprites problem

Hi! Let’s describe a problem:

  • I’ve imported 3 sprites for 3 button states
  • I’ve added new SpriteAtlas and put folder with 3 sprites in “Objects for Packing”
  • Made a scene with UI Button
  • Binded 3 sprites to different Button states (sprite swap)
  • Builded Player Content
  • Run game in Packed Play Mode (with hosted service)
  • Loaded that scene via Addressables
  • After load I can see button with image
  • After press, sprite converted to white one
  • After loading another scene and go back to previous one, all Images was white

Bundle Browser shows images and atlases in bundle.

Moreover, I had code like this:

 IconsHandle = Addressables.LoadAssetsAsync<Sprite>(new List<object>(Icons), null, Addressables.MergeMode.Union);
        IList<Sprite> icons = await IconsHandle.Task;

IconPrefab.InstantiateAsync(iconPosition, Quaternion.identity).Completed += icon =>
                {
                    icon.Result.transform.SetParent(ReelsContainer, false);
                    icon.Result.GetComponent<SpriteRenderer>().sprite = iconToInstantiate;
                };

If Icons are just Addressables, all work nice. But if I place one of that icons on scene and rebuild bundles, that icon will be broken:

Looks like problem with dependency packing.

That problem occurs only after switching scenes with:

Addressables.LoadSceneAsync(Name + "/Scenes/MainScene");

Also I have:

P.S. After building for macOS, problem from post 1 disappeared, left only problem with shaders after scene switch. Problem in Editor still the same.

Can you file a bug against Unity with a repro project? We’ve seen some similar issues elsewhere, but having your repro will really help us get to the bottom of this.

I sent a report. There is lack of Zenject of last version to be workable and maybe some project settings. Let me know if you need something more. Case 1170466.

2 Likes

@unity_bill for what it’s worth I think this issue may have re-surfaced. I’d file a bug report but it’s been so hard to reproduce. Basically exact same problem, all my sprites get turned into white/scrambled portion of sprite atlas showing when unloading an unrelated addressables scene (async/additive).

Unity 2020.1.11
Addressables 1.16.7

@AndersonDev wondering if you have been running into this since your report? Surprised you were able to reproduce it, it happens roughly 1/100 for me.

Does anyone know if there’s a way to detect that this happened? For example, would the sprite in the SpriteRenderer/Image component be null in a build?

I would test it myself, but I can’t reproduce the issue. It just happened randomly sometimes in 2020.3.14. I just upgraded to 2021, so maybe that will fix it.

Even if we can’t fix the bug, it would help if I could just log an error as soon as the game boots up with those invalid sprites, but I remember trying and failing to diagnose this before. I’m pretty sure the sprite references weren’t null when the Addressables finished loading, but when I looked at the frame debugger, the shader’s _MainTex was blank instead of pointing to the Sprite Atlas.

It appeared in our project after we implemented sprite atlases. Some of them are on single big sprite (which is atlas), some of them are inside dynamic sprite atlas (.spriteatlas files). Also some of them are in addressables, some are not if it may be related. But still after first opening project I get scrambled parts of atlases or somewhere white sprites. The most interesting thing is that if you look at Inspector window, sprites are set and exists. Even though I can’t see them in preview box while play mode. I looked into frame debugger and while rendering these sprites the _MainTex is set to none.
After restarting unity editor sprites become okay.But still after building the game for android or iOS some sprites are seems to be missing. May anybody explain what’s going on and how exactly it works?
P.S. We use Unity 2020.3.29f1

1 Like

This bug still persists. One the sprite loaded from the spriteatlas becomes the spriteatlas texture itself. We’re not using addressables (but using assetbundles). I don’t know the exact case but I’m now considering that it’s an engine bug.