We recently started testing our Cocos2d-x game on Android with the Address Sanitizer enabled to find memory issues. (see https://developer.android.com/ndk/guides/asan). We've seen numerous crashes (a use after free) in the AnimationState's EventQueue::drain() method, specifically this line:
if(!state._listenerObject) state._listener(&state, queueEntry->_type, trackEntry, NULL);
We debugged the problem back to setting a setEmptyAnimation() call inside a setTrackCompleteListener's callback. Example:
getSpine()->setTrackCompleteListener(track, [=](spine::TrackEntry*) {
getSpine()->setEmptyAnimation(ANIM_LAYER_CHECK_BL, 0);
getSpine()->setEmptyAnimation(ANIM_LAYER_CHECK_BR, 0);
getSpine()->setEmptyAnimation(ANIM_LAYER_CHECK_TL, 0);
getSpine()->setEmptyAnimation(ANIM_LAYER_CHECK_TR, 0);
CharacterEvents::KnockedOut knockedOutEvent(this);
knockedOutEvent.dispatchEvent();
});
We're able to workaround the issue in most cases by moving the setEmptyAnimation outside of the callback, but wanted to see if Esoteric had any feedback on the issue. This is happening with a version of the runtime from the 3.8 branch taken in September 2019.