For anyone who finds this post, I have found out what the error was. This is the same bug as
https://gitlab.freedesktop.org/drm/amd/-/issues/234
It is a problem in the automatic power switching, and it is a bug that has persisted for a number of years. If you go to
/sys/class/drm/card0/device/power_dpm_force_performance_level
and find that the default value is auto, you can change to low or high to see if this resolves your issue. I personally use low because I don’t want my gpu running on high power all the time. There are some other solutions revolving around setting the GPU clock and the like, but this is the solution I took.