I have this same problem intermittently. I would note that your "solution" only addresses iOS, which has nothing to do with this problem. A MacBook, like my MacBook Pro, runs on MacOS not on iOS. I don't know if the problem is a bug in Apple AirPlay or whether it is a Roku problem. The procedure to connect goes as follows after initial setup and connection.
1. Turn on the TV that the Roku device is connected to. I have a Roku Streaming Stick.
2. Open System Settings. One way to do that is to click on the black apple on the upper left corner.
3. Select Displays.
4. In the pulldown menu on the top right, Select Roku Streaming Stick or whatever the name of your device is.
In my case, I have an external monitor, and I am trying to mirror it to the Roku device attached to my TV. Normal behavior is for both screens (MacBook Pro and external monitor) to both go black for a few seconds. Note that there is a Finder bug which scrambles file icons on the MacBook Pro, but these will return to their normal positions after mirroring is turned off. I have reported this bug to Apple, but they have not fixed it yet. This happens every time.
I see two kinds of abnormal behavior. Sometimes, the video feed to the external monitor stops. In that case, turning mirroring off and on usually fixes that. This one is intermittent and does not occur often. This can also occur when mirroring is stopped. Again, turning it on and off generally fixed the problem.
The more serious problem is when AirPlay fails to connect to the Roku. There was a bug several updates ago in which that always happened when the Firewall was turned on. It also helped to have an Ethernet connection in addition to the WiFi connection. That bug, which obviously compromised security, was quickly fixed.
Since then, I find that AirPlay connects with no issues for a few days. Then it stops connecting for a few days. I am currently in the latter state so I have to watch videos on my monitor instead of on my TV. Both my Mac and the Roku device are on the same network with strong connections. After a few minutes, the MacBook shows a message that AirPlay failed to connect to Roku Streaming Stick. The interesting thing is that the MacBook can obviously "see" the Roku device since the name of the Roku device appears in the dropdown menu in System Settings/Displays. My Mac currently has 939 Mbps download and 717 Mbps upload. (I have fiber into my house and a fast router. The speeds directly to and from the router are probably higher.) My iPhone, which only uses WiFi, has 764 download and 478 upload, and that is likely what the Roku device is getting, too. All are on the same WiFi network.
I don't believe this can be a setup problem because sometimes it works and they connect and sometimes they don't. That is without changing any settings. I have also logged this bug to Apple, but nothing has been done to fix it to date, assuming that this is an AirPlay bug rather than a Roku bug. I'm running softwear version 14.5.4 build 5944. MacOS btw is Sequoia 15.5.