VS and game freeze when hitting breakpoint

I am running VS 2017 on Win10 with Monogame 3.7.

I can use break points fine almost anywhere in my game except in a particular piece of code where if I am using a breakpoint both VS and the game window hang and I need to kill the game process to get VS to respond again. Anywhere else is fine.

This is in one of my scene’s update loop

public override void Update(GameTime gameTime)
	{
		if (mouseInputManager.LeftButtonReleased)
		{
			PathFinder pathfinder = new PathFinder(pathFindingWeightedGraph);
			IPathFindingLocation target = pathFindingWeightedGraph.GetPathFindingLocationAtScenePosition(mouseInputManager.Position);
				//Camera.GetSceneRelativePositionFromCameraRelativePosition(mouseInputManager.Position));

			IPathFindingLocation start = pathFindingWeightedGraph.GetPathFindingLocationAtScenePosition(
				((TransformComponent)EntityManager.GetComponentForEntity("prototypeCrewMember", "Transform")).SceneRelativePosition);

			Debug.WriteLine("Target : " + target.ScenePosition);
			Debug.WriteLine("Start : " + start.ScenePosition);
			
			generalDebugUIWidget.AddColorBlockToDraw(target.ScenePosition, new Vector2(15, 15), Color.Black);
			generalDebugUIWidget.AddColorBlockToDraw(start.ScenePosition, new Vector2(15, 15), Color.Black);


		}

		base.Update(gameTime);
	}

If I put a breakpoint anywhere in the if statement I have the problem as soon as the if returns true (when I click somewhere in the game screen).

Anyone has an idea what could be happening ?

I don’t think that was it since it runs without any problem without a break point.

Weird thing is that was on my work computer. I just got home and tried it here and the break point gets hit no problem. Behaves as expected … I have the same version of everything here and at work so I am really puzzled about the whole thing but at least it works so I can debug the problem I was trying to get rid of.

Thanks for trying :slight_smile:

Are you running the game in fullscreen ? I had a similar problem and discovered that the debugger has some problem with directx if fullscreen is set. I now run my game in windowed mode (while testing).

2 Likes

Are you by any chance interrupting a draw call or breaking while the GPU is getting info. Cause that tends cause issues.

1 Like

Not running in fullscreen ever while testing. So that’s not it.

I don’t think I am interrupting a draw call this code path comes from the Update() of game.cs so unless monogame is running Draw() at the same time on an other thread it is not interrupting a draw call.

And like I said in my previous reply what is really weird is that I can break in that code just fine at home but I can’t at work. Same versions of everything. I guess I might be hitting some kind of edge case with the hardware I have at work.