Object too deep.

So this is going to be a bit of a hard one I think, but I'll try to go over this as well as I can from a non programmer's standpoint.

I am getting the object too deep error, and have narrowed it down to 2 conflicting JS plugins. The first is a plugin that summons an actor to the battle: http://sumrndm.site/summon-core/

And the second is a JS plugin that expands on restrictions in the game (such as needing to have a state to use a skill, or be a certain class): https://forums.rpgmakerweb.com/inde...kill-and-skill-type-restrictions-1-5-3.49224/

These 2 plugins work fine when running together until I actually put a restriction on a skill - it doesn't actually matter what skill as long as the actor using the summon ability has it learned, as soon as I use the tag, I will get this error. Here is how to replicate the bug: After restricting a skill (what I was using
<Restrict>
State: 998
</Restrict>
)
Go into combat and summon an actor using the plugin. On the next turn, when you go to your skill menu the game will crash and you will get the error "Object too deep."

After looking around for hours I found that this may be caused by the two plugins using the same variable perhaps? I'm not sure at all, since I am really bad at programming. If anyone could help me out on this, it would be greatly appreciated. Both of these plugins are core to my game, and without them a looooot of things won't work in the game.

Thanks for your consideration~
Greetings KawaiiKid,
I am getting the object too deep error, and have narrowed it down to 2 conflicting JS plugins.
Thank you for narrowing it down to two plugins, that makes it a lot easier for other's to reproduce your bug & then try to squash it.​

The next step that would really help are:
  1. Reproduce the bug in a totally empty project (so that other's can do this on their computer) with just those two plugins & nothing else.
  2. Post screen shots of this in clear SPOILER tags.
  3. Post very brief instructions (which you have already started above) of the plugins.
Let me explain this step by step & how a good bug report is made using Sharm's bug report on MOG_CursorBorder as a sample of a really good report that made it easy to find the bug and stomp it:

First she explained the bug clearly in one sentence:
The default border is correct, circling the character only, but Mog's extra border goes around the entire character section, or off screen when selecting the second character.
Second & most importantly she took time to reproduce the bug & using SPOILER tags posted them:
  1. She posted "some images of the problem, using the menu's demo file, only adding the mog border plugin".
  2. Then she posted a second step of images "Here's how it looks with the default border (no Mog plugin)"
  3. Then she posted a third set of images "Here's Mog's plugin on a default menu"
The most important part of that was "using the menu's demo file". This made it very easy to reproduce the bug.

Third (you have already done this), she explained where to find the two plugin's so we could reproduce the bug:
The above steps made it much easier to reproduce the bug, so it only took me about one hour to reproduce the bug following Sharm's instructions. I then explained in detail, for others helping to look for the bug how to reproduce the bug:
  • Download Galv's menu plugin (Same link that Sharm gave)
  • Download Mog's cursor border plugin (Same link that Sharm gave)
  • Copy the following files from Mog's project into Galv's project:
    • js/plugins/MOG_CursorBorder.js
    • img/system/CursorBorderA.png
    • img/system/CursorBorderB.png
  • Enable MOG_CursorBorder (as second plugin)
So I am asking you to follow these steps & yes it will probably take you one to two hours (maybe longer) to do this:
  • Isolate the problem down to "using the menu's demo file" with just plugins.
  • Post images of this in SPOILER tags like Sharm did.
  • Post clear step by step instructions like I did.
This will make it much easier for others, so they might be able to stomp your bug in one to two hours (maybe longer).

Without clear instructions from you, it could easily take them even more hours to stomp your bug. Thus solving bugs is a cooperative process between the bug reporter & the people trying to stomp the bug.
​
Thanks,

Joy Diamond
P.S.: Sharm's instructions were very easy to follow. And good bug reporting by making this on a very simple project that easy to reproduce.

​
Alright, going off what I said above, I've recreated the bug in a demo file you can find here:

(I've removed almost all the sound and images from the folder to reduce the size of the download)

After loading the plugins, the first step is to make an actor that will be summoned into the battle. For the Demo I named this: "Summoned Thing"
Spoiler
OGRvchn.png

Next is to create a skill that will summon him. This is done by creating a spell, and placing the following in the note tag:
<Summon>
Actor ID: 5
<End Summon>
The actor ID being the actor who will be summoned into the battle.
Spoiler
ewBpa8Z.png

So far this has all been for the summon plugin, which works fine. You can go into the demo and fight, and you can summon the enemy and cast spells without hitch after this. Next we will move on to the Restrictions plugin. For this we will add the following notetag to the skill "Fire"
<Restrict>
LevelMin: 1
</restrict>
This will tell the plugin to only allow the actor to be able to use the ability if he is Level 1. This bug can be replicated with any restriction tag, I'm just using this one as an example.
Spoiler
RRXOvWl.png
Make sure to give your actor both the Fire spell and the Summon spell so you will be able to use them in game.

Now to replicate the bug.
Play test the game and enter battle by talking to the npc. Once in battle, use the Summon spell to summon the actor to battle. In this demo he won't be visible due to being designed to work with the side view battle system, but I can assure you this works when implemented, I've just omitted it to cut down on file size and to reduce the chances of interference from other plugins during this test. Once it is your turn to act again (not the summons) go to your skill menu, and the following error will appear.
Spoiler
Y1j5Kze.png

This bug can be stopped by changing the restrictions on the spell "Fire". If you have restrictions on any other spell that the player has not learned in game yet, the bug will not happen, it only happens when the player has a spell in his inventory that has the restrictions note tag applied.

I've also made a video replicating this bug that can be found here


Thanks for your time.
Greetings KawaiiKid,

Alright, going off what I said above, I've recreated the bug in a demo file you can find here:
Great!​

(I've removed almost all the sound and images from the folder to reduce the size of the download)
Thanks!

I've also made a video replicating this bug that can be found here

Wow - Very nice. 😎 I watched the video & it makes it super clear how to reproduce the bug:
  • I'll be linking to this bug report in the future as another example of writing a great bug report!

Joyfully,

Joy Diamond,

Spoiler: Updates as Joy is working to discover this bug ...
Spoiler: Irrelevant old history
P.S.: If no one else looks at it later today, I'll be sure to take a look at it (I have to head out to church now and then visit a friend afterwards to work on the MICA - Monster Is Coming ARGGH! game together ... so I can't look at it for quite a few hours ... but after that I can ...)

2017-11-20 12:00am UTC I'm looking to reproduce the bug now

2017-11-20 12:20am UTC Bug has been reproduced due to the excellent video by KawaiiKid .... but bad news ...
Spoiler: first stack trace
upload_2017-11-19_19-20-10.png

The bug is triggered inside of the rpg_core.js as a recursive call. These are hard bugs to find ... sometimes very hard ...
(NOTE: The bug is probably not in rpg_core, but just triggered there ...)

2017-11-20 12:30am UTC Ok, now we are looking at the code that is in the above stack trace ...
Spoiler: first look at the code
upload_2017-11-19_19-31-28.png

Ok, this is looking a bit more positive ... It is probably a recursive object that is self-referential from one of the other two plugins that is causing this bug ...

2017-11-20 12:45am UTC Ok, now we have modified the code & can see it in the debugger:
Spoiler: modified code to store in window.naughty
upload_2017-11-19_19-45-54.png
Spoiler: looking at window.naughty in the debugger
upload_2017-11-19_19-47-52.png

2017-11-20 1:20am UTC GRR, found a totally unrelated bug in rps_core.js!! Took me half an hour .... I'll report on it later ...

Spoiler: Here is our debug code (and solved the unrelated bug in rps_core.js):
upload_2017-11-19_20-28-8.png

Spoiler: Ok now we understand the self-referential problem (as suspected)
upload_2017-11-19_20-25-10.png

Spoiler: Ok have found the self-referential bug. Next to find who created this.
upload_2017-11-19_20-34-31.png

2017-11-20 2:00am UTC So have found the self-referential object & what it means:

It is basically Harold._summons[0]._battleSprite.parent.parent.parent.parent.stage.stage

Spoiler: Harold_summons[0]._battleSprite.parent.parent.parent.parent.stage.stage
upload_2017-11-19_20-59-24.png

Update: After looking at this 3 & a half hour, I have a very good idea of the bug. How to fix it is another matter though ....
Greetings KawaiiKid,

History:
Spoiler: Updates as Joy is working to discover this bug ...
2017-11-20 12:00am UTC I'm looking to reproduce the bug now

2017-11-20 12:20am UTC Bug has been reproduced due to the excellent video by KawaiiKid .... but bad news ...
Spoiler: first stack trace

The bug is triggered inside of the rpg_core.js as a recursive call. These are hard bugs to find ... sometimes very hard ...
(NOTE: The bug is probably not in rpg_core, but just triggered there ...)

2017-11-20 12:30am UTC Ok, now we are looking at the code that is in the above stack trace ...
Spoiler: first look at the code

Ok, this is looking a bit more positive ... It is probably a recursive object that is self-referential from one of the other two plugins that is causing this bug ...

2017-11-20 12:45am UTC Ok, now we have modified the code & can see it in the debugger:
Spoiler: modified code to store in window.naughty
Spoiler: looking at window.naughty in the debugger

2017-11-20 1:20am UTC GRR, found a totally unrelated bug in rps_core.js!! Took me half an hour .... I'll report on it later ...

Spoiler: Here is our debug code (and solved the unrelated bug in rps_core.js):

Spoiler: Ok now we understand the self-referential problem (as suspected)

Spoiler: Ok have found the self-referential bug. Next to find who created this.

2017-11-20 2:00am UTC So have found the self-referential object & what it means:

It is basically Harold._summons[0]._battleSprite.parent.parent.parent.parent.stage.stage

Spoiler: Harold_summons[0]._battleSprite.parent.parent.parent.parent.stage.stage
Update: After looking at this 3 & a half hour, I have a very good idea of the bug. How to fix it is another matter though ....
I have some good news for you:
  • My previous investigation showed that this was a mixture of three different bugs.
The good news is a major one of these bugs has been fixed with 1.6.0 Public Beta Test
  • The fix is lines 111-160.
  • From a private conversation I wrote, here is a link to the code explaining the issue:
Spoiler: Code for JsonEx._encode
index.php
  • Testing your sample program, but this time with 1.6.0 Public Beta Test shows the first bug has been solved 😎
  • Now that the first bug has been solved, the second bug is much easier to understand.
  • First we get a different (and much more useful) error:
upload_2017-11-24_11-8-3.png

​
  • Second this time the stack trace is on the exact problem (no longer masked by the first bug):
upload_2017-11-24_11-10-3.png

​
This second bug in Bob_EnhancedRestrictions.js still needs to be fixed; however, major progress 🙂​

index.php
Thanks,

Joy Diamond

Spoiler: Lots more details from another conversation about this bug in 'Bob_EnhancedRestrictions.js
The second bug, third & fourth bugs were found while working on this bug: Object to deep.

There are two bugs from this in RPG Maker MV CoreScript (this is the game engine that RPG Maker uses & is the js/rpg_*.js files in each game).

Spoiler: First bug in rpg_core.js incrementing depth twice per recursive call

The second bug has already been fixed (not by me, by someone else), and the fix can be seen in https:/js/rpg_core/JsonEx.js lines 111-160 (this is the github repository for the RPG Maker MV CoreScript):

Spoiler: Second bug in rpg_core.js fixing the circular reference fix

(NOTE: You can Compare this to the previous spoiler, which shows the current version of JsonEx._encode before the fix)
​
The fourth bug is in BOB_EnhancedRestrictions.js:

Spoiler: Fourth bug shown in BOB_EnhancedRestrictions.js

NOTE: The bug was not in Ellye's State Damage plugin & to fix the current bug report by Kawaiikid we need to, instead, get at the root of the problem in BOB_EnhancedRestrictions.js.​

​

Original thread: https://forums.rpgmakerweb.com/threads/object-too-deep.87418/