Repository navigation
Contain RNTester's tab bar controller before its view enters a window - #60368
Conversation
df004a4 to
85200a3
Compare
`RNTesterTabsIOSComponentView` installed its `UITabBarController`'s view as its content view when it was created, so the view entered the window with the component, and the controller became a child of the view controller above only afterwards, in `didMoveToWindow`. UIKit's containment rules ask for the opposite order. On an iPhone Duo launched unfolded, the last inset update at launch saw the tab bar with a bottom bar's frame although it was on the side, so RNTester applied a bottom bar's insets (50 points at the top, 65 at the bottom). On a physical iPhone Duo (iOS 27.2) RNTester also sometimes came up with no tab items; that may have the same cause. Install the view only while the controller is a child, in the order UIKit documents for container view controllers: `didMoveToWindow` adds the controller to the view controller above, sizes and installs its view, then calls `didMoveToParentViewController:`, and reverses that when the component leaves the window. With no view controller above the component, the tabs are not installed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
85200a3 to
26c4d17
Compare
chrfalch
left a comment
There was a problem hiding this comment.
The containment order looks right to me, in both directions. (Commenting rather than approving since it's still a draft.) Two requests:
1. Make the code comment match the evidence. The comment above didMoveToWindow says a tab bar laid out before its controller has a parent "can lose its items, as the iPhone Duo's side tab bar does". What the PR shows reproducibly is the wrong tabBar frame and the bottom-bar insets. The missing items were seen only sometimes on a physical device and not on the simulator, and the description itself says they only "may have the same cause". Could the comment describe the wrong frame and insets instead?
2. Before/after screenshots. The inset bug reproduces on every launch on the iPhone Duo simulator (unfolded). Screenshots from main and this branch would make the fix easy to see:
- the top of the example list (y = 137 vs 103)
- the end of an example page such as Button (the extra 65 points)
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D135059659. |
zeyap
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
|
|
This pull request was successfully merged by @ide in 19c49e3 When will my fix make it into a release? | How to file a pick request? |
Summary:
RNTester's iOS tabs are a
UITabBarControllerhosted inRNTesterTabsIOSComponentView. The component installed the controller's view when it was created, and made the controller a child of the view controller above only later, indidMoveToWindow. UIKit's containment rules ask for the opposite order.On an iPhone Duo simulator (iOS 27.1) launched unfolded, the last inset update at launch on
mainseestabBarwith a bottom bar's frame,{{0, 595}, {466, 83}}, although the bar on screen is on the side; with the controller contained first, every update sees the side bar. So onmainRNTester applies a bottom bar's insets, 50 points at the top and 65 at the bottom instead of 16 and 0: the example list starts 34 points lower than with the side bar's insets, and every example page ends with 65 points of empty space. On a physical iPhone Duo (iOS 27.2), RNTester also sometimes came up with no tab items until sent to the background and back; that may have the same cause, but it did not reproduce on the simulator.didMoveToWindownow follows the order UIKit documents for container view controllers: it adds the controller as a child, sizes and installs its view, then callsdidMoveToParentViewController:, and reverses that when the component leaves the window. With no view controller above the component, the tabs are not installed; before, they showed without a parent controller.Changelog:
[INTERNAL] [FIXED] - Contain RNTester's iOS tab bar controller before its view enters the window
Test Plan:
RNTester builds (Xcode 27.1). Run in Debug on an iPhone Duo (iOS 27.1, unfolded), an iPad Pro 13-inch (M5) and an iPhone 18 Pro (iOS 27.0) simulator.
On the iPhone Duo, a local log in
tabSafeAreaInsetsDidChangeshows the frames and insets above; on this branch every call sees the side bar ({{397, 0}, {69, 678}}). A local UI test measures:mainand y = 103 on this branch.mainand 93 on this branch.mainOn the iPhone 18 Pro and the iPad the frames are the same on both builds, and on the iPhone, turning to landscape and back keeps the list's last row above the tab bar.