nesrak1 / UABEA

c# uabe for newer versions of unity
MIT License
1.05k stars 135 forks source link

Crash when loading Pillars of Eternity 1 assets #282

Closed TheForgotten69 closed 7 months ago

TheForgotten69 commented 8 months ago

Describe the bug The application crashed when trying to load any kind of assets from PoE 1. Here's the crash logs: Application: UABEAvalonia.exe CoreCLR Version: 6.0.2423.51814 .NET Version: 6.0.24 Description: The process was terminated due to an unhandled exception. Exception Info: System.ArgumentException: The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'. (Parameter 'chars') at System.Text.Encoding.ThrowCharsOverflow(DecoderNLS decoder, Boolean nothingDecoded) at System.Text.Encoding.GetCharsWithFallback(ReadOnlySpan1 bytes, Int32 originalBytesLength, Span1 chars, Int32 originalCharsLength, DecoderNLS decoder) at System.Text.UTF8Encoding.GetCharsWithFallback(ReadOnlySpan1 bytes, Int32 originalBytesLength, Span1 chars, Int32 originalCharsLength, DecoderNLS decoder) at System.Text.Encoding.GetCharsWithFallback(Byte* pOriginalBytes, Int32 originalByteCount, Char* pOriginalChars, Int32 originalCharCount, Int32 bytesConsumedSoFar, Int32 charsWrittenSoFar, DecoderNLS decoder) at System.Text.DecoderNLS.GetChars(Byte* bytes, Int32 byteCount, Char* chars, Int32 charCount, Boolean flush) at System.Text.Decoder.GetChars(ReadOnlySpan1 bytes, Span1 chars, Boolean flush) at System.IO.BinaryReader.Read() at System.IO.BinaryReader.ReadChar() at AssetsTools.NET.AssetsFileReader.ReadNullTerminated() at AssetsTools.NET.AssetsFileExternal.Read(AssetsFileReader reader) at AssetsTools.NET.AssetsFileMetadata.Read(AssetsFileReader reader, UInt32 version, Int64 dataOffset) at AssetsTools.NET.AssetsFileMetadata.Read(AssetsFileReader reader, AssetsFileHeader header) at AssetsTools.NET.AssetsFile.Read(AssetsFileReader reader) at AssetsTools.NET.Extra.AssetsFileInstance..ctor(Stream stream, String filePath) at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFileCacheless(Stream stream, String path, Boolean loadDeps, BundleFileInstance bunInst) at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFile(FileStream stream, Boolean loadDeps) at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFile(String path, Boolean loadDeps) at UABEAvalonia.MainWindow.OpenFiles(String[] files) in D:\a\UABEA\UABEA\UABEAvalonia\Forms\MainWindow.axaml.cs:line 111 at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state) at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore() at Avalonia.Threading.DispatcherOperation.Execute() at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job) at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback) at Avalonia.Threading.Dispatcher.Signaled() at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg) at Avalonia.Win32.Win32DispatcherImpl.RunLoop(CancellationToken cancellationToken) at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl) at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode) at UABEAvalonia.Program.Main(String[] args) in D:\a\UABEA\UABEA\UABEAvalonia\Program.cs:line 53

To Reproduce Steps to reproduce the behavior:

  1. Load any assets from Pillars of Eternity 1
  2. See error

Expected behavior The asset should be loaded.

Screenshots

Additional context

nesrak1 commented 8 months ago

I don't know what specific file you tried to load, but I had a totally different issue (that eventually resolved itself after enough time) with the globalgamemanager being inefficiently queried for every dependency loaded and taking a long time to load. For now, you can rename to something else or move the globalgamemanagers file so it doesn't try to do this. I did not get the error you posted just randomly trying to open files however.

TheForgotten69 commented 8 months ago

Thanks for responding so quickly - that's really appreciated. i tried to load any files from the assets bundle. I tried this file px2_0003_shop.unity3d which seemly had another error. Application: UABEAvalonia.exe CoreCLR Version: 6.0.2423.51814 .NET Version: 6.0.24 Description: The process was terminated due to an unhandled exception. Exception Info: System.ArgumentOutOfRangeException: Non-negative number required. (Parameter 'capacity') at System.Collections.Generic.List`1..ctor(Int32 capacity) at AssetsTools.NET.AssetsFileMetadata.Read(AssetsFileReader reader, UInt32 version, Int64 dataOffset) at AssetsTools.NET.AssetsFileMetadata.Read(AssetsFileReader reader, AssetsFileHeader header) at AssetsTools.NET.AssetsFile.Read(AssetsFileReader reader) at AssetsTools.NET.Extra.AssetsFileInstance..ctor(Stream stream, String filePath) at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFileCacheless(Stream stream, String path, Boolean loadDeps, BundleFileInstance bunInst) at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFile(FileStream stream, Boolean loadDeps) at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFile(String path, Boolean loadDeps) at UABEAvalonia.MainWindow.OpenFiles(String[] files) in D:\a\UABEA\UABEA\UABEAvalonia\Forms\MainWindow.axaml.cs:line 111 at System.Threading.Tasks.Task.<>c.b__128_0(Object state) at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore() at Avalonia.Threading.DispatcherOperation.Execute() at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job) at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback) at Avalonia.Threading.Dispatcher.Signaled() at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg) at Avalonia.Win32.Win32DispatcherImpl.RunLoop(CancellationToken cancellationToken) at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl) at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode) at UABEAvalonia.Program.Main(String[] args) in D:\a\UABEA\UABEA\UABEAvalonia\Program.cs:line 53

Maybe something for older version of unity isn't present?

nesrak1 commented 8 months ago

Can't reproduce, that bundle opens fine for me and I'm able to view data and export on randomly selected assets. Maybe make sure you are using nightly UABEA?

TheForgotten69 commented 8 months ago

I'm sure sadly - if you can't reproduce there must be something missing on my end... it seems that every time I'm trying to open the assets for this game, a new error arise: Application: UABEAvalonia.exe CoreCLR Version: 6.0.2423.51814 .NET Version: 6.0.24 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.EndOfStreamException: Unable to read beyond the end of the stream. at System.IO.BinaryReader.InternalRead(Int32 numBytes) at System.IO.BinaryReader.ReadUInt32() at AssetsTools.NET.AssetsFileReader.ReadUInt32() at AssetsTools.NET.AssetFileInfo.Read(AssetsFileReader reader, UInt32 version) at AssetsTools.NET.AssetsFileMetadata.Read(AssetsFileReader reader, UInt32 version, Int64 dataOffset) at AssetsTools.NET.AssetsFileMetadata.Read(AssetsFileReader reader, AssetsFileHeader header) at AssetsTools.NET.AssetsFile.Read(AssetsFileReader reader) at AssetsTools.NET.Extra.AssetsFileInstance..ctor(Stream stream, String filePath) at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFileCacheless(Stream stream, String path, Boolean loadDeps, BundleFileInstance bunInst) at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFile(FileStream stream, Boolean loadDeps) at AssetsTools.NET.Extra.AssetsManager.LoadAssetsFile(String path, Boolean loadDeps) at UABEAvalonia.MainWindow.OpenFiles(String[] files) in D:\a\UABEA\UABEA\UABEAvalonia\Forms\MainWindow.axaml.cs:line 111 at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state) at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore() at Avalonia.Threading.DispatcherOperation.Execute() at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job) at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback) at Avalonia.Threading.Dispatcher.Signaled() at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg) at Avalonia.Win32.Win32DispatcherImpl.RunLoop(CancellationToken cancellationToken) at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl) at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode) at UABEAvalonia.Program.Main(String[] args) in D:\a\UABEA\UABEA\UABEAvalonia\Program.cs:line 53

is there some dependency I'm missing or log level I should set to debug more thoroughly?

nesrak1 commented 8 months ago

What this error is saying is that something in the header read incorrectly. There have been issues with OS languages doing weird things, but according to the exception language you're using English, so that can't be the issue. The other issue is that your files are in a different format somehow? Now that I look at it, my bundle is called px2_0003_shop (which I have from epic games), and not px2_0003_shop.unity3d (as it seems to be on steam). Without the files, it's hard to tell the issue, other than that the header is being read incorrectly.

If you know how to debug, you could compile AssetsTools.NET from source and open the bundle with AssetsView. Then you can see where in the code it got stuck and see what it tried to read. It's possible that the format of the files is modified from the normal format somehow.

TheForgotten69 commented 8 months ago

My OS is indeed in English. I think I know the difference we have - The epic version is compiled against a later version of unity (2019 I guess) compared to GoG and Steam. I can definitely send some files as well in the meanwhile if you deemed it useful.

Doing some debug and it seems that the program tries to read another int32 but there isn't any data in the stream. Thanks again for your responses!

TheForgotten69 commented 8 months ago

I managed to find likewise assets that are triggering this. assetbundles.zip

nesrak1 commented 7 months ago

Your version of the game is unity 4.x which is not supported by AssetsTools.NET. Most likely it won't ever be supported since 3.x and 4.x games are a lot of work for the very few games that use it compared to 5.x+.