Why are RS485 frames corrupted between ESP32 and ESP8266?

It seems that both your ESP32 master and ESP8266 slave codes lack proper DE/RE control for the SP3485 transceivers, which is essential to switch between transmit and receive ➜ without it, the bus can float or experience contention, causing exactly the sporadic byte corruption you observed.

On the ESP32, HardwareSerial at 115200 baud is reliable, but still requires DE/RE toggling.

On the ESP8266, using SoftwareSerial at 115200 is inherently unreliable due to timing limitations, so hardware UART is recommended.

I think both sides should use a GPIO to assert DE during transmission and deassert it immediately afterward, and the ESP8266 should ideally switch to HardwareSerial.