Shader not working on animated sprite in 3.13.1

I am trying to update to 3.13.1 from 3.10 everything works fine but one new bug, one of my shaders refuses to work in some conditions.

i use a shader to color sprites to a team color by replacing magenta with the teams color. it is not working when applied to animated sprites in game where there are a lot of these sprites. it works fine if the sprites are not animated and also works fine in the main menu with an animated sprite by itself. with my unit sprites the shader will sometimes work but with some lag before it kicks in. and it all still works fine with the older engine and the same code.

i am out of ideas as to what is causing this, any ideas will be appreciated.
The game is currently available on steam early access if you want to get an idea what it looks like http://store.steampowered.com/app/546870

teamcolor.fsh

uniform sampler2D u_texture;

uniform vec3 u_color;
uniform float u_opacity;

varying vec4 v_color;
varying vec2 v_texCoord;

void main()
{
	vec4 texColor = texture2D(CC_Texture0, v_texCoord);
	if(texColor.g < texColor.r-0.15 && texColor.g < texColor.b-0.15 && texColor.b > texColor.r-0.25 && texColor.b < texColor.r+0.25)
	{

		float brightness = texColor.r;
		vec3 brightColor = u_color*brightness;
		float grey = dot(texColor.rgb, vec3(0.299, 0.587, 0.114));
		gl_FragColor = vec4(mix(brightColor, vec3(grey, grey, grey), 0.2),texColor.a);
	} else {
		gl_FragColor = texColor;
	}
}

teamcolor.vsh

#ifdef GL_ES

attribute mediump vec4 a_position;
attribute mediump vec2 a_texCoord;
attribute mediump vec4 a_color;
					
varying mediump vec4 v_color;
varying mediump vec2 v_texCoord;

#else

attribute vec4 a_position;
attribute vec2 a_texCoord;
attribute vec4 a_color;
					
varying vec4 v_color;
varying vec2 v_texCoord;

#endif
						
void main()	
{							
    gl_Position = CC_PMatrix * a_position;
	v_color = a_color;
	v_texCoord = a_texCoord;
}
cocos2d::Sprite* UI::makeAnimatedHexSprite(int type, int level, bool flipped, Player* player)
{
	cocos2d::Sprite* sprite = cocos2d::Sprite::create();
	char animationName[32] = { 0 };
	if (level == -1)
	{
		sprintf(animationName, "ruins");
	}
	else {
		sprintf(animationName, "%d_%d", type, level);
	}

	cocos2d::Animate* animate = cocos2d::Animate::create(cocos2d::AnimationCache::getInstance()->getAnimation(animationName));
	sprite->runAction(cocos2d::RepeatForever::create(animate));  // run action on sprite object

	sprite->setFlippedX(flipped);
	sprite->setAnchorPoint(cocos2d::Vec2(0.5f, 0.25f));

	if (player != NULL)
	{
auto gl_cache = cocos2d::GLProgramCache::getInstance();
	cocos2d::String* programName = cocos2d::String::createWithFormat("teamcolor%d", this->ID);
	cocos2d::GLProgram* shaderProgram = gl_cache->getGLProgram(programName->getCString());

	if (shaderProgram == NULL)
	{
		shaderProgram = cocos2d::GLProgram::createWithFilenames("shaders/teamcolor.vsh", "shaders/teamcolor.fsh");
		gl_cache->addGLProgram(shaderProgram, programName->getCString());
	}

	cocos2d::GLProgramState* shaderProgramState = cocos2d::GLProgramState::getOrCreateWithGLProgram(shaderProgram);
	cocos2d::Color4F c = cocos2d::Color4F(this->color);
	shaderProgramState->setUniformVec3("u_color", cocos2d::Vec3(c.r, c.g, c.b));
	sprite->setGLProgramState(shaderProgramState);
	}

	return sprite;
}

i added some code to reapply the shader to the sprite when i click it and this worked but only for once cycle of the animation. the animation is set to repeat forever and each time it repeats the shader is lost.

I tried adding a callback that would reapply the shader each animation loop. In sequence nothing happens in spawn the shader starts working but only for one frame then stops.

if anyone has any ideas on how i could further debug this that would be a great help because im out of ideas.

I think i have same issue, but with build-in shader:
i have animated sprite and now every frame has thin black border. Sprite without animation draw fine.
Issue happened after upgrade cocos2d-x from 3.10 to 3.13.1 version.

Update:
it was premultiplied alpha issue, i just changed one variable from “true” to “false”
platform/CCImage.cpp
bool Image::PNG_PREMULTIPLIED_ALPHA_ENABLED = false;

This continues to be a problem for me in cocos2d-x 3.14

I think this could be a problem with the blending function. Checkout this issue: https://github.com/cocos2d/cocos2d-x/issues/16732