fix(iOS, Tabs): weak-capture tab bar item and screen view in async image callbacks#4111
Conversation
…llbacks Avoid updating a tab bar item whose internal view hierarchy has been torn down. This works around an iOS 26 UIKit regression where unowned refs inside UITabBarItem._updateViewAndPositionItems: cause crashes. Both the normal icon and selected icon completion blocks now: 1. Weak-capture tabBarItem and screenView before the block 2. Promote to strong refs inside the block and bail if either is nil 3. Guard that the screen's controller is still parented by a UITabBarController
The semantics look okayish. It won't hurt to add guard checks for whether the `tabBarItem` / `screenView` has not been dealocated in the meantime or it has been detached from the tab bar. One thing though is that when reattaching to window -> it is likely that we need to trigger appearance update.
kkafar
left a comment
There was a problem hiding this comment.
Hello!
I can not really reproduce the issue, but it won't hurt to add a null-guard & verify whether we have been not detached from the parent controller since block-schedule-time.
One thing though -> this slightly changes semantics. Earlier, even if we were detached from the parent controller, the update would go through, effectively setting tabBarItem.image / tabBarItem.selectedImage. Now it won't. This implies that we might need to take care of reapplying the appearance at the moment we receive didMoveToParentViewController on RNSTabsScreenViewController.
I'll look into it.
kkafar
left a comment
There was a problem hiding this comment.
Okay, we already request appearance update on didMoveToParentViewController.
Seems fine then.
Description
Avoid updating a tab bar item whose internal view hierarchy has been
torn down. This works around an iOS 26 UIKit regression where unowned
refs inside UITabBarItem._updateViewAndPositionItems: cause crashes.
Both the normal icon and selected icon completion blocks now:
Before & after - visual documentation
TBA
Test plan
Discussed offline
Checklist