fix encoder's crash bug