phaserjs / phaserjs/phaser

Destroying a Spine game object and then switching scenes and adding a different Spine causes a rendering issue

Open
#6,980 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🐛 3rd Party Lib Bug 🐛 Spine
Dominant language
JavaScript
Stars
40.3k
Forks
7.2k
PR merge metrics
No merged PRs in 30d

Description

Version

  • Phaser Version: 3.86.0 and Spine 4.1
  • Operating system: Windows
  • Browser: Chrome, Edge, Firefox

Description

If you add a Spine game object to a scene, and then destroy it, go to another scene, and then try to add a different Spine game object ("different" in this case means a different key) to the scene, the texture that is used for the Spine will flash on the screen for a frame. I'm guessing there's a binding issue somewhere.

Example Test Code

The following code will demonstrate the issue:

export default class TestScene1 extends Phaser.Scene {
  create() {
    this.cameras.main.setBackgroundColor(0xffffff);
    this.testSpine = this.add.spine(500,500, "spine0");

    this.time.delayedCall(5000, ()=> 
    {
      this.testSpine.destroy();
      this.scene.start("Test2");
    });
  }
}

export default class TestScene2 extends Phaser.Scene {
  create() {
    this.cameras.main.setBackgroundColor(0xffffff);

    this.testSpine = this.add.spine(500,500, "spine1");
  }
}

Note that the Spines used in the 2 different scenes must be different ones, if you use the same key for both, the issue does not happen. Other ways to prevent it from happening:

  1. If you add the TestScene1 Spine again in TestScene2 FIRST, when you add the other Spine, the issue won't happen.
  2. If you don't call .destroy() on the Spine game object in TestScene1, the issue won't happen in TestScene2.

There are probably other ways to prevent it from happening. I tried a few different sets of our Spine objects and it's happening no matter what I use, but it's possible there is something in our Spines that causes the issue.

Additional Information

I wasn't able to test using Spine 3.8.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TestScene1 and TestScene2 reproduction: add Spine key "spine0", destroy it, switch with scene.start("Test2"), then add "spine1". Trace the add.spine and destroy flow around the scene transition, and verify that the replacement Spine texture no longer flashes for a frame in Chrome, Edge, and Firefox.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.