Alright, so after fixing some other Wi-Fi issues, I think I'm one last step closer to a stable connection. My current obstacle is that periodically (roughly every 10 minutes or so) the output of journalctl -ef shows "timed out to flush queue 3" twice, which is then followed by iwd showing "Received Deauthentication event, reason: 4, from_ap: false". After that, my Wi-Fi disconnects though it reconnects successfully every time after a few seconds. Note that the timed out message always occurs twice every time. No more, no less. I'm using a Linksys WUSB6300 V2 Wi-Fi adapter (newly bought) with rtw_882bu driver in Ubuntu 23.04 using Linux kernel version 6.2.0-20-generic.
I've done lots of research over the past few days, and it looks like it might be related to NetworkManager performing scans at (what seems like) 10 minute intervals, but I'm not 100% sure if that's the cause of the problem. Also it seems like "reason 4" means inactivity, but this happens even when I have, say, a steam game installing in the background while watching youtube. One other thing is that sometimes, "timed out to flush queue 3" is spammed in journalctl for a good 10 or even 15 minutes but I've noticed it's kind of random. The full message looks like this:
"kernel: rtw_8822bu 1-5:1.0: timed out to flush queue 3"
It's usually coupled with "kernel: rtw_8822bu 1-5:1.0: timed out to flush queue 1" too, but the 3 is more common.
I've tried disabling power management for the Wi-Fi but it didn't help all that much. Gave "11n_disable" a try. Nothing.
I've aksed a question before that's related to this, but I think this is a completely different problem from what the other question was. That had many more errors coming up and I was using wpa_supplicant at the time. Made the switch to iwd to see if it helped, and it definitely did. Just need to figure this out now and I'm good to go.