0
votes

Good day everyone,

I've been building a cross-platform framework/abstraction layer to target Android, iOS and Windows Phone 7 utilising the Mono and XNA frameworks on the appropriate platforms. I am not utilising ExEn, MonoGame or a similar framework, though I have learned much from studying their approach.

The XNA part of the framework extends the XNA Game class, and I am quite certain this is where the problem occurs. I am having some difficulty tracking it down, however, and someone with a better knowledge of the XNA Game class might be of great help. I won't post code for the entire inheritance heirarchy for the class, as it would take up some space, but rather I would request information about the likely source of the problem in the XNA Game class, which may lead me to finding my error.

I am receiving a stack overflow exception when running a test game. The full exception is:

An unhandled exception of type 'System.StackOverflowException' occurred in Microsoft.Xna.Framework.Game.dll

In order to track down the culprit, I have been outputting some simple debug statements to the console. The output I am getting is:

Started init.
Started linear load.
Loading a texture...
Finished loading a texture...
Finished linear load.
Finished init.
Begin run called.
Begin run ended successfully.
Started update.
Ended update.

Process is terminated due to StackOverflowException.

As you can see, it's successfully completing update but is not proceeding to either BeginDraw or EndRun. I have been unable to determine what processes may be taking place at that point in order to lead to a stack overflow exception.

If someone could be of assistance in determining the process that may be occuring at this point, it would undoubtedly be helpful in finding the source of the issue. If you would be more comfortable examining the code, I can certainly provide it, I hesitate to do so as I believe I can determine the problem with more information, and the requisite code base for understanding the issue may prove quite large.

Thank you for your time and assistance, and please let me know if I can provide more information that would prove helpful.

1
Can you check the stack trace of the exception (or maybe paste it in your question)?Ilian
Terribly shameful as it is, I had forgotten I could disable the Just My Code feature and examine the source of the problem. Strangely enough, it seems to be calling OnActivated ad-infinitum.Nathan Runge

1 Answers

2
votes

Solution

It turns out OnActivated was being called repeatedly as a result of my rather foolish step of, apparently, tying the event handling method to the event itself, thereby creating an infinite loop of self-toggling.

Thanks

Thanks go to Illian Pinzon for this helpful, if obvious advice, that snapped my brain out of whatever Android-development induced comatose state it had entered.