I have an app that supports screen mirroring by connecting to an external display to show a different UI (not just playing a video). Most of the time it works great, but it occasionally has issues with 4K TVs where the screen and audio are glitchy on the TV. I tell people to go through all the troubleshooting steps from Apple about getting AirPlay to work. Sometimes it helps, but not always, so I'd like to have a more permanent fix.
I am suspicious that it happens because too much data is being sent over AirPlay too frequently. I was hoping to either be able to limit the frequency of updates (maybe lowering the refresh rate somehow) or to decrease the resolution of the view controller that is sent over AirPlay. I have not found anything for the first idea, but regarding the second one, in the docs, it says that you can change the UIScreen's currentMode property (effectively changing the resolution). I have tried doing this in multiple ways, but I have not been able to get that to work--after assigning a different value to currentMode it still has the old value. The docs say to "apply that mode to the UIScreen object before associating the screen with a window." There are two problems here:
- That instruction seems to be a little outdated because since iOS 13 the UIScreen is associated with a UIWindowScene instead of UIWindow. Does that make any of this different with how I can/should update the UIScreenMode?
- I have tried setting the
currentModeinside the observation block forUIScreen.didConnectNotificationas well as inside the AppDelegate'sapplication(:configurationForConnecting:options)method. Neither of those have worked, even if the UIScreen is not yet associated with a UIWindowScene.
If I'm going about this incorrectly, please help me correct my mistake. Ultimately I just want to fix the glitchiness with screen mirroring, so I'm happy to do that in whatever way I can.