It does not happen only in LibreOffice but also a few other applications, maybe not Firefox. Some are mentioned in the corresponding bugs somewhere:
- https://bugs.documentfoundation.org/show_bug.cgi?id=128803
- https://gitlab.gnome.org/GNOME/mutter/issues/919
- https://launchpad.net/bugs/1852183
See also Wikipedia’s Mutter and Compositing window manager articles.