HTML5 Saving Freezes Game

JeffreyDriver

  • *
  • Posts: 2151
I've managed to figure out that saving in HTML5 is causing my game to crash, but I don't know why.

This appears in the console. Saving only happens once. I've added a boolean to ensure that it does.

Uncaught RangeError: Maximum call stack size exceeded
    at new empty (Type.hx:118)
    at Function.Type.createEmptyInstance (Type.hx:119)
    at cloner_Cloner.cloneClass (Cloner.hx:99)
    at f (Tools.hx:756)
    at cloner_Cloner.handleClass (Cloner.hx:88)
    at cloner_Cloner._clone (Cloner.hx:65)
    at cloner_Cloner.cloneClass (Cloner.hx:104)
    at f (Tools.hx:756)
    at cloner_Cloner.handleClass (Cloner.hx:88)
    at cloner_Cloner._clone (Cloner.hx:65)
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

Justin

  • *
  • Posts: 4336
Perhaps you have a circular reference in whatever you're saving.

For example, if you had a map ("a") and in that map, one of the values was an array ("b"), and in the array one of the items is map "a" again. When it tries to save, it'll get stuck in a loop.

Or perhaps you have some object in your game attributes that has its own natural circular reference. Like an Actor, for example.

Ensure that the data you're saving is all basic types, and that any lists and maps you're saving aren't in some way contained within themselves.

For Live Support: Join our discord server and ping me @justin.
I'm most often available between 8am and midnight Japan time. (GMT+9)

JeffreyDriver

  • *
  • Posts: 2151
Thanks. I'll dig a little deeper.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

JeffreyDriver

  • *
  • Posts: 2151
Trial and error led me to somewhere I was saving a sound into an attribute. The problem seems to be that I was saving it directly into the attribute rather than in a 'as text' block.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk