nesrak1 / UABEA

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

Huge asset bundle saves failed #274

Open nsYW opened 10 months ago

nsYW commented 10 months ago

Describe the bug When I save a huge modified unity3d file, there will be pop a write exception window. And it represent: here was a problem while writing the file:

**System.IO.IOException: Stream was too long.
   at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at AssetsTools.NET.Extra.Net35Polyfill.CopyToCompat(Stream input, Stream output, Int64 bytes, Int32 bufferSize)
   at AssetsTools.NET.AssetsFile.Write(AssetsFileWriter writer, Int64 filePos, List`1 replacers, ClassDatabaseFile typeMeta)
   at UABEAvalonia.InfoWindow.SaveFile(Boolean saveAs) in D:\a\UABEA\UABEA\UABEAvalonia\InfoWindow.axaml.cs:line 509**

PS: this exception only happens in UABEA, UABE can save the file easily.

To Reproduce Steps to reproduce the behavior:

  1. Click the "File", then click the "Save" or press "Ctrl+s"
  2. See error

Expected behavior here was a problem while writing the file:

System.IO.IOException: Stream was too long.
   at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at AssetsTools.NET.Extra.Net35Polyfill.CopyToCompat(Stream input, Stream output, Int64 bytes, Int32 bufferSize)
   at AssetsTools.NET.AssetsFile.Write(AssetsFileWriter writer, Int64 filePos, List`1 replacers, ClassDatabaseFile typeMeta)
   at UABEAvalonia.InfoWindow.SaveFile(Boolean saveAs) in D:\a\UABEA\UABEA\UABEAvalonia\InfoWindow.axaml.cs:line 509

Screenshots 图片

Additional context N/A

nesrak1 commented 10 months ago

This is less of a "bug" and more of a known limitation. I didn't actually expect anyone to find a bundle with a single file with a size larger than 2GB, very impressive.

What happens when you save is that UABEA saves the file to memory so that if you close the window but click info again, it can be reopened with the changes you made. However, MemoryStreams in .NET (the thing holding that memory) can only be 2GB maximum.

PS: this exception only happens in UABEA, UABE can save the file easily.

UABE is most likely using a "from assets replacer" which only holds the changes you make in memory instead of the entire file. While I could do that for this version of UABEA, it would be a decent amount of rework. The new version of UABEA already does replacers from assets, so when that fully releases, you'll get the fix with it.

nsYW commented 10 months ago

Thank you for your reply, I'm trying to replace the font files in Blasphemous I. Very much looking forward to the next version of UABEA!