Issues with caching when using a custom thumbnail renderer

I am trying to create a custom thumbnail renderer for one of our data assets by inheriting from UTextureThumbnailRenderer. The renderer uses a texture inside the data asset (these textures are in-engine) to create the required thumbnail. I am registering this thumbnail on post engine load. The data asset thumbnails are initially blank until they are opened or saved, which makes sense given that the data asset has to be loaded to access the texture inside. My expectation was that the engine would cache these thumbnails after this initial save, and the thumbnails should render correctly on subsequent engine loads. However, this is not the case and many of those data assets (not all) still render blank thumbnails. I went through a few other thumbnail renderer implementations in the engine, and it seems a bit unclear what the correct method is to implement a custom thumbnail renderer:

1) ControlRig seems to use the “CustomThumbnailTagName” metadata to indicate which thumbnail to render (ControlRigBlueprint.h, line 198)

2) Niagara seems to set up Thumbnail caching in the asset factory (NiagaraSystemFactoryNew.cpp, line 120)

My question, therefore, is: What is the correct way to implement a custom thumbnail renderer for our use case, and where do we implement caching this thumbnail? If not caching, can you suggest another way to cleanly access the texture inside the data asset without reducing editor performance?

Hi,

Thank you for your inquiry. As I understand, the issue is that custom thumbnails of your saved asset do not show up after engine restart. The engine supports saving and loading custom thumbnails (the Niagara setup is just to ensure a newly-created asset has a thumbnail if needed, before the first save is done). To debug this issue further, I recommend putting a breakpoint in CacheThumbnail (in ObjectTools.cpp) and ensure it gets hit every time your asset is saved in the editor. Then, try placing another breakpoint in FindCachedThumbnail in the same class and restart the engine. Once it’s hit for your specific asset, step into the function to make sure a thumbnail is found. Niagara assets are a good example to follow and compare your custom implementation with.

Feel free to share your findings so that we can investigate this further.

Best Regards,

Zahra Nikbakht

Hi,

Thank you for the reply!

I debugged the issue like you suggested, and it turns out that the thumbnails were getting cached before the texture was fully loaded/built. I was able to fix this by using

Texture->BlockOnAnyAsyncBuild() and they are now caching correctly.

Best regards,

Amritha