Popover arrow is not pointing to the correct location after changing app size in iPadOS split view

I have a popover that is attached to a UIBarButtonItem and I am experiencing an issue with the location of the arrow in the popover's navigation bar.

My desired behavior is to have the arrow pointing at the bar button item that triggered the popover to display. To to this, I have the following IBAction attached to the bar button from storyboard.

Code Block swift
@IBAction func openPopover(_ sender: Any) {
let navigationController = UINavigationController(rootViewController: myViewController)
navigationController.modalPresentationStyle = .popover
let popover = navigationController.popoverPresentationController
myViewController.preferredContentSize = CGSize(width: 500, height: 820)
popover?.delegate = self
popover?.sourceView = self.view
popover?.permittedArrowDirections = .up
popover?.barButtonItem = myBarButtonItem
present(navigationController, animated: true)
}


This creates the desired behavior, where the arrow of the popover points at myBarButtonItem, even after rotation and in split view.

My issue is when I create and present the popover when the app is in the 1/3 screen width on iPadOS. The popover will be presented as a modal, and when I change the app to a larger size that is not a compact horizontal size class, the arrow will be way too far right of the bar button item.

The issue only happens when the app size is changed from 1/3 screen size width to a non compact horizontal size class. When the app changes from 1/2 screen size on the 11 inch iPad Pro to full screen, the issue does not occur even though 1/2 screen width on 11 inch iPad Pro is also a compact horizontal size class.

The issue occurs on the simulator and on device.

Popover arrow is not pointing to the correct location after changing app size in iPadOS split view
 
 
Q