Servo stutter with DFplayer mini

I'm trying to have the DFplayer play a sound while the servo moves from 180 to 40 degrees, and then pause the DFplayer while the servo moves back from 40 to 180 degrees. I'm avoiding using delay in the loop, but it does not make a difference for the brief stutter I'm experiencing. I used Wokwi to test and there is a jitter in servo movement right around the Short Pause (see code).

Am I missing something here?

Here's the code

#include <Arduino.h>

#define ENABLE_EASE_QUADRATIC

#include "ServoEasing.hpp"

ServoEasing Servo1;

#include <DFPlayerMini_Fast.h>

DFPlayerMini_Fast player;

#define START_DEGREE_VALUE 90

#include <SoftwareSerial.h>

SoftwareSerial softSerial(/*rx =*/4, /*tx =*/5);

#define mySerial softSerial



void setup()  {
    pinMode(LED_BUILTIN, OUTPUT);
    Serial.begin(115200);

    delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!

    // Just to know which program is running on my Arduino
#if !defined(PRINT_FOR_SERIAL_PLOTTER)
    Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_SERVO_EASING));
#endif

softSerial.begin(9600);
  
player.begin(softSerial, true);

player.volume(20);

Servo1.attach(9);

      Serial.println(F("Set easing type to QUADRATIC_IN_OUT for Servo1"));
      Serial.println(F(""));

Servo1.setEasingType(EASE_QUADRATIC_IN_OUT);

// Move servo to good start position
setSpeedForAllServos(50);
Servo1.easeTo(180);

      Serial.println(F("Getting Ready"));
      Serial.println(F(""));
delay(4000);

}


void loop() {


uint16_t tSpeed = (random(80 , 100));
 
setSpeedForAllServos(tSpeed);

player.playNext();

Servo1.easeTo(40);



//Short Pause

int16_t shortPause = random(25, 400 + 1);

unsigned long SPause = millis();
while(millis() - SPause <= shortPause)
{
      ; 
}

player.pause();

int16_t outSpeed = tSpeed - random(10, 30 +1);
setSpeedForAllServos(outSpeed);


Servo1.easeTo(180);

//Long  Pause
   
uint16_t LongPause = random(1500, 2000 + 1);


unsigned long LPause = millis();
while(millis() - LPause < LongPause)
{
      ; 
}

}

Tell us what you think is happening DURING your pauses.

Well, what I think is happening is that the servo first moves from 180 to 40, then stands still for x milliseconds and then starts moving again from 40 to 180. Meanwhile the audio is played for the duration of the first servo move and paused right after the shortPause.

That is at least what I would expect to happen. But instead, the second servo movement (from 40 to 180) starts but then it jumps back a tiny bit and starts over again, as if it is trying to catch up with or correct some timing mistake.

Your pause loops are identical to just calling a delay() function. Nothing happens until the loop finishes.

That is correct. Nothing should happen during the pauses. The problem is not with the pauses. When I remove them, the jitter still happens.

void loop() {


uint16_t tSpeed = 100;
 
setSpeedForAllServos(tSpeed);

player.playNext();

Servo1.easeTo(40);

player.pause();

Servo1.easeTo(180);

}

there's a jitter between the two servo movements.