pixijs / spine

Pixi.js plugin that enables Spine support.
Other
567 stars 217 forks source link

Spine animation and animation listener not update when tab inactive (tab not visible) #296

Open majaclay opened 5 years ago

majaclay commented 5 years ago

Hi all, in my current project I faced one issue with spine listener. Part of my project promise was based on spine listener (complete) to resolve, then once user switch tab the listener became not working until user back to the tab. For your infomation, my project has auto-play function which user may on the auto play and leave it there and the promise stuck cause the function not work as I expected.

I did some research about the spine update. What I get is spine extend from PIXI.Container and PIXI.Container extend PIXI.accessibility.AccessibilityManager. Accessibility manager will manage the update function. The thing I want to do is when the Tab inactive i want to spine listener run as normal so that my promise will work fine.

However I found a solution here. Which keep all the spine in an array and when the tab inactive manually update spine animation, but this solution may cause memory leak and performance issue to user. Now I am looking for alternative way to solve this issue. Can anyone help me out ?

Thank you.

ivanpopelyshev commented 5 years ago

Alternative: wait when I make a super-plugin that can track all animations differently, not through updateTransform. I have that in my games but I cant share it yet. Maybe 3 months or so :)

update does not come from AccessabilityManager. Maybe it forces updateTransform() somehow, that's why you see it. render() method calls stage.updateTransform() which updates all matrices of all children and due to hacks it also updates spine objects.

The problem is that you have to track all spine objects somewhere in the list. of course it would be easy if PixiJS has addedOnStage and removedFromStage events, but sadly, we still aren't ready for it. See this rejected PR: https://github.com/pixijs/pixi.js/pull/4586

SUMMARY: that's one of things that im trying to create general solution for. Until then, you have to maintain your own list of spine objects, solution that is specific for your project.