Error sprite-animation-clip.js upon restarting same scene

Hello :wave:

I checked same game in version 1.61.3 works fine.

But giving error in version 1.62.1 and 1.62.2 (current).

Upon calling restart scene game got stuck with following error.

sprite-animation-clip.js:288 Uncaught TypeError: Cannot read properties of undefined (reading 'off')
    at SpriteAnimationClip._unbindSpriteAsset (sprite-animation-clip.js:288:15)
    at SpriteAnimationClip._destroy (sprite-animation-clip.js:421:18)
    at SpriteComponent.onDestroy (component.js:588:31)
    at SpriteComponentSystem.onBeforeRemove (system.js:259:19)
    at SpriteComponentSystem.fire (event-handler.js:201:26)
    at SpriteComponentSystem.removeComponent (system.js:75:14)
    at Entity.destroy (entity.js:519:33)
    at Entity.destroy (entity.js:535:23)
    at Entity.destroy (entity.js:535:23)
    at Entity.destroy (entity.js:535:23)
_unbindSpriteAsset	@	sprite-animation-clip.js:288
_destroy	@	sprite-animation-clip.js:421
onDestroy	@	component.js:588
onBeforeRemove	@	system.js:259
fire	@	event-handler.js:201
removeComponent	@	system.js:75
destroy	@	entity.js:519
destroy	@	entity.js:535
destroy	@	entity.js:535
destroy	@	entity.js:535
destroy	@	entity.js:535
(anonymous)	@	endGameManagerScript…fd-06ff912754b4:563
setTimeout (async)		
EndGameManagerScript.changeScene	@	endGameManagerScript…fd-06ff912754b4:562
EndGameManagerScript.restartGame	@	endGameManagerScript…fd-06ff912754b4:693
(anonymous)	@	VM209:1

Any help will be appreciated… :pray:

@yaustar knows this one I think.

1 Like

Can you create a public repro project please for us to look at?

@yaustar Please check DM. As i can not share link in public.

I’ve had a quick look at the project and this issue has been fixed in this PR Add null check before unbinding events sprite animation clip by yaustar · Pull Request #5272 · playcanvas/engine · GitHub

The real issue is that the Entity ‘bubble’ in the gameplay scene still had a reference to the sprite_ballon_green asset that is excluded from the project.

The entity is set to be ‘animated’ but if you switch it back to type ‘simple’, you can see the asset is being referenced still

I’ve removed the reference in your project and switched it back to animated which has fixed the issue

1 Like

That was quick! :smiley: :+1:
Thank you very much @yaustar for taking look this.

1 Like