Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException in DebugTextSystem #185

Closed
jonstelly opened this issue Sep 5, 2018 · 1 comment
Closed

NullReferenceException in DebugTextSystem #185

jonstelly opened this issue Sep 5, 2018 · 1 comment

Comments

@jonstelly
Copy link

Release Type: GitHub

Version: master

Platform(s): Windows/(All I think?)

Describe the bug
DebugText.Print("something", new Int2(20, 20)) from a script causes a Null Reference Exception in DebugTextSystem line 88. It looks like DebugTextSystem.Content is initialized to null since the DebugTextSystem is created and registered in the Game constructor, while the ContentManager is created and registered later in GameBase.PrepareContext().

To Reproduce
Steps to reproduce the behavior:

  1. Create a basic Game
  2. In the BasicCamerController.Update method, add this line: DebugText.Print("Hello, Crash", new Int2(20, 20));
  3. Get the below exception/crash:

Expected behavior
Debug Text

Screenshots
If applicable, add screenshots to help explain your problem (use GitHub drag & drop)

Log and callstacks

[Game]: Error: Unexpected exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Xenko.Profiling.DebugTextSystem.Draw(GameTime gameTime)
   at Xenko.Games.GameSystemCollection.Draw(GameTime gameTime)
   at Xenko.Games.GameBase.Draw(GameTime gameTime)
   at Xenko.Games.GameBase.DrawFrame()
   at Xenko.Games.GameBase.TickInternal()
System.NullReferenceException: Object reference not set to an instance of an object.
   at Xenko.Profiling.DebugTextSystem.Draw(GameTime gameTime)
   at Xenko.Games.GameSystemCollection.Draw(GameTime gameTime)
   at Xenko.Games.GameBase.Draw(GameTime gameTime)
   at Xenko.Games.GameBase.DrawFrame()
   at Xenko.Games.GameBase.TickInternal()

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Xenko.Profiling.DebugTextSystem.Draw(GameTime gameTime)
   at Xenko.Games.GameSystemCollection.Draw(GameTime gameTime)
   at Xenko.Games.GameBase.Draw(GameTime gameTime)
   at Xenko.Games.GameBase.DrawFrame()
   at Xenko.Games.GameBase.TickInternal()
   at Xenko.Games.GameBase.Tick()
   at Xenko.Games.GamePlatform.Tick()
   at Xenko.Games.GamePlatform.OnRunCallback()
   at Xenko.Games.GameWindowWinforms.<>c__DisplayClass19_0.<Run>b__0()
   at Xenko.Games.WindowsMessageLoop.Run(Control form, RenderCallback renderCallback, Boolean useApplicationDoEvents)
   at Xenko.Games.GameWindowWinforms.Run()
   at Xenko.Games.GamePlatform.Run(GameContext gameContext)
   at Xenko.Games.GameBase.Run(GameContext gameContext)
   at DebugTextTest.DebugTextTestApp.Main(String[] args) in C:\code\misc\DebugTextTest\DebugTextTest\DebugTextTest.Windows\DebugTextTestApp.cs:line 11

Additional context
I can hack around the bug if I change DebugTextSystem line 88 to:

DebugSpriteFont = (Content ?? Services.GetService<IContentManager>()).Load<Texture>("XenkoDebugSpriteFont"),

I can create a pull request for that workaround with a comment about it being a workaround if that's worth doing.

@domske
Copy link

domske commented Sep 8, 2018

Workaround in #41. Duplicate #113.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants