nesrak1 / UABEA

c# uabe for newer versions of unity
MIT License
1.15k stars 149 forks source link

Crashes when Batch importing textures. #330

Open NikolasL015 opened 5 months ago

NikolasL015 commented 5 months ago

I'm using the nightly version, but it still crashes every time I try to import multiple textures2d at once (all the texture names are correct).

LOG: Plugin Batch import textures has crashed. Stacktrace: System.InvalidOperationException: Target width 0 and height 0 must be greater than zero. at SixLabors.ImageSharp.Processing.Processors.Transforms.ResizeHelper.ThrowInvalid(String message) at SixLabors.ImageSharp.Processing.Processors.Transforms.ResizeHelper.CalculateTargetLocationAndBounds(Size sourceSize, ResizeOptions options) at SixLabors.ImageSharp.Processing.Processors.Transforms.ResizeProcessor..ctor(ResizeOptions options, Size sourceSize) at SixLabors.ImageSharp.Processing.ResizeExtensions.Resize(IImageProcessingContext source, ResizeOptions options) at TexturePlugin.TextureEncoderDecoder.<>c__DisplayClass9_0.b__0(IImageProcessingContext i) at TexturePlugin.TextureEncoderDecoder.Encode(Image1 image, Int32 width, Int32 height, TextureFormat format, Int32 quality, Int32 mips) at TexturePlugin.TextureImportExport.Import(Image1 image, TextureFormat format, Int32& width, Int32& height, Int32& mips, UInt32 platform, Byte[] platformBlob) at TexturePlugin.TextureImportExport.Import(String imagePath, TextureFormat format, Int32& width, Int32& height, Int32& mips, UInt32 platform, Byte[] platformBlob) at TexturePlugin.ImportTextureOption.ImportTextures(Window win, List1 batchInfos) at TexturePlugin.ImportTextureOption.ExecutePlugin(Window win, AssetWorkspace workspace, List1 selection) at UABEAvalonia.PluginWindow.BtnOk_Click(Object sender, RoutedEventArgs e) in D:\a\UABEA\UABEA\UABEAvalonia\PluginWindow.axaml.cs:line 53

nesrak1 commented 5 months ago

The code that's having the exception is the mipmapping code trying to scale your image down to 0. However, there's a lot of checks to make sure the image you're importing can be mipmapped. Are you sure you don't actually have a 0x0 image you're importing?

NikolasL015 commented 5 months ago

The code that's having the exception is the mipmapping code trying to scale your image down to 0. However, there's a lot of checks to make sure the image you're importing can be mipmapped. Are you sure you don't actually have a 0x0 image you're importing?

I exported all the textures and modified some of them again, seems to work now. I think one of my old textures was bugged when I saved it in Photoshop. But I have another issue: when I try to import more than 50 modified textures, the program freezes (not responding) forever, is it due to my CPU? (2,9 ghz, 6 cores and 12 threads)

nesrak1 commented 5 months ago

It might just be taking a while. Encoding is definitely slower than decoding. The texture import/export doesn't have a progress bar, but it's probably a good idea to add one in a future update.

NikolasL015 commented 5 months ago

It might just be taking a while. Encoding is definitely slower than decoding. The texture import/export doesn't have a progress bar, but it's probably a good idea to add one in a future update.

I went to sleep to see if it was just slow, but it was still not responding when I woke up after 9 hours. (I've tried it many times.). Then I asked a friend of mine (who has a better CPU than mine) to try it, and he did it with 80 textures, but when he tried to import more than 100, the program froze too.

nesrak1 commented 4 months ago

I'll have to make a big bundle to test on, but 9 hours definitely isn't right. Is it at max cpu the whole time? How big are the textures you're trying to import? I don't think the code could get stuck in a loop after importing too many textures.

NikolasL015 commented 4 months ago

I'll have to make a big bundle to test on, but 9 hours definitely isn't right. Is it at max cpu the whole time? How big are the textures you're trying to import? I don't think the code could get stuck in a loop after importing too many textures.

It uses the maximum CPU in just a fraction of time; all the textures were 512x512. image image

nesrak1 commented 4 months ago

Can you check what texture format they are? I can't reproduce this with DXT5 images. Ten 2048x2048 images import in one second on my computer with a slightly worse CPU than the one in your screenshot.

NikolasL015 commented 4 months ago

Can you check what texture format they are? I can't reproduce this with DXT5 images. Ten 2048x2048 images import in one second on my computer with a slightly worse CPU than the one in your screenshot.

All of them are PNG. I managed to import ten 2048x2048 images too, but my problem is when I try to import more than 50–80.

PS: My 2048x2048 image imports took longer than yours, but it worked. (ten textures) And it used the maximum CPU the whole time, unlike my previous screenshot. image

nesrak1 commented 4 months ago

What texture format are the textures? Not like png, but like RGBA32 or DXT5. Single selecting a texture and clicking plugins -> edit texture will show this.

NikolasL015 commented 4 months ago

What texture format are the textures? Not like png, but like RGBA32 or DXT5. Single selecting a texture and clicking plugins -> edit texture will show this.

Oh sorry, all the textures are ASTC_RGB_8x8