Every once in a while, you run into one of those problems while debugging where you just don’t get what’s going on. you’ve stepped through the debugger 10 times, and you see it happening, but you just don’t know why.
I ran into one of those a few weeks back, while porting one of my apps to windows 10, where sometimes, when you clicked the back button, nothing would happen. if you clicked it a second time, it went back to the page you were on. And when this state was occurring, there were some other strange things going on that weren’t quite right. I’d been stepping through it over and over, and i got to a place where the same breakpoint was getting hit 2 times, with the same stack when i navigated to the page in the first place. This seemed like a very strange thing. i couldn’t for the life of me figure out how that was possible. did i find some strange subtle bug in the Win10 UWP framework? I figured that to be highly unlikely, i was certainly doing something subtle myself. So i thought, “Hey, self, you used to work on debuggermap, i wonder if there’s something i’m not seeing here..”
So i restarted the app, hit the breakpoint, and pressed “show on codemap” my stack window was then shown as a graph:
yes. that’s the same thing i’ve been looking at the whole time. the red dot is where the breakpoint is, the green chevron was where my cursor was in a file while i was looking through the stack when i took the screenshot. i pressed F5 to go again, since i knew i was just going to end up right back here in a second when the debugger hits the breakpoint again, and…:
Waaaaaaaaaaaaaaait a minute! there’s a triangle here! two different places are calling NavigateTo! how did i not see this before? i had presumed earlier that it was the same exact stack twice, like i somehow had added a listener twice or something, so the event was occurring twice, or something like that. i didn’t realize i had two paths through my own code that were doing this. one of those 2 arrows shouldn’t be there at all! the back button was working just fine: going back once went back to another copy of the page, so it just looked like nothing was happening when you pressed back.
Within 5 seconds of the graph updating, i knew exactly what the problem was. i deleted the one extra call to NavigateTo, and the problem was solved. I’d been banging my head on this for like an hour up to this point, trying to figure out what the repro was, and then staring at the same stack window and code over and over and getting nowhere.
Sometimes you just need to look at the problem a different way! DebuggerMap for the win!