Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spine Plugin crashes in HEADLESS mode #4988

Closed
raimon-segura opened this issue Feb 6, 2020 · 2 comments
Closed

Spine Plugin crashes in HEADLESS mode #4988

raimon-segura opened this issue Feb 6, 2020 · 2 comments
Labels
🐛 Spine An issue arising from the Spine runtime

Comments

@raimon-segura
Copy link

Version

  • Phaser Version: Phaser v3.22.0 (Headless | Web Audio)
  • Operating system: Ubuntu 18.04
  • Browser: Version 79.0.3945.130 (Official Build) (64-bit) & Karma/mocha ChromeHeadless tests

Description

"this.add.text" crashes, seems that code should check the current renderer :

VM53:26911 Uncaught TypeError: Cannot read property 'height' of null
at SpineGameObject.updateSize (:26911:31)
at SpineGameObject.setSkeleton (:26710:21)
at new SpineGameObject (:26390:18)
at GameObjectFactory.add [as spine] (:6666:27)
at Scene.create (eval at (frame.html:45), :33:14)
at SceneManager.create (VM42 3.22.0.js:77900)
at SceneManager.loadComplete (VM42 3.22.0.js:77812)
at LoaderPlugin.emit (VM42 3.22.0.js:1754)
at LoaderPlugin.loadComplete (VM42 3.22.0.js:173994)
at LoaderPlugin.fileProcessComplete (VM42 3.22.0.js:173960)

https://github.com/photonstorm/phaser/blob/v3.22.0/plugins/spine/src/gameobject/SpineGameObject.js#L761
...
var height = renderer.height;
....

Example Test Code

Using this example as a template( https://labs.phaser.io/edit.html?src=src/spine/3.8/basic%20spineboy.js&v=3.22.0 ) :

var config = {
type: Phaser.HEADLESS,
parent: 'phaser-example',
width: 800,
height: 600,
backgroundColor: '#2d2d2d',
scene: {
preload: preload,
create: create,
pack: {
files: [
{ type: 'scenePlugin', key: 'SpinePlugin', url: 'plugins/3.8/SpinePlugin.js', sceneKey: 'spine' }
]
}
}
};

var game = new Phaser.Game(config);

function preload (){
this.load.image('logo', 'assets/sprites/phaser.png');
this.load.setPath('assets/spine/3.8/demos/');
this.load.spine('set1', 'demos.json', [ 'atlas1.atlas' ], true);
}

function create (){
this.add.image(0, 0, 'logo').setOrigin(0);
this.add.spine(400, 600, 'set1.spineboy', 'idle', true);
}

Thanks!

@raimon-segura
Copy link
Author

raimon-segura commented Feb 6, 2020

I've found a workaround, just create a renderer object literal if its a test:

this.game = new Phaser.Game(config)
this.game.renderer = {width:100, height:100, preRender: function(){}, postRender: function(){}, render: function(){}, destroy: function(){}}

@photonstorm photonstorm added the 🐛 Spine An issue arising from the Spine runtime label Aug 24, 2020
@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Spine An issue arising from the Spine runtime
Projects
None yet
Development

No branches or pull requests

2 participants