Our Black Lab, Sam, does this occasionally. Sometimes her legs will also twitch as she barks. I have always thought
that she may be dreaming...........do dogs dream?............ It lasts for only a short time. I have especially noticed it when she is tired from running.