three-mesh-ui icon indicating copy to clipboard operation
three-mesh-ui copied to clipboard

onAfterUpdate is not fired after initial component setup

Open felixmariotto opened this issue 3 years ago • 6 comments

It looks like onAfterUpdate is not triggered in this fiddle

Investigating...

felixmariotto avatar Jun 08 '21 20:06 felixmariotto

Interesting. Looks like you are updating ThreeMeshUI outside of the main animation loop. Rather, you call it once via setTimeout.

Out of curiosity, I threw a basic counter in that fiddle and logged the number of calls to animate before onAfterUpdate is called when ThreeMeshUI is updated in the animate function. It isn't exactly consistent, but I don't see onAfterUpdate fire until after 5-7 calls to animate. Feels like an asynchronous issue?

JoeCoppola-HIA avatar Jun 08 '21 20:06 JoeCoppola-HIA

Actually, it's a little odd. Replacing the setTimeout with a setInterval still doesn't have the callback fire, regardless of how many times Update is called from it. Maybe a JS scope issue?

JoeCoppola-HIA avatar Jun 08 '21 20:06 JoeCoppola-HIA

And I can't reproduce locally.

felixmariotto avatar Jun 08 '21 21:06 felixmariotto

I just tested locally myself on my fork, also am unable to reproduce locally using similar code. Super odd.

JoeCoppola-HIA avatar Jun 08 '21 21:06 JoeCoppola-HIA

Actually, it's a little odd. Replacing the setTimeout with a setInterval still doesn't have the callback fire, regardless of how many times Update is called from it. Maybe a JS scope issue?

This is expected, because when you don't set new properties to a component it has no reason to update, so it doesn't update, so it doesn't trigger onAfterUpdate.

Here is the fiddle modified with a setInterval, it does trigger onAfterUpdate if I change the text content at each interval : https://jsfiddle.net/felixmariotto/2kny51ru/ However onAfterUpdate is still not fired after the first update ( after the first call to setInterval callback, when the panel reads "number of tries: 1" ).

I've no idea what is happening honestly... And it's late here ( in France ), so I will have to leave it like this for now... I keep the issue open, tell me if you run into the issue in another context.

felixmariotto avatar Jun 08 '21 21:06 felixmariotto

All good, I've thankfully not run across this bug yet on my side. Just interesting to learn more about it. Thanks for your help again.

JoeCoppola-HIA avatar Jun 08 '21 21:06 JoeCoppola-HIA