I've had this problem before. What I did that seemed to fix the problem was turn up the gpu memory, which can be done this way
This is the raspberry pi configuration (I am using raspberry pi os buster which is basically Debian 10) which can be found by clicking on the applications icon in the top left corner of the screen an going to preferences and raspberry pi configuration and then performance. It is something like that if you have a slightly different version of Debian.
There is a commandline way to do it as well. That is to enter
sudo nano /boot/config.txt
into a terminal window and scrolling to the bottom, where you will find:
This is overclocked, but look at the
gpu_mem line, and raise about 25 to 50 numbers. then, hit Ctrl+X and then
y and then Enter. That should fix it; it did for me.