OLED I2C pausing

I get these weird cutouts whenever I update the OLED display. It seems as though my whole program stops. I’ve tried modifying my OLED update function and regardless of how much I put into it, if the screen gets updated, the program pauses.

Here is a recording of the output when the display is not being updated:

And another recording of the output when the display is being updated regularly but nothing is being displayed. It sounds the same regardless of what is being displayed.

I am using a OLED 128x64 SSD1306 plugged into i2c_1.

If there is any way to multithread this or use the I2C DMA stuff to run the update in the background that would be amazing.

Are you writing to the OLED from in the audio callback?

Yes, I changed it to update in the main loop and that works for the most part. I kept most of the things updating the OLED buffer inside the audio callback and just called the display update method in the while loop at regular intervals. The program never crashes but the screen freezes occasionally and has some weird visual glitches. Is there a better way to be updating the OLED?