System.IO.EndOfStreamException in MonoGame.Framework/Graphics/DxtUtil.cs

I updated Xamarin, Xcode and MG to latest versions this weekend and tried to make a new build of my game. But an error keeps showing up on both emulators and test iOS devices:

In MonoGame.Framework/Graphics/DxtUtil.cs, line 339:

byte alpha0 = imageReader.ReadByte();

“System.IO.EndOfStreamException has been thrown
Failed to read past end of stream.”

Below is the call stack:

System.IO.BinaryReader.ReadByte () in /Users/builder/data/lanes/2077/d230615b/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.IO/BinaryReader.cs:313
Microsoft.Xna.Framework.Graphics.DxtUtil.DecompressDxt5Block (imageReader={System.IO.BinaryReader}, x=0, y=256, blockCountX=512, width=2048, height=2048, imageData={byte[16777216]}) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Graphics/DxtUtil.cs:339
Microsoft.Xna.Framework.Graphics.DxtUtil.DecompressDxt5 (imageStream={System.IO.MemoryStream}, width=2048, height=2048) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Graphics/DxtUtil.cs:329
Microsoft.Xna.Framework.Graphics.DxtUtil.DecompressDxt5 (imageData={byte[2097152]}, width=2048, height=2048) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Graphics/DxtUtil.cs:313
Microsoft.Xna.Framework.Content.Texture2DReader.Read (reader={Microsoft.Xna.Framework.Content.ContentReader}, existingInstance=(null)) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentReaders/Texture2DReader.cs:133
Microsoft.Xna.Framework.Content.ContentTypeReader<Microsoft.Xna.Framework.Graphics.Texture2D>.Read (input={Microsoft.Xna.Framework.Content.ContentReader}, existingInstance=(null)) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentTypeReader.cs:181
Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject<Microsoft.Xna.Framework.Graphics.Texture2D> (existingInstance=(null)) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentReader.cs:175
Microsoft.Xna.Framework.Content.ContentReader.ReadObject<Microsoft.Xna.Framework.Graphics.Texture2D> (existingInstance=(null)) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentReader.cs:162
Microsoft.Xna.Framework.Content.ContentReader.ReadObject<Microsoft.Xna.Framework.Graphics.Texture2D> () in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentReader.cs:150
Microsoft.Xna.Framework.Content.SpriteFontReader.Read (input={Microsoft.Xna.Framework.Content.ContentReader}, existingInstance=(null)) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentReaders/SpriteFontReader.cs:74
Microsoft.Xna.Framework.Content.ContentTypeReader<Microsoft.Xna.Framework.Graphics.SpriteFont>.Read (input={Microsoft.Xna.Framework.Content.ContentReader}, existingInstance=(null)) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentTypeReader.cs:181
Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject<Microsoft.Xna.Framework.Graphics.SpriteFont> (existingInstance=(null)) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentReader.cs:175
Microsoft.Xna.Framework.Content.ContentReader.ReadObject<Microsoft.Xna.Framework.Graphics.SpriteFont> (existingInstance=(null)) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentReader.cs:162
Microsoft.Xna.Framework.Content.ContentReader.ReadObject<Microsoft.Xna.Framework.Graphics.SpriteFont> () in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentReader.cs:150
Microsoft.Xna.Framework.Content.ContentReader.ReadAsset<Microsoft.Xna.Framework.Graphics.SpriteFont> () in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentReader.cs:72
Microsoft.Xna.Framework.Content.ContentManager.ReadAsset<Microsoft.Xna.Framework.Graphics.SpriteFont> (assetName="Fonts/titleFont", recordDisposableObject=(null)) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentManager.cs:294
Microsoft.Xna.Framework.Content.ContentManager.Load<Microsoft.Xna.Framework.Graphics.SpriteFont> (assetName="Fonts/titleFont") in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Content/ContentManager.cs:209
MyGame.ScreenManager.LoadContent () in /Users/Greyp/Desktop/MyGame/Game/ScreenManager/ScreenManager.cs:610
Microsoft.Xna.Framework.DrawableGameComponent.Initialize () in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/DrawableGameComponent.cs:63
MyGame.ScreenManager.Initialize () in /Users/Greyp/Desktop/MyGame/Game/ScreenManager/ScreenManager.cs:594
Microsoft.Xna.Framework.Game.InitializeExistingComponents () in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Game.cs:727
Microsoft.Xna.Framework.Game.Initialize () in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Game.cs:532
MyGame.GameStateManagementGame.Initialize () in /Users/Greyp/Desktop/MyGame/Game/Program.cs:136
Microsoft.Xna.Framework.Game.DoInitialize () in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Game.cs:679
Microsoft.Xna.Framework.Game.Run (runBehavior=Microsoft.Xna.Framework.GameRunBehavior.Asynchronous) in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Game.cs:384
Microsoft.Xna.Framework.Game.Run () in /Users/Greyp/Desktop/MonoGame/MonoGame.Framework/Game.cs:370
MyGame.Program.FinishedLaunching (app={<UIApplication: 0x79777140>}) in /Users/Greyp/Desktop/MyGame/Game/Main.cs:32
UIKit.UIApplication.UIApplicationMain () in 
UIKit.UIApplication.Main (args={string[0]}, principal=0x0, delegate=0x79623150) in /Users/builder/data/lanes/2077/d230615b/source/maccore/src/UIKit/UIApplication.cs:74
UIKit.UIApplication.Main (args={string[0]}, principalClassName=(null), delegateClassName="AppDelegate") in /Users/builder/data/lanes/2077/d230615b/source/maccore/src/UIKit/UIApplication.cs:58
MyGame.Program.Main (args={string[0]}) in /Users/Greyp/Desktop/MyGame/Game/Main.cs:40

Can someone please help with this problem? Thanks very much in advance! =)

Can someone help me solve this issue please? I don’t know what exactly happened, but my code was working before I updated the dev tools and MG source…

Have you rebuilt your content with the new content pipeline? It is likely the textures were built with the previous XNA-based content pipeline extensions that re-used the DXT flag for PVR compression. Now we have our own content pipeline that handles PVR compressed textures properly.

Thanks for the reply @KonajuGames ! I’ll give it a try later today! :smile:

Hi @KonajuGames, I tried rebuilding the content with MG3.4 (for VisualStudio) content pipeline tool, but the same problem is still there… :frowning:

Oh there is one thing I forgot: the fonts were built using the old content pipeline project, because I couldn’t figure out how to make my custom content processor work with the new pipeline tool. Not sure if that is the cause…

That will likely be it. The texture inside the font xnb will likely have been compressed using PVR but using the DXT flag.

I see… But I still couldn’t figure out how to make my custom processor work with the pipeline tool… Asked the same question again in a new post (Is there a detailed tutorial on how to use custom content processor with the pipeline tool?), and really wish there could be someone familiar with that kind of problems…

Thanks very much for your help again @KonajuGames!