The behavior is very strange. I've tried using handcrossbows to attack from invisiblity and it correctly applies the sneak attack. So, the bug is with invisibility and melee attacks that applies sneak attack damage dice passively.