Search Unity

Solution to Empty/corrupt asset/EndofStreamException: Failed to read past end of stream

Discussion in 'Asset Bundles' started by unitedone3D, Dec 19, 2021.

  1. unitedone3D

    unitedone3D

    Joined:
    Jul 29, 2017
    Posts:
    161
    Hi there!

    I have faced a Problem, which is that an asset that I downloaded worked perfectfly/was downloaded correctly..and everything was alright;...until, it wasn't (the next day so; after I tried to change the asset..and then wish to revert the changes - by reimporting it - it could not, not (correctly) anymore).

    What happened:

    Unity created a corrupted asset file - by itself, because it crashed 2 3 times while I was trying to change a skeletal mesh (already animated/animation vertex data) to have subdivisions (after the model is polygonally-subdivided (to add detail/precision); this can crash Blender, Unity...any 3D program can crash if animation vertex data/skeletal skinned mesh data wreaks havoc with it; it happened not just in Unity; it meant that skeletal vertex data - if Read wrong - can destroy the file/software to - be forced to 'end/abort/crash'; it was FBX 3d model skinned mesh file);

    This file it created is located in the 'Your Project../Library/Artifacts', it is a file that contains 0 byte..is empty and Unity tells you these errors:

    ''Error loading the file 'Library/Artifacts/32/326e47e820bc46df02a2958b7dd90697'. File is either empty or corrupted, please verify the file contents.''

    ''EndofStreamException: Failed to read past end of stream...cannot read beyond end of stream.''

    When I got these console errors, I was like????...then I understood, when I selected the faulty assets...the error Only showed up upon selected the corrupted asset (Unity reimported the asset when I asked it - but it was now corrupted (each time I reimport it anew) - Nothing happens, the imported asset is empty and unresponsive/cannot be loaded...the day before, all was working, the asset was there and working/available...now it'S an empty shell/Unity does not even show anything it just writes in the console (upon clicking the FBX asset): ''Error loading the file 'Library/Artifacts/.......'' )..

    Thus, what is really happening, is so not so much that it is corrupted, it'S that it's Empty (0 byte); Unity Made those empty files (that 0 byte) in the /Library/Artifacts....directory folder...
    After that it says : ''serialization problem''...

    Of course the file serialisation is now messed up...and thus the asset is never imported correctly; because Unity Detects Empty Files (0 byte)...

    Solution to Problem:

    Go to your Library/Artifacts....open windows explorer....in search - click 'empty-files - 0kb'....the list will come up...Erase Them/Delete'...(make sure it is Only 0 byte/empty, each file).

    Reimport the asset.

    Now, the problem is (almost) fixed, in Unity, the asset will Still Not import correctly...even if you removed the offending files/empty files that Unity engine made.

    So...

    One Last Step, the easiest (but takes you a bit of your time...to wait)...is Restart Unity entirely.

    Now.

    It is fixed,

    because the Serialization process will begin anew and will Correctly serialize/read the correct Artifact files...and make the 'asset appear' inside Unity as it should have (because there are no more empty serialization files that 'jam' the import process/reading, of asset file)...and Unity reads it/accesses it
    correctly this time.


    Hope this helps anyone getting this error!