Gnome desktop freezes randomly about once a day

My Gnome desktop + mouse + keyboard freeze randomly about once a day. Keyboard shortcuts don`t work as all input devices are frozen , too.

It might be linked to Firefox playing multimedia files e.g. youtube content. Whenever it happens, the sound of the last fraction of a second before the desktop froze is played in an endless loop.