Bug Issue: Scene won't open


Pages: 1

mbergoei

  • Subscriber - Stencyl Studio
  • *
February 10, 2022, 04:57:19 pm
Hi. Today, one of my scenes won't open in the editor. I'm getting the following error:

java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 4
   at stencyl.sw.app.tasks.StencylWorker.done(StencylWorker.java:74)
   at stencyl.sw.app.tasks.StencylWorker.done(StencylWorker.java:54)
   at stencyl.sw.app.tasks.OpenResourceTask.done(OpenResourceTask.java:81)
   at java.desktop/javax.swing.SwingWorker$5.run(Unknown Source)
   at java.desktop/javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(Unknown Source)
   at java.desktop/sun.swing.AccumulativeRunnable.run(Unknown Source)
   at java.desktop/javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(Unknown Source)
   at java.desktop/javax.swing.Timer.fireActionPerformed(Unknown Source)
   at java.desktop/javax.swing.Timer$DoPostEvent.run(Unknown Source)
   at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
   at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
   at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
   at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
   at java.base/java.security.AccessController.doPrivileged(Unknown Source)
   at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
   at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 4
   at stencyl.sw.editors.snippet.designer.block.Block.definitionFromXML(Block.java:1883)
   at stencyl.sw.editors.snippet.designer.block.Block.fromXML(Block.java:1976)
   at stencyl.sw.editors.snippet.designer.block.Block.fromXML(Block.java:2123)
   at stencyl.sw.editors.snippet.designer.block.Block.fromXML(Block.java:2123)
   at stencyl.sw.editors.snippet.designer.block.Block.fromXML(Block.java:2123)
   at stencyl.sw.editors.snippet.designer.block.Block.fromXML(Block.java:2123)
   at stencyl.sw.editors.snippet.designer.block.Block.fromXML(Block.java:2123)
   at stencyl.sw.editors.snippet.designer.block.Block.fromXML(Block.java:2123)
   at stencyl.sw.editors.snippet.designer.block.Group.fromXML(Group.java:209)
   at stencyl.sw.editors.snippet.designer.block.Block.fromXML(Block.java:2104)
   at stencyl.sw.editors.snippet.designer.block.Group.fromXML(Group.java:209)
   at stencyl.sw.editors.snippet.designer.EditArea.loadSnippet(EditArea.java:605)
   at stencyl.sw.editors.snippet.designer.EditArea.<init>(EditArea.java:741)
   at stencyl.sw.editors.snippet.designer.SnippetDesigner.createEditArea(SnippetDesigner.java:618)
   at stencyl.sw.editors.snippet.designer.SnippetDesigner.<init>(SnippetDesigner.java:342)
   at stencyl.sw.editors.scene.SceneTab.init(SceneTab.java:167)
   at stencyl.sw.editors.scene.SceneTab.<init>(SceneTab.java:122)
   at stencyl.sw.app.doc.Workspace.fetchEditorForResource(Workspace.java:844)
   at stencyl.sw.app.doc.Workspace.finishOpenResource(Workspace.java:703)
   at stencyl.sw.app.tasks.OpenResourceTask.doInBackground(OpenResourceTask.java:72)
   at stencyl.sw.app.tasks.OpenResourceTask.doInBackground(OpenResourceTask.java:20)
   at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)
   at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
   at java.desktop/javax.swing.SwingWorker.run(Unknown Source)
   at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.base/java.lang.Thread.run(Unknown Source)

I tried opening the scene as described in #1552 but it won't open.

Using b10925.

Thank you.
« Last Edit: February 10, 2022, 04:58:20 pm by mbergoei »


Justin

  • Master Stencyler
  • *
February 10, 2022, 07:21:23 pm
Looks like it's related to the use of custom blocks. Would you mind sharing your game so I can take a better look at the condition that causes this?


mbergoei

  • Subscriber - Stencyl Studio
  • *
February 11, 2022, 05:54:14 am
Hi Justin, no problem. How can I deliver it to you?


Justin

  • Master Stencyler
  • *
February 11, 2022, 09:30:24 am
If it's small enough, you can make this a private issue and attach it here, or you can send it as an email or discord attachment. Otherwise, upload it somewhere and send me link via PM.

I've sent you my email address as a message, in case you want to use email.


Justin

  • Master Stencyler
  • *
February 13, 2022, 05:04:31 pm
Ok, I think I understand what happened here.

You have multiple custom blocks defined in the events for that scene. Four of them have parameters with the same name, "Top_Row", "Mid_Row", and "Bottom_Row". Although the parameters have the same name, they have different internal IDs used when saving/loading the behavior, and used as a reference in the block spec when creating the block. In "MinMax Algorithm", they have the IDs 5, 6, and 7, respectively. In "Gameover Verification", they have the IDs 0, 1, and 2.

In the "Gameover Verification" event, the Top/Mid/Bottom_Row blocks have the internal IDs of 5, 6, and 7 instead of the expected IDs of 0, 1, and 2. I'm presuming here that you copied the blocks from one event to the other.

When the event loads, it sees the parameter blocks and assume that they belong to the custom block in which they're found, but the IDs are wrong (too high) so they cause an out-of-bounds array access.

For now, I've improved the behavior loading code to not break when something like this happens, and instead treat the parameters with out-of-bounds IDs as unknown blocks. You can grab the latest build (4.1.0-beta3/b10926) to open your scene and manually fix the code in the "Gameover Verification" custom block.
« Last Edit: February 13, 2022, 06:20:01 pm by Justin »


Justin

  • Master Stencyler
  • *
February 13, 2022, 06:22:28 pm
I just re-read my post and realized I wrote the wrong build number. It should be (4.1.0-beta3/b10926). Edited the post.


mbergoei

  • Subscriber - Stencyl Studio
  • *
February 15, 2022, 03:52:27 pm
Hi Justin! Thanks for the big help! :) Never thought a bug would happen with custom blocks. Just opened the file and redo the custom blocks so that each of the variables had different names.


Justin

  • Master Stencyler
  • *
February 15, 2022, 05:52:14 pm
Glad I could help.

To be clear, there's no problem with the parameters having the same name. The only problem is that parameters are not really copied between events as you may expect. The internal IDs were different, but the names were the same, so it may have seemed like it worked, but really nothing at all happened.

In general, I think that it would be best to simply not allow custom block parameters to be copied to other events, since it makes no sense. In this specific case, where you have similarly named parameters, perhaps it would make sense to automatically convert the parameters from one event to the other.

Anyway, the issue preventing your scene from loading has been fixed, so I'll file that as a separate issue.
  • Status changed from New to Resolved


Pages: 1

Details

  • Reported
    February 10, 2022, 04:57:19 pm
  • Updated
    February 15, 2022, 05:52:14 pm

  • View Status
    Public
  • Type
    Bug
  • Status
    Resolved
  • Priority
    Normal
  • Version
    (none)
  • Fixed in
    (none)
  • Assigned to
    (none)
  • Category
    Scene Designer

Tags